xref: /php-src/ext/standard/tests/array/gh16905.phpt (revision e1b45347)
1--TEST--
2GH-16905 (Internal iterator functions can't handle UNDEF properties)
3--FILE--
4<?php
5
6class TestSomeUndef {
7	public int $a;
8	public int $b;
9	public int $c;
10	public int $d;
11}
12
13class TestAllUndef {
14	public int $a;
15}
16
17$x = new TestSomeUndef;
18$x->b = 1;
19$x->c = 2;
20
21var_dump(reset($x));
22var_dump(current($x));
23var_dump(end($x));
24
25var_dump(reset($x));
26var_dump(next($x));
27
28var_dump(end($x));
29var_dump(prev($x));
30
31var_dump(key($x));
32var_dump(current($x));
33
34$x = new TestAllUndef;
35var_dump(key($x));
36var_dump(current($x));
37
38$x->a = 1;
39var_dump(key($x));
40var_dump(current($x));
41reset($x);
42var_dump(key($x));
43var_dump(current($x));
44
45?>
46--EXPECTF--
47Deprecated: reset(): Calling reset() on an object is deprecated in %s on line %d
48int(1)
49
50Deprecated: current(): Calling current() on an object is deprecated in %s on line %d
51int(1)
52
53Deprecated: end(): Calling end() on an object is deprecated in %s on line %d
54int(2)
55
56Deprecated: reset(): Calling reset() on an object is deprecated in %s on line %d
57int(1)
58
59Deprecated: next(): Calling next() on an object is deprecated in %s on line %d
60int(2)
61
62Deprecated: end(): Calling end() on an object is deprecated in %s on line %d
63int(2)
64
65Deprecated: prev(): Calling prev() on an object is deprecated in %s on line %d
66int(1)
67
68Deprecated: key(): Calling key() on an object is deprecated in %s on line %d
69string(1) "b"
70
71Deprecated: current(): Calling current() on an object is deprecated in %s on line %d
72int(1)
73
74Deprecated: key(): Calling key() on an object is deprecated in %s on line %d
75NULL
76
77Deprecated: current(): Calling current() on an object is deprecated in %s on line %d
78bool(false)
79
80Deprecated: key(): Calling key() on an object is deprecated in %s on line %d
81NULL
82
83Deprecated: current(): Calling current() on an object is deprecated in %s on line %d
84bool(false)
85
86Deprecated: reset(): Calling reset() on an object is deprecated in %s on line %d
87
88Deprecated: key(): Calling key() on an object is deprecated in %s on line %d
89string(1) "a"
90
91Deprecated: current(): Calling current() on an object is deprecated in %s on line %d
92int(1)
93