Re: [VOTE] Automatic Property Initialization
On Fri, 2014-01-31 at 23:48 +0000, Dan Ackroyd wrote:
> 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.
Right. Still one should be aware of this and might be worth adding to
RFC. "Correct" usage would of course be be passing parameters through
explicitly.
> 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.
As said - just had a quick look and didn't think much. if those are
triggered during compilation (which would be obvious as only the
compiler is changed ...) then its fine.
Thanks for reviewing!
johannes
Thread (34 messages)