« first day (3674 days earlier)      last day (1290 days later) » 
02:00 - 22:0022:00 - 00:00

2:27 AM
morning room.
and happy friday all.
 
 
5 hours later…
7:17 AM
Phar does not decompress properly ・ PHAR related ・ #80326
 
 
3 hours later…
10:11 AM
moin
 
yo
arrow functions work when I use it inside array_map, but is it possible to use them externally? 3v4l.org/fR19Q
 
@Shafizadeh Yes, but you can't use echo since it's a statement.
 
do you know any document about it to explain it all in PHP?
 
@Shafizadeh 3v4l.org/gnvQV
 
ah thx
 
10:19 AM
@Shafizadeh I would consider that a hack though. Use arrow functions when you're actually returning something and making use of the result.
 
you are right
 
cmb
@Shafizadeh php.net/manual/en/functions.arrow.php should explain it all
 
yeah already found it ;-)
 
hmm.. wanted to make a bad joke about using fn() => (function() { echo "test"; })(); instead.. but that doesn't seem to work?
 
I've actually used arrow functions yesterday for the first time for actual production code :D We're very quick with upgrading xD We actually still have some code running on 5.3 but I'm sure somebody has me beat on this.
@makadev 3v4l.org/WWLN3 there you go :D
Such elegance
 
10:34 AM
@IluTov ahhh.. 2 functions, 2 calls.. maybe I should drink a bit more coffee..
 
10:49 AM
that reminds me.. is there a way to typehint the function signature for anonymous functions? Like f.e. expecting that IntArray::visit(callable $visitor) gets a visitor function which has the signature function(int $item, int $index): int|false?
 
@makadev Not natively, Psalm and PHPStan can do that though. psalm.dev/r/8f6f582944
 
