Bug #69537 [Fbk->Opn]: __debugInfo with empty string for key gives error

From: Date: Tue, 28 Apr 2015 12:43:01 +0000
Subject: Bug #69537 [Fbk->Opn]: __debugInfo with empty string for key gives error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192375@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69537&edit=1

 ID:                 69537
 Updated by:         danack@php.net
 Reported by:        danack@php.net
 Summary:            __debugInfo with empty string for key gives error
-Status:             Feedback
+Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   N/A
 PHP Version:        5.6.8
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2015-04-28 12:35:20] danack@php.net

Hi Laruence,

Sorry, I don't understand what you mean. The tests don't cover the case when the key is
empty.

The issue also doesn't manifest when the empty key isn't the first element i.e. this:

<?php 

class A{
    function __debugInfo(){
        return [
            
            "foo" => 'bar',
            '' => 'bar',
        ];
    }
}


print_r(new A);

?>

works fine.

------------------------------------------------------------------------
[2015-04-28 02:42:56] laruence@php.net

or at least a expected side affect

------------------------------------------------------------------------
[2015-04-28 02:42:34] laruence@php.net

I have to say it's expected behavior

see: https://github.com/laruence/php-src/blob/master/Zend/tests/debug_info.phpt

------------------------------------------------------------------------
[2015-04-27 17:02:24] danack@php.net

Description:
------------
Returning debug info through the function __debugInfo with an empty key as the key for the first
element gives a warning message "Notice: Illegal member variable name in /in/0raS3 on line
10"

Test script:
---------------
<?php

class A{
    function __debugInfo(){
        return ['' => 1];
    }
}


print_r(new A);

Expected result:
----------------
A Object
(
    [] => 1
)

Actual result:
--------------
A Object
(
    [
Notice: Illegal member variable name in /in/0raS3 on line 10
] => 1
)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69537&edit=1


Thread (12 messages)

« previous php.bugs (#192375) next »