diff options
Diffstat (limited to 'ext/opcache/tests/opt/verify_return_type.phpt')
-rw-r--r-- | ext/opcache/tests/opt/verify_return_type.phpt | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/ext/opcache/tests/opt/verify_return_type.phpt b/ext/opcache/tests/opt/verify_return_type.phpt index c1384c7af8..3838cd8b0c 100644 --- a/ext/opcache/tests/opt/verify_return_type.phpt +++ b/ext/opcache/tests/opt/verify_return_type.phpt @@ -20,6 +20,23 @@ class Test1 { } } +class Test2 { + public function getInt(): int { + return 42; + } + public function getInt2(): int { + return $this->getInt(); + } + public function getIntOrFloat(int $i): int|float { + return $i; + } + public function getInt3(int $i): int { + // Should not elide return type check. Test2::getIntOrFloat() returns only int, + // but a child method may return int|float. + return $this->getIntOrFloat($i); + } +} + ?> --EXPECTF-- $_main: @@ -42,3 +59,35 @@ Test1::getInt: 0000 INIT_METHOD_CALL 0 THIS string("getIntOrFloat") 0001 V0 = DO_UCALL 0002 RETURN V0 + +Test2::getInt: + ; (lines=1, args=0, vars=0, tmps=0) + ; (after optimizer) + ; %s +0000 RETURN int(42) + +Test2::getInt2: + ; (lines=3, args=0, vars=0, tmps=1) + ; (after optimizer) + ; %s +0000 INIT_METHOD_CALL 0 THIS string("getInt") +0001 V0 = DO_FCALL +0002 RETURN V0 + +Test2::getIntOrFloat: + ; (lines=2, args=1, vars=1, tmps=0) + ; (after optimizer) + ; %s +0000 CV0($i) = RECV 1 +0001 RETURN CV0($i) + +Test2::getInt3: + ; (lines=6, args=1, vars=1, tmps=1) + ; (after optimizer) + ; %s +0000 CV0($i) = RECV 1 +0001 INIT_METHOD_CALL 1 THIS string("getIntOrFloat") +0002 SEND_VAR CV0($i) 1 +0003 V1 = DO_FCALL +0004 VERIFY_RETURN_TYPE V1 +0005 RETURN V1 |