Bug #69017 [Com]: Fail to push to the empty array with the constant value defined in class scope
| From: | reeze@php.net | Date: | Thu, 12 Feb 2015 00:49:14 +0000 |
| Subject: | Bug #69017 [Com]: Fail to push to the empty array with the constant value defined in class scope | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-190599@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69017&edit=1
ID: 69017
Comment by: reeze@php.net
Reported by: n-hatano at infiniteloop dot co dot jp
Summary: Fail to push to the empty array with the constant
value defined in class scope
Status: Verified
Type: Bug
Package: Scripting Engine problem
Operating System: any
PHP Version: 5.4.37
Assigned To: reeze
Block user comment: N
Private report: N
New Comment:
This patch should be able to fix the bug: https://github.com/php/php-src/pull/1077
Previous Comments:
------------------------------------------------------------------------
[2015-02-10 02:26:34] yohgaki@php.net
Correction. It should be execution time.
------------------------------------------------------------------------
[2015-02-10 02:24:14] yohgaki@php.net
It seems $a2 initialization is broken at compile time.
------------------------------------------------------------------------
[2015-02-10 01:53:58] yohgaki@php.net
http://3v4l.org/m4eiS
------------------------------------------------------------------------
[2015-02-10 00:32:56] n-hatano at infiniteloop dot co dot jp
It seems this bug must be seen on any os.
------------------------------------------------------------------------
[2015-02-09 07:35:31] n-hatano at infiniteloop dot co dot jp
Description:
------------
Failed to push to the empty array with the constant value zero defined in class scope.
We were able to push any value using empty square bracket to the array which has initialized in
class definition.
However, if we use the php 5.4.34 - 5.4.37, 5.5.18 - 5.5.21,
the following message has returned and the php fails to push the value.
"Warning: Cannot add element to the array as the next element is already occupied in"
Test script:
---------------
<?php
class c1
{
const ZERO = 0;
const ONE = 1;
public static $a1 = array(self::ONE => 'one');
public static $a2 = array(self::ZERO => 'zero');
}
$v1 = c1::$a1;
$v2 = c1::$a2;
$v1[] = 1;
$v2[] = 1;
var_dump($v1);
var_dump($v2);
Expected result:
----------------
array(2) {
[1]=>
string(3) "one"
[2]=>
int(1)
}
array(2) {
[0]=>
string(4) "zero"
[1]=>
int(1)
}
Actual result:
--------------
array(2) {
[1]=>
string(3) "one"
[0]=>
int(1)
}
array(1) {
[0]=>
string(4) "zero"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69017&edit=1