@IluTov Thanks, that should be sufficient for my purpose (since it's only used internally and I have both psalm/phpstan testing).
 
11:14 AM
morns
 
@IluTov pretty :D
@mega6382 YO!
 
yo
 
11:35 AM
Mornigns o/
 
\o Good nooning.
 
12:03 PM
Happy Friday
 
12:21 PM
moin
 
12:53 PM
o/
 
Wes
what would require to have the debugger to treat e.g. $a = $b ? $c : $d; as separate lines? in particular in code coverage. if i hit $c, there's no way for me to know i've never hit $d, since code coverage is per line rather than per code path
 
1:20 PM
\o
 
Conflicts of parameter names and variadics ・ Scripting Engine problem ・ #80327
 
Hi guys. I have worked on compression (conversion to jpg) and watermarking the image in uploading an image to the server.
Can I know how can I upload multiple images into server and store their name in database?
Any articles available to learn?
I came across some articles online. They show only uploading images not storing their names in database. I need to store 3 images in 3 different columns. According to the user input it could vary. For example, if user has inserted 2 only two columns must be filled
 
1:39 PM
@Wes not using a ternary, afaik is the only way
idk if @Derick can elaborate/contradict me on that
 
Wes
@DaveRandom but that's what peehaa would say
 
he does get things right occasionally tbf
 
cmb
IIRC, Xdebug now supports path coverage
 
You want branch coverage, not line coverage.
 
Dave's right. It's a single statement. But if the operands are functions, you can always step-in
@cmb Yes, it can do that - but for debugging it only halts at EXT_STMT (see 3v4l's VLD outout)
xdebug 2.9 does support path/branch coverage, and Phpunit also now supports that
 
cmb
1:42 PM
Ah, thanks! But I think it was more about code coverage analysis.
 
I wonder if formatting it differently helps at all:
$a = $b
  ? $c
  : $d;
It looks dumb for such small expressions, yes, but this is how I end up formatting multi-line ones.
 
I believe it's still one STMT, but as long as PHP generates the code on the right lines, it should work
(for code coverage)
looks like at least 7.4.2 handles that
walk time now
 
Eventually, I couldn't understand what word "dump" mean. Sometimes means "export", sometimes means "show or print", sometimes means "garbage" ..!
 
it means "to remove something in it's entirety" and it has an implied air of carelessness
 
ahh
 
1:51 PM
like to "dump" a bin out is to just turn it upside down and shake it, instead of picking things out of it carefully
 
I see
 
"the dump" being a place where rubbish is taken is an extension of that meaning and a little colloquial I guess
certainly I regard it as an americanism
but it certainly makes sense with var_dump(), "show me everything inside this var"
 
what about mysqldump
 
yeh, that's for extracting all the data from mysql
mysql is "dumping" out its data
that stupid apostrophe exception with possessive "its" I hate it so much
 
ah :-)
I guess sometimes it means "vague" .. take a look at Levi's sentence
> It looks dumb for such small expressions
 
cmb
1:58 PM
dumb vs dump
 
OHh .. that's what made me misunderstood .. thanks cmb
 
PhpToken::getAll() confusing name ・ SPL related ・ #80328
 
... SPL?
 
2:29 PM
May 13 at 13:15, by Danack
@StatikStasis Thanks. When I ragequit the PHP project, I will go through the chat log of this room and find who it was who said the problem that PHP internals has it "not enough community involvement" and take the piss out of them until I get kicked.
 
I am so confused.
 
@Crell that's probably either just a missclick, or they equate "Standard PHP Library" with "stuff that ships in PHP's core library".
 
cmb
ext/tokenizer is lacking a "package" entry on bugsnet /cc @Derick
 
2:53 PM
Hi guys
Anyone to perhaps assist with a Laravel struggle?
I would like to create files outside the public directory but I don't know how to change this default behaviour of the framework.

When I hit my test URL, the files are added to the public directory. However, I want it outside the public directory.

Route::get('test', function(){

$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$file2 = fopen("another.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
 
That is unrelated to Laravel
You are not specifying the path to write to meaning it will write to the current working dir
 
@PeeHaa I first had this:
$myfile = fopen("app/newfile.txt", "w") or die("Unable to open file!");

The intention was to save the file inside the app directory.
How would that work?
 
@PeeHaa when convenient, could you chuck some examples of your use-case in a gist please?
need some examples for a thing....
 
@useragent laravel typical uses storage/ path for files f.e. with storage_path("newfile.txt).. but if you want to put stuff in your app path you can probably use app_path helper like fopen(app_path("app/newfile.txt"), "w")
 
@LeviMorrison Just like that. Preceding operator (or any special sign) clearly announces that line has something with line above.
 
3:01 PM
* fopen(app_path("newfile.txt"), "w")
 
Top level always having an anon function where I need to capture all params
 
thanks - do you have anything less Promise-y though? they confuse people (me).
 
Last week I had a good one using array_map I think in one of the projects
Will try to find it
 
@PeeHaa I figured it based on your comment :)
Am using base_path helper
Thanks for the comment
 
np
 
3:26 PM
Another typehint question: Is it possible to typehint a class constant?
 
If it is a constant why does it need to be passed into something?
 
> typehint
 
@PeeHaa Hrmm.. the specific Problem is actually psalm like psalm.dev/r/89fed4491e it doesn't recognize the this constant is always int
my alternative was either typecasting or using a typed helper variable.. but both introduce bloat (which most likely is optimized out by opcache.. but still)
 
Or just ignore it if the tool is not working
 
int * int can result in a float....
also, you can just say type, not typehint.
 
3:42 PM
typewhiff
 
@Danack doesn't seem to matter for psalm: psalm.dev/r/aadb9e4674
 
it doesn't run the code
 
ye
 
It just knows that the operation can result in a float
 
it seems more like PHP_SIZE_INT is somehow seen as mixed
 
3:46 PM
Doesn't pslam have an ignore annotation/config?
If a tool doesn't work for you, don't rewrite your working and correct code for it
 
tool-oriented design
 
^ that
 
Yeah but PHP_SIZE_INT should be small...
 
something something type checking is a subset of a halting problem...
 
4:04 PM
@Danack ?
 
4:15 PM
Ah.. static type checking of dynamic languages.. makes sense. But my idea was more to use the hammer approach and set the type like const X = (int)(PHP_INT_SIZE*8) with a runtime check.
 
28 mins ago, by DaveRandom
tool-oriented design
 
but PeeHaa has probably the best approach for that.. config/annotation and suppress
 
Levi was saying that te result of PHP_SIZE_INT * 8 obviously fits within an int. Which is true, but there are limits of what tools can do, en.wikipedia.org/wiki/… and even before then, there are limits on what tools can usefully do.
 
@Danack that was one of my approaches but sadly no valid PHP: 3v4l.org/3HLQe
config/annotation it is!
 
4:28 PM
guys there is a term: "product led growth"
any idea what's the full word of "led"? is it a short? abbreviation?
 
@Danack idgaf if they prefer southern fired chicken, I'm not dressing up and that's the end of it.
@Shafizadeh it's the past tense of "lead"
as in "to lead a horse to water"
 
ow right .. thanks Dave
 
Add option to specify LOAD DATA LOCAL white list folder (including libmysql) ・ mysql ・ #80329
 
in fact @Shafizadeh the phrase "product-driven growth" is synonymous, and might make more sense to you
 
4:31 PM
@Jeeves enterprise like typing detected
 
@DaveRandom Yeah, More meaningful
 
also what kind of bullshit salesy garbage are you reading/writing @Shafizadeh?? :-P
that's the sort of phrase that appears with other marketing garbage like "synergise"
 
there is a festival I'm trying to buy a ticket for
https://festival.productledalliance.com/
 
yep, looks like marketing to me :-P
/kills self
 
yeah, not technical whatsoever
It's about 2 years I have become a product owner
so, I'm following such things
noted that I will get back to tech as soon as possible .. I'm understanding product/marketing/business jobs are awful
 
4:35 PM
sure, I'm not saying they don't have value, things like that
but I am saying that I would rather set myself on fire than attend one
:-P
 
I just remembered that that match is a thing now and as single expression I can (ab)use it to make short closures that aren't so short :-P
static fn(?\Throwable $exception, mixed $value) => match ($exception) {
    null => $continuation->resume($value),
    default => $continuation->throw($exception),
}
 
3 mins ago, by DaveRandom
/kills self
 
@DaveRandom Oh come on now, you like it, you know you do.
 
yeh I actually do
and I will totally be doing that
it actually reads perfectly obviously I think
 
4:39 PM
Yeah, I think that's an elegant use. That could so be abused though :-D
 
what would be really nice would be if you could have different branches for different exception types
so it's kind of like a cheap(er) try/catch
in particular I'm thinking for stuff like cancellations and timeouts where you may have special handling internally for those exceptional events
 
static fn(?\Throwable $exception, mixed $value) => match (true) {
        $exception instanceof \Error => $continuation->throw($exception),
        $exception instanceof \Exception => $continuation->throw(new \Error("Wee!", 0, $exception)),
        default => $continuation->resume($value),
    }
 
btw, do you know any platform to make me (from Iran) able to accept a remote project?
 
I guess that's not too bad
 
4:42 PM
@DaveRandom Eh… that's getting kind of abusive.
 
yeh I always worry about switch (true), although again it has been known
 
There is a note in the RFC about match without a condition being the same as match (true).
 
readable use cases are few and far between
 
Not sure I'm a fan of that though.
@DaveRandom Exactly.
 
@DaveRandom has been kicked
 
4:43 PM
and because of that it's probably best avoided all together, if your brain isn't used to groking it frequently it won't buy you anything
 
@Trowski that looks dangerously like rust
I love it
 
@Shafizadeh sorry, no
it's probably about the least convenient place on earth to be a developer rn, with the possible exception of north korea
sorry :-/
 
Replace language in APIs and source code/docs ・ mysql ・ #80330
 
@Trowski well, I can't read it. I always break stuff like that up into separate lines:
$exceptionFn = static fn(?\Throwable $exception, mixed $value) => match ($exception) {
  null => $continuation->resume($value),
  default => $continuation->throw($exception),
};

$suspendFn = static fn(\Continuation $continuation) => $promise->onResolve($exceptionFn);

return \Fiber::suspend($suspendFn, Loop::get());
 
5:01 PM
@Trowski Another reason I'm proposing short named functions, too. :-)
 
@Danack Yeah, that's probably better. Deeply nested is always harder to grok.
Ooo… except that doesn't work because $continuation isn't defined yet.
It has to be nested, even with regular closures.
 
yeah, and not just for reading what it's doing, but PRs that affect a bit of it, and when stepping through a debugger.
 
@Derick You know there's 7 minutes of dead air at the end of episode 69, right?
 
nice
 
5:21 PM
@Crell that's when the 69 was happening
 
You know, we made it all the way through the episode without making that joke. You had to go and ruin it.
 
s/ruin/save/
 
🙄
@DaveRandom actually just read through some code earlier that did switch (true) and had kind of a "wat" reaction. The code worked, I think, but never encountered it before and don't understand the reasoning behind it without asking the dev who did it.
Which will have to wait until Monday when I have a working internet connection
 
it's just a different way of writing an elseif tree
 
I suppose that's cleaner....ish
 
5:31 PM
it's 100% equivalent to if ($case1) {} elseif ($case2) {} else { /* default case */ }
 
cmb
a terrible way IMHO
 
@Tiffany rarely, but occasionally
very occasionally
 
Yeah, the instance I encountered, it would probably be uglier with if/elseif chains. Though it does make the next dev reading it do a double-take.
 
5:55 PM
Use match(true) and make each branch body a function call. :-)
 
6:13 PM
lol
you are such a charmer @PeeHaa
 
<3
How's you doing @FélixGagnon-Grenier?
 
6:39 PM
@PeeHaa quite busy with moving
and, work
 
Moving where?
 
some city a few hours from where I was ! I bought me a house :D
 
\o/
That's awesome!
 
It is \o/
and what about you @PeeHaa
 
Ekin and I have a daughter! :P
 
6:49 PM
No-one has told him there's a wolf in his house yet, so it hasn't eaten him yet. Keep it under your hat.
 
It's been trying to eat me every morning
 
I wake up with a licking girl on my face
 
ugh, so many jokes, none of which are acceptable
 
And when did that ever stop you?
 
6:52 PM
when I haven't had enough to drink yet
 
/me looks at clock
?
 
user image
3
 
@PeeHaa "yet"
 
/me looks at clock again
 
@Trowski er, turns out that still has a slight bug in it:
function convert_file_to_docuwiki(string $file)
{
  // TODO
}
 
6:57 PM
@Danack Good timing, I was just about to commit and update to the RFC.
Would you like to be added to the author list?
 
As gandalf
 
@PeeHaa drinking complicated (i.e. expensive) beer that needs time
 
It's got a typo on the can though
London "beer" factory
 
@PeeHaa "The bearded one"
 
Or is it actually not entirely terrible
 
6:59 PM
@DaveRandom Never been an IPA fan.
 
Heh, the editor of 3v4l is not compatible with PHP 8 syntax. Throws an error at line 8
https://3v4l.org/CWjbr
 
PhpStorm currently throws a fit too.
Along with the nullsafe operator.
 
by nullsafe operator you mean <=> ? if so, AFAIK it would be called "spaceship"
 
ah, right
 
7:11 PM
@Trowski Works fine in the EAP :)
 
The only EAP I know is "Extensible Authentication Protocol" that hardly think you mean that. So, what you mean by that?
 
Change in error level not listed in Migration guide ・ Documentation problem ・ #80331
 
early access program
 
7:38 PM
@Danack Results seem consistent, not sure what you’re on about.
 
@Crell I was just reading through your draft enum RFC, and my initial reaction is "me wants" 🙃
one thought I had in case I forget to mention it during later discussion, is that the match type construct (or however it ends up spelled) is a useful feature in its own right
 
I would agree.
Although we're still not sure if that's the way to go for enum match.
 
exceptions are my go-to example: if you're catching them, you can have a series of catch clauses that perform instanceof checks, but if you're trying to share logic, e.g. logging, it's really annoying
it fits nicely with some other parts of the proposal, IMHO: having cases pass instanceof checks, available as type constraints, etc
and if ( $maybeResult instanceOf Maybe::None ) { ... } seems like a reasonable way of avoiding dozens of new pattern matching features
anyway, I'm really hoping enums make it into the language in something like this form, best of luck to you both :)
 
7:58 PM
@Danack Beautiful.
 
how can i ask a question if i dont know how to ask a question and someone closes my question for lack of clarity--if i knew how to ask the question i prob would know the answewr
 
I see a slim routine without any tech debt.
 
@IMSoP That's my thinking; if we can have a match variant that does instanceof, and let people sort out extracting bound values on the rhs, then that's probably good enough for the 80% case at least. And lets us not think about pattern matching for now, without actually making it impossible in the future.
 
@ForgivenIT you might pay for a programming course on the subject, where it is someone's job to spend time on teaching you stuff. And yeah.....this is a real limit on how useful StackOverflow can be to someone new to a topic.
Or just say the wrong answer somewhere and provoke people into correcting you....
 
yeah don't think i need to go back to school @danack but thanks for that
 
8:04 PM
@ForgivenIT formulating problems is definitely a tricky skill, but a very valuable one - you're quite right that sometimes by the time you've defined the question you've found the answer, but that's just the process you have to go through sometimes; and that's why software engineering is a highly-skilled (and highly paid) profession
my number one tip, which some day I'll get round to writing up as a blog post, is always Break The Problem Down
 
wow this is why i never chat --I have a masters degree and have been coding for 15 years just having a brain cramp and was reaching out for a bit off help
*of
 
Yeah wow indeed
 
^
 
@Danack That's clever
 
Rubber Ducking is a thing for a reason.
 
8:09 PM
@ForgivenIT then maybe you've fallen into a variant of "Don't Ask to Ask, Just Ask" - what you seemed to be asking for help with was how to frame questions better; if you were actually hoping for help with something else, you'll need to tell us what
 
sorry @ IMSOP i am just a bit frustrated--- so here is my basic question
I am trying to send a list of 20 asin to amazon api in one call-- i have the code to send and recieve the results but where i am struggling to formulate a piece of code is when i select a group of asins that are say 1000 or more from a query. Then grouping them into sets of 20 to send to amazon then returning the results finishing, then doing the next 20 and so on and so forth til all 1000 are done
 
Is the question coming? :-)
 
while ($rows = $results->fetch_assoc()) {
$asin = $rows['asin'];
$conn->query("UPDATE masterguide25ManFinal SET amazonPrice = '$amzAvg', Title='$title' WHERE asin='$asin'");
$returnResults[$n]= array('payPrice' => number_format((float)$amzAvg, 2, '.', '' ),
'asin' => $asin,
'sales rank' =>$rank,

);
$n++;

}
lots of code in between that is not need for this question--but basically in the while loop instead of sending it to amazon one at a time for up to 30000 asin i can send 20 at a time but i don't want to make the query return 20 results at a time so i was thinking there was something simple that was blocked in my brain to accomplish this
 
OK, so let's Break The Problem Down ™😉 - we have a source of data (which happens to be a database, but that's not relevant to the problem); we have a process that requires batches of data (which happens to be an Amazon API, but that's not relevant to the problem); and we have something that needs to know the result of that batch process (which happens to be a database update, but, again, not relevant to the problem)
 
correct--normally not an issue the sticker is the 20 at a time inside the while loop without having to exist the while loop
 
8:18 PM
> yeah don't think i need to go back to school
everyone always needs more school....
 
@PeeHaa 😍
@PeeHaa that'll keep you on your toes
 
I need to go back and learn all the stuff these kids keep making up. wtf is a 'promise'.
 
sorry @ Danack i am just being pissy because i should be able to do this and i have stuck all day and i thought i asked a pretty straight forward question and got taken down
 
@Trowski cool, what's your eta for getting feedback on the api from the other projects, and asking ms how he wants to be credited?
 
@Danack tbf nobody really knows, is it the best thing ever? the worst nightmare?
 
8:22 PM
so, to frame the question better, discard all the parts that are details of your specific task, and look at it as an algorithm question:
foreach ( $someSource as $nextItem ) {
    #TODO: Somehow add $nextItem to $batch until we have 20
    $result = someAction($batch);
    saveResult($result);
}
 
@Danack No eta as of the moment. I wonder if any of the React people come in here anymore.
 
brilliant thanks, i actually dont need to ask the question now --all i need was that to get me unstuck
@IMSoP
 
another victory for breaking the problem down :)
 
