method_static_var.phpt 530 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. Initial value of static var in method depends on the include time of the class definition
  3. --XFAIL--
  4. Maybe not a bug
  5. --FILE--
  6. <?php
  7. class Foo {
  8. public function __construct() {
  9. eval("class Bar extends Foo {}");
  10. }
  11. public static function test() {
  12. static $i = 0;
  13. var_dump(++$i);
  14. }
  15. }
  16. foo::test();
  17. new Foo;
  18. foo::test();
  19. /**
  20. * function_add_ref() makes a clone of static variables for inherited functions, so $i in Bar::test gets initial value 1
  21. */
  22. Bar::test();
  23. Bar::test();
  24. --EXPECT--
  25. int(1)
  26. int(2)
  27. int(1)
  28. int(2)