xref: /PHP-7.1/ext/spl/tests/bug45622.phpt (revision 113213f0)
1--TEST--
2SPL: Bug #45622 (isset($arrayObject->p) misbehaves with ArrayObject::ARRAY_AS_PROPS set
3--FILE--
4<?php
5
6class C extends ArrayObject {
7	public $p = 'object property';
8}
9
10$ao = new C(array('p'=>'array element'));
11$ao->setFlags(ArrayObject::ARRAY_AS_PROPS);
12
13echo "\n--> Access the real property:\n";
14var_dump(isset($ao->p));
15var_dump($ao->p);
16
17echo "\n--> Remove the real property and access the array element:\n";
18unset($ao->p);
19var_dump(isset($ao->p));
20var_dump($ao->p);
21
22echo "\n--> Remove the array element and try access again:\n";
23unset($ao->p);
24var_dump(isset($ao->p));
25var_dump($ao->p);
26
27echo "\n--> Re-add the real property:\n";
28$ao->p = 'object property';
29var_dump(isset($ao->p));
30var_dump($ao->p);
31?>
32--EXPECTF--
33--> Access the real property:
34bool(true)
35%unicode|string%(15) "object property"
36
37--> Remove the real property and access the array element:
38bool(true)
39%unicode|string%(13) "array element"
40
41--> Remove the array element and try access again:
42bool(false)
43
44Notice: Undefined index: p in %s on line %d
45NULL
46
47--> Re-add the real property:
48bool(true)
49%unicode|string%(15) "object property"
50