xref: /PHP-8.1/ext/spl/tests/bug53515.phpt (revision d7a3edd4)
1--TEST--
2Bug #53515 (property_exists incorrect on ArrayObject null and 0 values)
3--FILE--
4<?php
5
6$a = array('a' => 1, 'b'=> true, 'c' => 0, 'd' => null, 'e' => false, 'f' => array());
7$o = new ArrayObject($a, ArrayObject::ARRAY_AS_PROPS);
8
9$a['z'] = '';
10$a[''] = '';
11
12foreach ($a as $key => $value) {
13 echo $key . ': ' . (is_null($value) ? 'null' : @"$value") .
14    ' array_key_exists: ' . (array_key_exists($key, $a) ? 'true' : 'false') .
15    ' property_exists: ' . (property_exists($o, $key) ? 'true' : 'false'),"\n";
16}
17
18?>
19--EXPECT--
20a: 1 array_key_exists: true property_exists: true
21b: 1 array_key_exists: true property_exists: true
22c: 0 array_key_exists: true property_exists: true
23d: null array_key_exists: true property_exists: true
24e:  array_key_exists: true property_exists: true
25f: Array array_key_exists: true property_exists: true
26z:  array_key_exists: true property_exists: false
27:  array_key_exists: true property_exists: false
28