Why doesn't PHP Strict Standards complain about difference in constructor arguments? -



Why doesn't PHP Strict Standards complain about difference in constructor arguments? -

normally when kid class has different function arguments parent, php strict standards lets know:

strict standards: declaration of boele::bla() should compatible oele::bla($one, exception $two) in foo.php

it doesn't break anything, lets know it's not cool. agree.

however, constructors seem special treatment:

class="lang-php prettyprint-override">class oele { function __construct($one, exception $two) {} function bla($one, exception $two) {} } class boele extends oele { function __construct(exception $two) {} function bla(exception $two) {} }

the __construct() , bla() methods both different in parent , child, yet php notifies bla(), not __construct().

proof on 3v4l

why?? isn't as 'bad' constructors?

(i'm running php 5.5.17 here, can see on 3v4l works same php 5.)

i can not explain why there info in php documentation this:

unlike other methods, php not generate e_strict level error message when __construct() overridden different parameters parent __construct() method has.

source: http://php.net/manual/en/language.oop5.decon.php

php constructor strict

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -