new_in_constexpr.phpt 503 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. Handling of new in constant expressions in reflection
  3. --FILE--
  4. <?php
  5. function test1() {
  6. static $x = new stdClass;
  7. return $x;
  8. }
  9. $rf = new ReflectionFunction('test1');
  10. $s = $rf->getStaticVariables();
  11. var_dump($s['x'] === test1());
  12. function test2($x = new stdClass) {
  13. return $x;
  14. }
  15. $rf = new ReflectionFunction('test2');
  16. $rp = $rf->getParameters()[0];
  17. // Parameter default should *not* be the same.
  18. var_dump($rp->getDefaultValue() !== test2());
  19. ?>
  20. --EXPECT--
  21. bool(true)
  22. bool(true)