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

 ID:                 50816
 Patch added by:     pierr...@php.net
 Reported by:        spasic dot dejan at yahoo dot de
 Summary:            Using class constants in array definition fails 
                     (works in PHP_5_2)
 Status:             Verified
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   *
 PHP Version:        5.3, 6
 Block user comment: N
 Private report:     N

 New Comment:

The following patch has been added/updated:

Patch Name: 50816-2.diff
Revision:   1311949824
URL:        
https://bugs.php.net/patch-display.php?bug=50816&patch=50816-2.diff&revision=1311949824


Previous Comments:
------------------------------------------------------------------------
[2011-07-29 04:14:28] pierr...@php.net

The following patch has been added/updated:

Patch Name: 50816-2.diff
Revision:   1311912867
URL:        
https://bugs.php.net/patch-display.php?bug=50816&patch=50816-2.diff&revision=1311912867

------------------------------------------------------------------------
[2011-07-29 00:54:11] pierr...@php.net

The following patch has been added/updated:

Patch Name: 50816.diff
Revision:   1311900851
URL:        
https://bugs.php.net/patch-display.php?bug=50816&patch=50816.diff&revision=1311900851

------------------------------------------------------------------------
[2010-01-22 13:45:10] j...@php.net

Works as expected in PHP 5.2, fails with 5.3 and above.

------------------------------------------------------------------------
[2010-01-21 22:14:08] spasic dot dejan at yahoo dot de

Description:
------------
Some lines of code is worth a thousand words

Reproduce code:
---------------
class Foo {
  const ONE = 1;
  const TWO = 1;

  public static $mapWithConst = array(self::ONE => 'one', self::TWO => 'two',);

  public static $mapWithoutConst = array(17 => 'one', 17 => 'two',);
}

$mapWithConst = array(1 => 'one', 1 => 'two',);

$mapWithoutConst = array(Foo::ONE => 'one', Foo::TWO => 'two',);

var_dump(Foo::$mapWithConst);
var_dump(Foo::$mapWithoutConst);
var_dump($mapWithConst);
var_dump($mapWithoutConst);


Expected result:
----------------
array(1) {
  [1]=>
  string(3) "two"
}
array(1) {
  [17]=>
  string(3) "two"
}
array(1) {
  [1]=>
  string(3) "two"
}
array(1) {
  [1]=>
  string(3) "two"
}


Actual result:
--------------
array(1) {
  [1]=>
  string(3) "one"   // ???
}
array(1) {
  [17]=>
  string(3) "two"
}
array(1) {
  [1]=>
  string(3) "two"
}
array(1) {
  [1]=>
  string(3) "two"
}



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



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

Reply via email to