#50897 [Opn]: Require() problem with E_STRICT
| From: | jani@php.net | Date: | Mon, 01 Feb 2010 12:21:08 +0000 |
| Subject: | #50897 [Opn]: Require() problem with E_STRICT | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-147093@lists.php.net to get a copy of this message | ||
ID: 50897
Updated by: jani@php.net
Reported By: frederic dot hardy at mageekbox dot net
Status: Open
Bug Type: Scripting Engine problem
Operating System: *
PHP Version: 5.*, 6
New Comment:
And the notice should be output in all cases..
Previous Comments:
------------------------------------------------------------------------
[2010-02-01 12:19:49] jani@php.net
Yes, but the order should not matter, that was my point. :)
------------------------------------------------------------------------
[2010-02-01 12:08:42] mvalleton at sauf dot ca
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();
?>
------------------------------------------------------------------------
[2010-02-01 11:59:52] jani@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