dynamic_call_non_static.phpt 576 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. Dynamic static call of non-static method
  3. --FILE--
  4. <?php
  5. class Foo {
  6. function test1() {
  7. $method = ['Foo', 'bar'];
  8. $method();
  9. }
  10. function test2() {
  11. $method = 'Foo::bar';
  12. $method();
  13. }
  14. function __call($name, $args) {}
  15. }
  16. $x = new Foo;
  17. try {
  18. $x->test1();
  19. } catch (Error $e) {
  20. echo $e->getMessage(), "\n";
  21. }
  22. try {
  23. $x->test2();
  24. } catch (Error $e) {
  25. echo $e->getMessage(), "\n";
  26. }
  27. ?>
  28. --EXPECT--
  29. Non-static method Foo::bar() cannot be called statically
  30. Non-static method Foo::bar() cannot be called statically