php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: simon at simon dot geek dot nz
New email:
PHP Version: OS:

 

 [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 commitsRelated reports
 [2011-10-30 11:53 UTC] laruence@php.net
-Status: Open +Status: Analyzed
 [2011-10-31 03:46 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2011-10-31 03:47 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=318599
Log: Fixed bug #60174 (Notice when array in method prototype error)
this should also exists in ext/reflection. since the new warning of &quot;array to string convert&quot; is introduced in zend_make_printable_zval which is used in ext/reflection too
 [2011-10-31 03:56 UTC] laruence@php.net
-Status: Analyzed +Status: Closed
 [2011-10-31 03:56 UTC] laruence@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2011-10-31 06:04 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=318600
Log: Test for #60174 (Notice when array in method prototype error)
 [2012-04-18 09:48 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=725af4c2dd2edb2986041a3b8decb509b66eeabb
Log: Fixed bug #60174 (Notice when array in method prototype error) this should also exists in ext/reflection. since the new warning of &quot;array to string convert&quot; is introduced in zend_make_printable_zval which is used in ext/reflection too
 [2012-07-24 23:39 UTC] rasmus@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=725af4c2dd2edb2986041a3b8decb509b66eeabb
Log: Fixed bug #60174 (Notice when array in method prototype error) this should also exists in ext/reflection. since the new warning of &quot;array to string convert&quot; is introduced in zend_make_printable_zval which is used in ext/reflection too
 [2013-11-17 09:35 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=725af4c2dd2edb2986041a3b8decb509b66eeabb
Log: Fixed bug #60174 (Notice when array in method prototype error) this should also exists in ext/reflection. since the new warning of &quot;array to string convert&quot; is introduced in zend_make_printable_zval which is used in ext/reflection too
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC