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