From: Operating system: PHP version: 5.4SVN-2011-10-30 (SVN) Package: *General Issues Bug Type: Bug Bug description:Notice when array in method prototype error
Description: ------------ If a class redefines a method of a superclass and does not match the method signature and the original signature contains an array, a notice about array to string conversion is also raised. The notice is raised on either the first line of the subclass (class blah extends blah) or on the line containing the closing } for the class. This seems to be caused by: zend_error(E_STRICT, "Declaration of %s::%s() should be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, method_prototype); in Zend/zend_compile.c (line 3232 as at revision 318576). If the notice is an expected result, I would expect it to occur on the line of the function prototype rather than the class opening or closing line, though I do not expect that notice at all as it appears to be more of PHP bug rather than an implementation problem. The notice also appears if the error reporting level does not contain E_STRICT but a custom error handler is loaded. If there's no custom error handler and the reporting level does not contain E_STRICT, then the E_NOTICE is not displayed. Test script: --------------- <?php class A { public static function test($arg = array()) { } } class B extends A { public static function test() { } } Expected result: ---------------- Strict Standards: Declaration of B::test() should be compatible with A::test($arg = Array) in /Users/simon/Sites/test.php on line 11 Actual result: -------------- Notice: Array to string conversion in /Users/simon/Sites/test.php on line 11 Strict Standards: Declaration of B::test() should be compatible with A::test($arg = Array) in /Users/simon/Sites/test.php on line 11 -- Edit bug report at https://bugs.php.net/bug.php?id=60174&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60174&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60174&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60174&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60174&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60174&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60174&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60174&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60174&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60174&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60174&r=support Expected behavior: https://bugs.php.net/fix.php?id=60174&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60174&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60174&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60174&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60174&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60174&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60174&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60174&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60174&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60174&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60174&r=mysqlcfg