closure_007.phpt 502 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. --TEST--
  2. Closure 007: Nested lambdas in classes
  3. --FILE--
  4. <?php
  5. class A {
  6. private $x = 0;
  7. function getClosureGetter () {
  8. return function () {
  9. return function () {
  10. $this->x++;
  11. };
  12. };
  13. }
  14. function printX () {
  15. echo $this->x."\n";
  16. }
  17. }
  18. $a = new A;
  19. $a->printX();
  20. $getClosure = $a->getClosureGetter();
  21. $a->printX();
  22. $closure = $getClosure();
  23. $a->printX();
  24. $closure();
  25. $a->printX();
  26. echo "Done\n";
  27. ?>
  28. --EXPECT--
  29. 0
  30. 0
  31. 0
  32. 1
  33. Done