objects_033.phpt 859 B

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