i am using that next time some ask me a question --i will give you credit though
wow cant type time to go to bed
 
@IMSoP after you write that post, what is your strategy going to be for how to get people to read it, before they discover that asking questions is hard, and a thing that needs to be practiced?
 
8:26 PM
oh, I just fancy having a link I can throw at people; whether they read it and learn how to apply it is up to them
but I do think it's a good general philosophy - it's why structuring programs is so important
if you can pull out functions so that your algorithms are literally as simple as that sample (but with better names) it becomes easier to "see the wood for the trees" as it were
@ForgivenIT sleep is also a good aid to debugging ;) have a good night
@Danack I just read Trowski's Fiber RFC draft; I think it gave my brain a full-stack suspension ;)
 
yeah.......probably needs an even more simple introduction.....there is a plan to have a direct link to better example, so at least people can see it in action.
 
yeah, I think I can see why they're a useful concept, but the interaction between the parts is very confusing
 
8:44 PM
2 days ago, by Danack
I mean explain it in a way that someone who is only just about aware of what 'pure' even means, can see that code that is not pure is bad.
s/pure/non-blocking io/
or continuations...
 
huh?
 
IMSop was saying the words for the fibre idea have the same problem I was pointing out....that if someone doesn't already understand the tech, the RFC doesn't really explain it.
> Three more languages that don’t have this problem: Go, Lua, and Ruby.

