invalid_new_dce.phpt 825 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Throwings NEWs should not be DCEd
  3. --INI--
  4. opcache.enable_cli=1
  5. opcache.optimization_level=-1
  6. --EXTENSIONS--
  7. opcache
  8. --FILE--
  9. <?php
  10. abstract class Foo {}
  11. interface Bar {}
  12. trait Baz {}
  13. class Abc {
  14. const BAR = Abc::BAR;
  15. }
  16. function test1() {
  17. $x = new Foo;
  18. }
  19. function test2() {
  20. $x = new Bar;
  21. }
  22. function test3() {
  23. $x = new Baz;
  24. }
  25. function test4() {
  26. $x = new Abc;
  27. }
  28. try { test1(); } catch (Error $e) { echo $e->getMessage(), "\n"; }
  29. try { test2(); } catch (Error $e) { echo $e->getMessage(), "\n"; }
  30. try { test3(); } catch (Error $e) { echo $e->getMessage(), "\n"; }
  31. try { test4(); } catch (Error $e) { echo $e->getMessage(), "\n"; }
  32. ?>
  33. --EXPECT--
  34. Cannot instantiate abstract class Foo
  35. Cannot instantiate interface Bar
  36. Cannot instantiate trait Baz
  37. Cannot declare self-referencing constant Abc::BAR