# No inheritance check in constructor ?

- Thread: https://externals.io/message/55981
- Original archive: https://news-web.php.net/php.internals/55981
- Started by jeanseb@au-fil-du.net on 2011-10-28T15:22:53+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #55981 — jeanseb@au-fil-du.net — 2011-10-28T15:22:53+00:00

URL: https://externals.io/message/55981#55981

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

---

## #55983 — jeanseb@au-fil-du.net — 2011-10-28T15:33:34+00:00

URL: https://externals.io/message/55981#55983 · In reply to: #55981

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 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

-- 
Jean-Sébastien H.
au-fil-du.net

---

## #55984 — Ralph Schindler — 2011-10-28T15:51:50+00:00

URL: https://externals.io/message/55981#55984 · In reply to: #55983

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 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:
> > […]
