« first day (4974 days earlier)      last day (101 days later) » 

9:40 AM
Hi all,
Can anyone explain to me why we need to use static way to call parent constructor/methods into child constructor/methods?
for example: why can't we use $this->__construct() inside child constructor?
9:56 AM
@Exception Because $this-> would be just calling itself, infinite recursion
10:33 AM
Also, logically, the object doesn't exist yet in the constructor, only when the constructor finishes.
That's a bit odd given that it's fully expected to be able to use $this in it?
11:22 AM
@Derick most probably then it should throw an error? 3v4l.org/UH3ZE
 
2 hours later…
12:58 PM
@MarkR Because you can call it: 3v4l.org/DXQIp
The object is initialized in memory prior to calling the constructor
There is a reason why ReflectionClass::newInstanceWithoutConstructor() exists/works
 
1 hour later…
2:03 PM
@Girgias Yeah that's what my expectation was (my line before), that comment was in relation to Derick saying the object doesn't exist yet
2:19 PM
I said "logically"...
The object hasn't been fully constructed until the constructor finishes.
 
1 hour later…
3:39 PM
@Exception It's not actually static. This part of PHP is not particularly consistent.
It's just scope resolution. Same syntax as static functions, but it's not the same thing.
If I were designing it today, I'd require passing $this. Pointless example, but good enough:
<?php

class Base {}

class Child extends Base {
    function __construct() {
        parent::__construct($this);
    }
}
This would also make some functional programming stuff easier.
But suppose class name Base is changed to BaseParent then you'll have to make changes in the child class as well, right?
@LeviMorrison It probably should also have a $this parameter for the Child::__construct() then, no?
@Exception I mean that's kind of true in general, but parent would work in this case.
And yeah, explicit this parameter would've been nice, because then $obj->foo() would just be syntactic sugar for Clazz::foo($obj), allowing for “extension functions”.
@TimWolla Even if you don't go that far, it's still useful. Map "Foo::method" on a list of "Foo" objects, for example.
$mapped = array_map($foos, Foo::method(...));
Today you have to do this:
$mapped = array_map($foos, fn ($foo) => $foo->method());
3:46 PM
Absolutely.
Of course, if we were redesigning things, I wouldn't require that (...). Just doing Foo::method would work ^_^
This is the sort of useful thing I'd like to see in a PHP++ but due to the BC break, I just can't see it ever happening :/
 
2 hours later…
5:20 PM
I am noodling with ways we could do extension functions. Some conceptual bits that aren't quite resolved yet. :-)
 
3 hours later…
8:45 PM
Already asked on IRC, but is there an RFC for logic inside heredoc, like loops?
Possibly inspired by Vue templates or JSX or such.
@LeviMorrison The foo(...) RFC got merged way too quickly.....
@OlleHärstedt What do you mean?
IIRC it got suggested, implemented and merged right before a new PHP release.
But maybe there were discussions I didn't see.
That was hardly true, I made an entire RFC which failed before that lol
Yeah that is a bit of a drunk take
Oh that's where the notation come from? xD
8:55 PM
Given all the discussion and a declined RFC the predated it, it's an astonishing 44 Yes to 0 No votes.
@OlleHärstedt Do not want turing-complete strings.
@TimWolla This is PHP

« first day (4974 days earlier)      last day (101 days later) »