bug69017.phpt 762 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. #69017 (Fail to push to the empty array with the constant value defined in class scope)
  3. --FILE--
  4. <?php
  5. class c1
  6. {
  7. const ZERO = 0;
  8. const ONE = 1;
  9. const MAX = PHP_INT_MAX;
  10. public static $a1 = array(self::ONE => 'one');
  11. public static $a2 = array(self::ZERO => 'zero');
  12. public static $a3 = array(self::MAX => 'zero');
  13. }
  14. c1::$a1[] = 1;
  15. c1::$a2[] = 1;
  16. try {
  17. c1::$a3[] = 1;
  18. } catch (Error $e) {
  19. echo $e->getMessage(), "\n";
  20. }
  21. var_dump(c1::$a1);
  22. var_dump(c1::$a2);
  23. var_dump(c1::$a3);
  24. ?>
  25. --EXPECTF--
  26. Cannot add element to the array as the next element is already occupied
  27. array(2) {
  28. [1]=>
  29. string(3) "one"
  30. [2]=>
  31. int(1)
  32. }
  33. array(2) {
  34. [0]=>
  35. string(4) "zero"
  36. [1]=>
  37. int(1)
  38. }
  39. array(1) {
  40. [%d]=>
  41. string(4) "zero"
  42. }