xref: /PHP-8.1/Zend/tests/objects_033.phpt (revision 72c3eded)
1--TEST--
2Ensure object comparison property order remains consistent
3--FILE--
4<?php
5
6// PHP4-5.3 object semantics had child properties added to an
7// object HashTable first, then parent, then grandparent, etc...
8// As of PHP 5.4 we use a packed C array to hold properties
9// which may or may not share the same ordering.
10// In the code snippet below, the print_r() has the side-effect
11// of materializing the properties shadow HashTable which
12// if used for comparison, results in the behavior consistent
13// with pre PHP-5.4.
14// This test ensures that the first comparison yields the same
15// result without shadow table materialization.
16
17class A { public $a; }
18class B extends A { public $b; }
19$a = new B(); $a->a = 0; $a->b = 1;
20$b = new B(); $b->a = 1; $b->b = 0;
21
22var_dump($a < $b);
23print_r($a, true);
24var_dump($a < $b);
25?>
26--EXPECT--
27bool(true)
28bool(true)
29