classes.phpt 645 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Array unpacking with classes
  3. --FILE--
  4. <?php
  5. class C {
  6. public const FOO = [0, ...self::ARR, 4];
  7. public const ARR = [1, 2, 3];
  8. public static $bar = [...self::ARR];
  9. }
  10. class D {
  11. public const A = [...self::B];
  12. public const B = [...self::A];
  13. }
  14. var_dump(C::FOO);
  15. var_dump(C::$bar);
  16. try {
  17. var_dump(D::A);
  18. } catch (Error $ex) {
  19. echo "Exception: " . $ex->getMessage() . "\n";
  20. }
  21. ?>
  22. --EXPECT--
  23. array(5) {
  24. [0]=>
  25. int(0)
  26. [1]=>
  27. int(1)
  28. [2]=>
  29. int(2)
  30. [3]=>
  31. int(3)
  32. [4]=>
  33. int(4)
  34. }
  35. array(3) {
  36. [0]=>
  37. int(1)
  38. [1]=>
  39. int(2)
  40. [2]=>
  41. int(3)
  42. }
  43. Exception: Cannot declare self-referencing constant self::B