Any guess what they have in common?

Threads. Or, more precisely: multiple independent callstacks that can be switched between. It isn’t strictly necessary for them to be operating system threads. Goroutines in Go, coroutines in Lua, and fibers in Ruby are perfectly adequate.
@Trowski would it be okay to say that PHP could be added to that list if the RFC passed, or would there still be things not as good about PHP fibres, compared to goroutines?
 
@FélixGagnon-Grenier hey gratz \o/
 
8:59 PM
@Danack Yes, PHP would be added to that list. Goroutines are a bit different in that they interleave instructions, what I've implemented is more similar to fibers in lua and ruby.
I thought goroutines launched threads.
 
Which is something that can be implemented on top of this Fiber API and a little magic. See amphp/parallel v2 branch.
@IMSoP @Danack Some examples of promise-based async vs. fiber-based async is probably in order.
 
Wait so a Fiber is "just" a thread?
 
no
 
Then I don't get it :(
 
9:11 PM
The way they are uhhmmm paused? thinking of a better word right now is different
interrupted is what I am looking for
Did I use the correct big word here @Trowski? :)
 
9:26 PM
Threads imply multiple active program counters executing stuff in parallel. Concurrency is code structured such that two parts could be executed in parallel because they're independent of each other.
Go may run multiple go routines at the same time on different threads, or not, depending on what the VM decides is best.
 
