Notice when array in method prototype error
| Bug #60174 | Notice when array in method prototype error | ||||
|---|---|---|---|---|---|
| Submitted: | 2011-10-30 09:24 UTC | Modified: | 2011-10-31 03:56 UTC | ||
| From: | simon at simon dot geek dot nz | Assigned: | laruence (profile) | ||
| Status: | Closed | Package: | *General Issues | ||
| PHP Version: | 5.4SVN-2011-10-30 (SVN) | OS: | |||
| Private report: | No | CVE-ID: | None | ||
[2011-10-30 09:24 UTC] 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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits