new_self_parent.phpt 641 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. new self / new parent in constant expression
  3. --FILE--
  4. <?php
  5. class A {
  6. public static function invalid($x = new parent) {
  7. }
  8. }
  9. class B extends A {
  10. public static function method($x = new self, $y = new parent) {
  11. var_dump($x, $y);
  12. }
  13. }
  14. function invalid($x = new self) {}
  15. B::method();
  16. try {
  17. invalid();
  18. } catch (Error $e) {
  19. echo $e->getMessage(), "\n";
  20. }
  21. try {
  22. B::invalid();
  23. } catch (Error $e) {
  24. echo $e->getMessage(), "\n";
  25. }
  26. ?>
  27. --EXPECT--
  28. object(B)#1 (0) {
  29. }
  30. object(A)#2 (0) {
  31. }
  32. Cannot access "self" when no class scope is active
  33. Cannot access "parent" when current class scope has no parent