method_argument_binding.phpt 630 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. Edge cases in compile-time method argument binding
  3. --FILE--
  4. <?php
  5. class A {
  6. private function method($x) {}
  7. }
  8. class B extends A {
  9. public function test() {
  10. $x = 1;
  11. $this->method($x);
  12. var_dump($x);
  13. }
  14. }
  15. class C extends B {
  16. public function method(&$x) {
  17. ++$x;
  18. }
  19. }
  20. (new C)->test();
  21. class D {
  22. private function method(&$x) {
  23. ++$x;
  24. }
  25. }
  26. class E extends D {
  27. public function __call($name, $args) { }
  28. public function test() {
  29. $this->method($x);
  30. }
  31. }
  32. (new E)->test();
  33. ?>
  34. --EXPECTF--
  35. int(2)
  36. Warning: Undefined variable $x in %s on line %d