#45742 [Asn->Csd]: Wrong class array inpretetion using constant indexes

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               45742
 Updated by:       [email protected]
 Reported By:      [email protected]
-Status:           Assigned
+Status:           Closed
 Bug Type:         Scripting Engine problem
 Operating System: Linux 2.6.26-gentoo
 PHP Version:      5.3CVS-2008-08-07 (CVS)
 Assigned To:      dmitry
 New Comment:

This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2008-08-07 09:54:24] [email protected]

Description:
------------
If an array is used as a class property and the keys are constants,
where two keys / constants have the same value, the second key is
converted to a "strange" string.

Reproduce code:
---------------
<?php

class Constants {
    // Needs to be equal
    const A = 1;
    const B = 1;
}

class ArrayProperty {
    public static $array = array(
        Constants::A => 23,
        Constants::B => 42,
    );
}

var_dump( ArrayProperty::$array );

?>

Expected result:
----------------
Output PHP 5.2.7-dev (cli) (built: Aug  7 2008 11:12:42) (DEBUG)
array(1) {
  [1]=>
  int(42)
}

Actual result:
--------------
Output PHP 5.3.0alpha2-dev (cli) (built: Aug  6 2008 19:47:42) (DEBUG)
array(2) {
  [1]=>
  int(23)
  ["Constants::"]=>
  int(42)
}


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


-- 
Edit this bug report at http://bugs.php.net/?id=45742&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.