#41461 [NEW]: Odd E_STRICT notice raised when using Interfaces

From: Date: Mon, 21 May 2007 23:06:13 +0000
Subject: #41461 [NEW]: Odd E_STRICT notice raised when using Interfaces
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112918@lists.php.net to get a copy of this message
From: ralph at smashlabs dot com Operating system: Linux PHP version: 5.2.2 PHP Bug Type: Class/Object related Bug description: Odd E_STRICT notice raised when using Interfaces Description: ------------ When an interface is a parent of a class, the interface is implying a specific profile for a given function (here its __get) even though it is not defined in the interface itself. This is making it impossible to overload and/or change the profile of the function in a descendant class. Reproduce code: --------------- The following will produce this notice: Strict Standards: Declaration of Z_Concrete::__get() should be compatible with that of Z_Abstract::__get() in xxx on line 16 <?php error_reporting(E_ALL | E_STRICT); interface Z_Interface { } abstract class Z_Abstract implements Z_Interface { public function __get($name) { return; } } class Z_Concrete extends Z_Abstract { public function & __get($name) { return null; } } $t = new Z_Concrete(); This code will not produce a notice: <?php error_reporting(E_ALL | E_STRICT); abstract class Z_Abstract { public function __get($name) { return; } } class Z_Concrete extends Z_Abstract { public function & __get($name) { return null; } } $t = new Z_Concrete(); The only difference is that the former has an interface as a parent, the latter does not. Expected result: ---------------- No E_STRICT notice raised Actual result: -------------- E_STRICT notice raised. -- Edit bug report at http://bugs.php.net/?id=41461&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41461&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41461&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41461&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41461&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41461&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41461&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41461&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41461&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41461&r=support Expected behavior: http://bugs.php.net/fix.php?id=41461&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41461&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41461&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41461&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41461&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41461&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41461&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41461&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41461&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41461&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41461&r=mysqlcfg

« previous php.bugs (#112918) next »