016.phpt 516 B

12345678910111213141516171819202122232425262728293031323334
  1. --TEST--
  2. static variables in methods inherited from parent class (can't cache objects)
  3. --FILE--
  4. <?php
  5. class C {
  6. function foo ($y = null) {
  7. static $x = null;
  8. if (!is_null($y)) {
  9. $x = [$y];
  10. }
  11. return $x;
  12. }
  13. }
  14. $c = new C();
  15. $c->foo(new stdClass);
  16. $d = new class extends C {};
  17. var_dump($d->foo());
  18. var_dump($d->foo(24));
  19. var_dump($c->foo());
  20. ?>
  21. --EXPECT--
  22. array(1) {
  23. [0]=>
  24. object(stdClass)#2 (0) {
  25. }
  26. }
  27. array(1) {
  28. [0]=>
  29. int(24)
  30. }
  31. array(1) {
  32. [0]=>
  33. int(24)
  34. }