__construct is like a normal method but without E_STRICT
| From: | Robert Stoll | Date: | Thu, 26 Sep 2013 21:19:44 +0000 |
| Subject: | __construct is like a normal method but without E_STRICT | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-69358@lists.php.net to get a copy of this message | ||
Heya
I would like to have some opinions on the topic inconsistency between
methods and __construct
See the following code:
class A {
function __construct($a) {}
function foo($a) {}
}
class B extends A {
function __construct($a, $b) {}
function foo($a, $b) {}
}
If you work in strict mode, then you will see the error message
Strict Standards: Declaration of B::foo() should be compatible with
A::foo($a)
I perfectly understand that the strict standard cannot be applied to the
__construct and I would not suggest to change that. But I think it is
somewhat strange that I am able to call __construct as it was a normal
method from everywhere.
Am I the only one thinking this, is there actually someone who is using
__construct as re-initialising method?
Cheers,
Robert