Bug #46851 [Com]: Strict standards: Declaration of ... should be compatible with that of ...
| From: | travis dot crowder at spechal dot com | Date: | Fri, 28 May 2010 15:24:50 +0000 |
| Subject: | Bug #46851 [Com]: Strict standards: Declaration of ... should be compatible with that of ... | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-150913@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=46851&edit=1
ID: 46851
Comment by: travis dot crowder at spechal dot com
Reported by: oliver at teqneers dot de
Summary: Strict standards: Declaration of ... should be
compatible with that of ...
Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: OpenSuSE 11.0
PHP Version: 5.2.8
New Comment:
Still an issue in 5.2.10
<?php
error_reporting(E_ALL | E_STRICT);
abstract class B extends A {
public static function foo($str){ echo $str; }
}
class C extends A {
public static function foo(){ echo 'baz'; }
}
abstract class A {
public static function foo(){ echo 'bar'; }
}
C::foo();
Error:
Strict Standards: Declaration of B::foo() should be compatible with that
of A::foo() in /var/www/oop_test.php on line 5
Previous Comments:
------------------------------------------------------------------------
[2008-12-17 11:12:04] bjori@php.net
Set error_reporting in your php.ini and you'll see the error.
------------------------------------------------------------------------
[2008-12-12 16:08:09] oliver at teqneers dot de
Description:
------------
If I turn on E_STRICT, I get a strict notice depending on class
position. The notice is as following:
Strict standards: Declaration of ... should be compatible with that of
...
Maybe this notice is correct, but if I switch the classes in my code
without changing their content, this notice is gone?!?
This is a problem when using autoload, because it might happen, that a
subclass is loaded before the parent class has been parsed.
Reproduce code:
---------------
<?php
// this code does trigger a strict message
error_reporting( E_ALL | E_STRICT );
class cc extends c {
function test() { return null; }
}
class c {
function test( $a ) { return 1; }
}
$cc = new cc();
?>
<?php
// this code does NOT trigger a strict message
error_reporting( E_ALL | E_STRICT );
class c {
function test( $a ) { return 1; }
}
class cc extends c {
function test() { return null; }
}
$cc = new cc();
?>
Expected result:
----------------
None of the code blocks should trigger an error (my personal preference)
or both code blocks must trigger a notice.
Actual result:
--------------
First block triggers:
Strict standards: Declaration of cc::test() should be compatible with
that of c::test() in strict_test.php on line 4
Second does nothing at all.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=46851&edit=1