2009/7/2 troels knak-nielsen :
> [snip] ... - I don't remember ever
> seen __construct() called directly.
Its commonly done when extending reflection for example, or to
populate the Exception class constructor when extending it:
code = (integer) $code;
parent::__construct($message);
troels knak-nielsen wrote:
> On Thu, Jul 2, 2009 at 4:47 PM, Edward Z. Yang wrote:
>> Excerpts from troels knak-nielsen's message of Thu Jul 02 10:14:18 -0400
>> 2009:
>>> I would have expected the second call to __construct() to yield an error.
>> Why should it? Especially since this is idiomatic
Excerpts from troels knak-nielsen's message of Thu Jul 02 10:55:48 -0400 2009:
> I understand that. It's not a technical issue - It's more a matter of
> language semantics. Constructors are used for initializing state on an
> object. Basically, this behaviour makes it impossible to implement
> immu
On Thu, Jul 2, 2009 at 4:47 PM, Edward Z. Yang wrote:
> Excerpts from troels knak-nielsen's message of Thu Jul 02 10:14:18 -0400 2009:
>> I would have expected the second call to __construct() to yield an error.
>
> Why should it? Especially since this is idiomatic code:
>
> class A {
> public fun
Excerpts from troels knak-nielsen's message of Thu Jul 02 10:14:18 -0400 2009:
> I would have expected the second call to __construct() to yield an error.
Why should it? Especially since this is idiomatic code:
class A {
public function __construct($a) {
$this->a = $a;
}
}
class B extend
2009/7/2 troels knak-nielsen :
> Has this been discussed before? In that case, was it decided to go
> with this behaviour or is it purely accidental? Are there perhaps some
> implementation issues in preventing the second call to __construct()?
Magic methods can always be called directly because t
I just realised that the following is valid php code:
class Foo {
function __construct() {
echo "constructor called\n";
}
}
$f = new Foo();
$f->__construct();
Output:
constructor called
constructor called
I would have expected the second call to __con