bug71334.phpt 626 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. --TEST--
  2. Bug #71334: Cannot access array keys while uksort()
  3. --FILE--
  4. <?php
  5. class myClass
  6. {
  7. private $a = [
  8. 'foo-test' => [1],
  9. '-' => [2],
  10. 'bar-test' => [3]
  11. ];
  12. private function _mySort($x, $y)
  13. {
  14. if (!isset($this->a[$x])) {
  15. throw new Exception('Missing X: "' . $x . '"');
  16. }
  17. if (!isset($this->a[$y])) {
  18. throw new Exception('Missing Y: "' . $y . '"');
  19. }
  20. return $x <=> $y;
  21. }
  22. public function __construct()
  23. {
  24. uksort($this->a, [$this, '_mySort']);
  25. }
  26. }
  27. new myClass();
  28. echo "Done";
  29. ?>
  30. --EXPECT--
  31. Done