summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/bug71334.phpt
blob: 7a37d0953a4ea824693b3546573f1f2ef2653e2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--TEST--
Bug #71334: Cannot access array keys while uksort()
--FILE--
<?php

class myClass
{
	private $a = [
		'foo-test' => [1],
		'-' => [2],
		'bar-test' => [3]
	];

	private function _mySort($x, $y)
	{
		if (!isset($this->a[$x])) {
			throw new Exception('Missing X: "' . $x . '"');
		}

		if (!isset($this->a[$y])) {
			throw new Exception('Missing Y: "' . $y . '"');
		}

		return $x < $y;
	}

	public function __construct()
	{
		uksort($this->a, [$this, '_mySort']);
	}
}

new myClass();
echo "Done";

?>
--EXPECT--
Done