xref: /PHP-5.3/ext/spl/tests/bug45622.phpt (revision 77baec3f)
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
34--> Access the real property:
35bool(true)
36%unicode|string%(15) "object property"
37
38--> Remove the real property and access the array element:
39bool(true)
40%unicode|string%(13) "array element"
41
42--> Remove the array element and try access again:
43bool(false)
44
45Notice: Undefined index:  p in %s on line %d
46NULL
47
48--> Re-add the real property:
49bool(true)
50%unicode|string%(15) "object property"
51
52