xref: /PHP-7.3/ext/standard/tests/array/bug28739.phpt (revision a541bb80)
1--TEST--
2Bug #28739 (*diff() and *intersect() not clearing the fci cache before work)
3--FILE--
4<?php
5class p {
6   public $x;
7   function __construct($x){$this->x=$x;}
8}
9function a(&$a, &$b){var_dump(__FUNCTION__);return $a->x - $b->x;}
10function b(&$a, &$b){var_dump(__FUNCTION__);return $a->x - $b->x;}
11
12$p1 = array(new p(2), new p(1), new p(0));
13$p2 = array(new p(0), new p(2), new p(3));
14
15uasort($p1, 'a');
16print_r($p1);
17echo "Now diffing:\n";
18print_r(array_udiff($p1,$p2, 'b'));
19?>
20--EXPECT--
21string(1) "a"
22string(1) "a"
23Array
24(
25    [2] => p Object
26        (
27            [x] => 0
28        )
29
30    [1] => p Object
31        (
32            [x] => 1
33        )
34
35    [0] => p Object
36        (
37            [x] => 2
38        )
39
40)
41Now diffing:
42string(1) "b"
43string(1) "b"
44string(1) "b"
45string(1) "b"
46string(1) "b"
47string(1) "b"
48string(1) "b"
49string(1) "b"
50string(1) "b"
51Array
52(
53    [1] => p Object
54        (
55            [x] => 1
56        )
57
58)
59