closure_037.phpt 668 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Closure 037: self:: and static:: within closures
  3. --FILE--
  4. <?php
  5. class A {
  6. private $x = 0;
  7. function getClosure () {
  8. return function () {
  9. $this->x++;
  10. self::printX();
  11. self::print42();
  12. static::print42();
  13. };
  14. }
  15. function printX () {
  16. echo $this->x."\n";
  17. }
  18. function print42() {
  19. echo "42\n";
  20. }
  21. }
  22. class B extends A {
  23. function print42() {
  24. echo "forty two\n";
  25. }
  26. }
  27. $a = new A;
  28. $closure = $a->getClosure();
  29. $closure();
  30. $b = new B;
  31. $closure = $b->getClosure();
  32. $closure();
  33. ?>
  34. Done.
  35. --EXPECT--
  36. 1
  37. 42
  38. 42
  39. 1
  40. 42
  41. forty two
  42. Done.