ssa_bug_003.phpt 717 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Incorrect elision of return type checks
  3. --SKIPIF--
  4. <?php require_once('skipif.inc'); ?>
  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 "Error: {$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 "Error: {$e->getMessage()}\n";
  31. }
  32. ?>
  33. --EXPECT--
  34. Error: Return value of test1() must be callable, string returned
  35. Error: Return value of test2() must be an instance of Foo, instance of stdClass returned