ID: 50897 Comment by: mvalleton at sauf dot ca Reported By: frederic dot hardy at mageekbox dot net Status: Open Bug Type: Scripting Engine problem Operating System: * PHP Version: 5.*, 6 New Comment:
The problem isn't related with the order in which you declare classes a and b: The warning appears when classes a and b are declared in the *correct* order, but in a different file, and then required by the main script. Here is a simple example: http://ssz.fr/brdl/php-bug-50897.tbz2 classes.php: <?php class a {public function test($foo) {}} class b extends a {public function test($foo, $bar) {}} ?> script.php: <?php error_reporting(E_STRICT); require "classes.php"; $b = new b(); ?> Previous Comments: ------------------------------------------------------------------------ [2010-02-01 11:59:52] j...@php.net Not sure what's going on here, but this is the difference eventually: No E_STRICT notice: <?php error_reporting(E_STRICT); class a{function test($foo){}} class b extends a{function test($foo, $bar){}} $b = new b(); ?> E_STRICT notice <?php error_reporting(E_STRICT); class b extends a{function test($foo, $bar){}} class a{function test($foo){}} $b = new b(); ?> ------------------------------------------------------------------------ [2010-02-01 10:30:33] frederic dot hardy at mageekbox dot net the "b" class must extends the "a" class, all my apologize. ------------------------------------------------------------------------ [2010-02-01 10:20:08] frederic dot hardy at mageekbox dot net Description: ------------ Require() and include() are more strict than a all in one file then parse php code. Reproduce code: --------------- file a.php <?php class a { public function test($fool) {} } ?> file b.php <?php class b { public function test($foo, $bar) {} } ?> file withRequire.php <?php error_reporting(E_STRICT); require('a.php'); require('b.php'); $b = new b(); ?> file allInOne.php <?php error_reporting(E_STRICT); class a { public function test($foo) {} } class b [ public function test($foo, $bar) {} } $b = new b(); ?> Expected result: ---------------- In CLI, "php withRequire.php" must give same result than php "allInOne.php". Actual result: -------------- php allInOne.php => nothing php withRequire.php => Strict standards: Declaration of b::test() should be compatible with that of a::test() in /path/to/b.php on line 8 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50897&edit=1