Skip to content

Commit b41a117

Browse files
committed
Also test case where no static scope is available
1 parent 207bf2a commit b41a117

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Zend/tests/type_declarations/static_type_return.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class B extends A {
2626

2727
class C extends B {}
2828

29+
function test(): static {
30+
return new stdClass;
31+
}
32+
2933
$a = new A;
3034
$b = new B;
3135

@@ -52,6 +56,13 @@ try {
5256
echo $e->getMessage(), "\n";
5357
}
5458

59+
echo "\n";
60+
try {
61+
var_dump(test());
62+
} catch (TypeError $e) {
63+
echo $e->getMessage(), "\n";
64+
}
65+
5566
?>
5667
--EXPECT--
5768
object(A)#3 (0) {
@@ -71,3 +82,5 @@ object(C)#3 (0) {
7182
object(A)#3 (0) {
7283
}
7384
Return value of A::test4() must be of type static|array, instance of A returned
85+
86+
Return value of test() must be an instance of static, instance of stdClass returned

0 commit comments

Comments
 (0)