Bug #69017 [NEW]: Fail to push to the empty array with the constant value defined in class scope
| From: | n-hatano at infiniteloop dot co dot jp | Date: | Mon, 09 Feb 2015 07:35:33 +0000 |
| Subject: | Bug #69017 [NEW]: Fail to push to the empty array with the constant value defined in class scope | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-190539@lists.php.net to get a copy of this message | ||
From: n-hatano at infiniteloop dot co dot jp
Operating system:
PHP version: 5.4.37
Package: Arrays related
Bug Type: Bug
Bug description:Fail to push to the empty array with the constant value defined in class scope
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 bug report at https://bugs.php.net/bug.php?id=69017&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69017&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69017&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69017&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69017&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69017&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69017&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69017&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69017&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69017&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69017&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69017&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69017&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69017&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69017&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69017&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69017&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69017&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69017&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69017&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69017&r=mysqlcfg