Skip to content

Commit abbb2b9

Browse files
committed
Add tests for relative class types
1 parent 0de8bc2 commit abbb2b9

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Cannot use parent type outside a class
3+
--FILE--
4+
<?php
5+
6+
function foo($x): parent {};
7+
8+
?>
9+
--EXPECTF--
10+
Fatal error: Cannot use "parent" when no class scope is active in %s on line %d
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Cannot use self type outside a class
3+
--FILE--
4+
<?php
5+
6+
function foo($x): self {};
7+
8+
?>
9+
--EXPECTF--
10+
Fatal error: Cannot use "self" when no class scope is active in %s on line %d
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Cannot use static type outside a class
3+
--FILE--
4+
<?php
5+
6+
function foo($x): static {};
7+
8+
?>
9+
--EXPECTF--
10+
Fatal error: Cannot use "static" when no class scope is active in %s on line %d
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Relative class types can be used for closures as it may be bound to a class
3+
--FILE--
4+
<?php
5+
6+
$fn1 = function($x): self {};
7+
$fn2 = function($x): parent {};
8+
$fn3 = function($x): static {};
9+
10+
?>
11+
DONE
12+
--EXPECT--
13+
DONE

0 commit comments

Comments
 (0)