Bug #60174 [Opn->Ana]: Notice when array in method prototype error
Edit report at https://bugs.php.net/bug.php?id=60174&edit=1
ID: 60174
Updated by: laruence@php.net
Reported by: simon at simon dot geek dot nz
Summary: Notice when array in method prototype error
-Status: Open
+Status: Analyzed
Type: Bug
Package: *General Issues
PHP Version: 5.4SVN-2011-10-30 (SVN)
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2011-10-30 09:24:27] simon at simon dot geek dot nz
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 this bug report at https://bugs.php.net/bug.php?id=60174&edit=1
Thread (3 messages)