bug50816.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. Bug #50816 (Using class constants in array definition fails)
  3. --FILE--
  4. <?php
  5. define("ONE", 1);
  6. define("TWO", 1);
  7. class Foo {
  8. const ONE = 1;
  9. const TWO = 1;
  10. public static $mapWithConst = array(self::ONE => 'one', self::TWO => 'two',);
  11. public static $mapWithConst1 = array(1 => 'one', self::TWO => 'two',);
  12. public static $mapWithConst2 = array(self::ONE => 'one', 1 => 'two',);
  13. public static $mapWithoutConst = array(1 => 'one', 1 => 'two',);
  14. }
  15. $mapWithConst = array(1 => 'one', 1 => 'two',);
  16. $mapWithoutConst = array(Foo::ONE => 'one', Foo::TWO => 'two',);
  17. $mapWithoutConst0 = array(1 => 'one', 1 => 'two',);
  18. $mapWithoutConst1 = array(ONE => 'one', 1 => 'two',);
  19. $mapWithoutConst2 = array(1 => 'one', TWO => 'two',);
  20. $mapWithoutConst3 = array(ONE => 'one', TWO => 'two',);
  21. var_dump(Foo::$mapWithConst[1]);
  22. var_dump(Foo::$mapWithConst1[1]);
  23. var_dump(Foo::$mapWithConst2[1]);
  24. var_dump(Foo::$mapWithoutConst[1]);
  25. var_dump($mapWithConst[1]);
  26. var_dump($mapWithoutConst[1]);
  27. var_dump($mapWithoutConst0[1]);
  28. var_dump($mapWithoutConst1[1]);
  29. var_dump($mapWithoutConst2[1]);
  30. var_dump($mapWithoutConst3[1]);
  31. ?>
  32. --EXPECT--
  33. string(3) "two"
  34. string(3) "two"
  35. string(3) "two"
  36. string(3) "two"
  37. string(3) "two"
  38. string(3) "two"
  39. string(3) "two"
  40. string(3) "two"
  41. string(3) "two"
  42. string(3) "two"