Is there a doc snippet for a function that returns true or null on failure?
 
/** This function is broken and should not be used. */
 
Well, sure we could deprecate mysqli and the problem would be gone, but instead of pointing this out every time I ask a question here you could try to help. I really am trying to do the best I can with what is a burning pile of garbage that is mysqli
I assume there is no point in adding such snippet so should I just write it out by hand?
 
As in, a stock set of text to explain "returns true on success, null on failure"? I don't know of one. It sounds simple enough that it's not worth making a snippet for it.
 
The function actually only ever returns SUCCESS, but if you use @ then in case of error it will return null/void
 
9:33 PM
@Girgias they're threads that don't get interupted, but instead promise (ha) to yield execution nicely: en.wikipedia.org/wiki/Fiber_(computer_science)
 
I have no idea why it doesn't just return void...
 
@Dharman Something something must have returned false before
Especially true in PHP 8, where a bunch of functions got their failure state converted to Value/TypeErrors
 
@PeeHaa pre-empted is also a good one...
 
Nah, could have found that by looking at the blame view :p
 
9:38 PM
@PeeHaa Pretty much. Threads are OS-level and do preemptive context switches. Fibers are single-threaded and cooperatively context switch.
 
What's the point in having such return values then? Is this ever useful?
 
The context switch is much less expensive. Something on the order of 10-ish pointers I think (need to verify).
 
@Dharman It is not
A changed a couple which were like that IIRC, but I left usually the ones where I removed the failure condition with a big TODO comment
Probably all these functions should be compiled in a list so that we can change that in a future version
@Danack Huh thanks that was helpful
 
02:00 - 22:0022:00 - 00:00

« first day (3674 days earlier)      last day (1290 days later) »