ssa_bug_003.phpt 651 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Incorrect elision of return type checks
  3. --EXTENSIONS--
  4. opcache
  5. --FILE--
  6. <?php
  7. function test1($x) : callable {
  8. if ($x == 1) {
  9. $c = 'foo';
  10. } elseif ($x == 2) {
  11. $c = new stdClass;
  12. } else {
  13. $c = [$x => &$x];
  14. }
  15. return $c;
  16. }
  17. try {
  18. test1(1);
  19. } catch (Error $e) {
  20. echo $e->getMessage() . "\n";
  21. }
  22. class Foo {}
  23. function test2() : Foo {
  24. $obj = new stdClass;
  25. return $obj;
  26. }
  27. try {
  28. test2();
  29. } catch (Error $e) {
  30. echo $e->getMessage() . "\n";
  31. }
  32. ?>
  33. --EXPECT--
  34. test1(): Return value must be of type callable, string returned
  35. test2(): Return value must be of type Foo, stdClass returned