Re: [VOTE] Automatic Property Initialization

From: Date: Sun, 02 Feb 2014 09:31:30 +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
Morning internalz,

Some clarity ...

Johannes: 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;
Assuming you meant to declare Base::__construct abstract: L1946 zend_compile.c:
zend_error(E_COMPILE_ERROR, "Automatic property initialization can not be used in an abstract method");
leading to probably unexpected results ... also
    class C { public function m($foo->prop){}}
L1933 zend_compile.c:
zend_error(E_COMPILE_ERROR, "Property name can only be prefixed by $this->");
Having reviewed the discussion, and played with the patch, I see no genuine objection. Cheers Joe

Thread (34 messages)

« previous php.internals (#71980) next »