Re: [VOTE] Automatic Property Initialization

From: Date: Fri, 31 Jan 2014 23:48:09 +0000
Subject: Re: [VOTE] Automatic Property Initialization
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi Johannes,

Johannes wrote:
> from a quick look at it there seems to be a design flaw
> around inheritance with code like this:

That example is equivalent to calling the parent constuctor like this:

class Base {
    public $p;

    function __construct($this->p = 42);
}

Class E extends Base {
    function __construct($value) {
        $this->p = $value;
        parent::__construct();
    }
}

So yes - you need will still need to pass parameters to a parent
constructor that requires them, but that is the same as the current
situation.


Johannes wrote:
> also
>   class C { public function m($foo->prop){}}
> becomes valid syntax

Nope, it's constructors only. From the patch, the following errors can
be triggered:

"Automatic property initialization can only be used inside a class"
"Automatic property initialization can only be used in a constructor"
"Automatic property initialization can not be used in an abstract method"

If you try to use the syntax outside of a constructor function.

cheers
Dan

On Fri, Jan 31, 2014 at 11:13 PM, Johannes Schlüter
<[email protected]> wrote:
> Hi Pascal,
>
> On Fri, 2014-01-31 at 23:41 +0100, Pascal Chevrel wrote:
>> Out of curiosity I read both the Voting and Release Process RFCs and
>> couldn't find any mention of a rule stating that all votes had to be
>> approved before the first alpha, if I overlooked it, please correct me.
>> Also, If you look at the wikipedia definition of an alpha in, I believe
>> that it is still time to add features:
>
> No, that rule wasn't written down, but the release process came to live
> out of consequence of us pushing things in quite late in the game and I
> fear we run exactly in the same direction, again.
>
>> Also, isn't it to the Release Manager role to make such decisions?
> [...]
>> The document linked is:
>> https://wiki.php.net/todo/php56#timetable
> [...]
>> The RFC was created before the first alpha, the voting phase is now and
>> if the result of the vote is a yes, then it has until mid-March to be
>> included. At least that's how I read it.
>
> Yes, there is no strict rule, but still we're not talking about a small
> change here but a language change (a small language change, but still)
> and I merely wish that this fact is considered by voters. Ideally the
> proposer would have added options for 5.6 and the following version.
>
>
> (Actually I hadn't reviewed the proposal before and from a quick look at
> it there seems to be a design flaw around inheritance with code like
> this:
>    class Base { public $p; function __construct($this->p = 42); }
>    Class E extends Base { function __construct($this->p = 23) { parent::__construct(); }
>    new E;
> leading to probably unexpected results ... also
>    class C { public function m($foo->prop){}}
> becomes valid syntax and leads to (fatal) runtime errors, this might
> even be true for non-class function declarations ... but I haven't
> really checked, I assume voters will)
>
> johannes
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>


Thread (34 messages)

« previous php.internals (#71909) next »