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

 

 

 

Reply via email to