Hi,
Is it an expected behaviour ?
See attached test file.
---- EXPECTED OUTPUT
Strict Standards: Declaration of ObjChild::method() should be
compatible with that of ObjParent::method() in %s on line 15
Strict standards: Declaration of ObjChild::__construct() should be
compatible with that of ObjParent::__construct() in %s on line 17
---- ACTUAL OUTPUT
Strict Standards: Declaration of ObjChild::method() should be
compatible with that of ObjParent::method() in %s on line 15
---- FAILED
NB :
The real actual output of the phpt is empty. Can we test strict error
with run-tests ?
Regards,
Jean-Sébastien H.
au-fil-du.net
Ok it's a documented behaviour, I should read more carefully.
http://php.net/manual/en/language.oop5.decon.php
Unlike with other methods, PHP will not generate an E_STRICT
level
error message when __construct() is overridden with different parameters
than the parent __construct() method has.
But I think, it's a lack in PHP ?
On Fri, 28 Oct 2011 17:22:53 +0200, Jean-Sébastien H.
jeanseb@au-fil-du.net wrote:
Hi,
Is it an expected behaviour ?
See attached test file.
---- EXPECTED OUTPUT
Strict Standards: Declaration of ObjChild::method() should be
compatible with that of ObjParent::method() in %s on line 15Strict standards: Declaration of ObjChild::__construct() should be
compatible with that of ObjParent::__construct() in %s on line 17
---- ACTUAL OUTPUT
Strict Standards: Declaration of ObjChild::method() should be
compatible with that of ObjParent::method() in %s on line 15---- FAILED
NB :
The real actual output of the phpt is empty. Can we test strict error
with run-tests ?Regards,
Jean-Sébastien H.
au-fil-du.net
--
Jean-Sébastien H.
au-fil-du.net
Hi Jean-Sebastien,
I'd say this is a harder-to-grasp concept and leads to this common
misconception.
Have a look here, particularly at my reply in the comments section:
http://devzone.zend.com/article/15273
In a nutshell, ctors (constructors) are not subject to LSP (liskov sub.
principle) because a type does not yet exist; the type is the product of
the ctor.
-ralph
Ok it's a documented behaviour, I should read more carefully.
http://php.net/manual/en/language.oop5.decon.php
Unlike with other methods, PHP will not generate anE_STRICT
level
error message when __construct() is overridden with different parameters
than the parent __construct() method has.But I think, it's a lack in PHP ?
On Fri, 28 Oct 2011 17:22:53 +0200, Jean-Sébastien H.
jeanseb@au-fil-du.net wrote:Hi,
Is it an expected behaviour ?
See attached test file.
---- EXPECTED OUTPUT
Strict Standards: Declaration of ObjChild::method() should be
compatible with that of ObjParent::method() in %s on line 15Strict standards: Declaration of ObjChild::__construct() should be
compatible with that of ObjParent::__construct() in %s on line 17
---- ACTUAL OUTPUT
Strict Standards: Declaration of ObjChild::method() should be
compatible with that of ObjParent::method() in %s on line 15---- FAILED
NB :
The real actual output of the phpt is empty. Can we test strict error
with run-tests ?Regards,
Jean-Sébastien H.
au-fil-du.net