Add support for true type

The null/false types were alread accepted previously, even though
they are only legal as standalone types since PHP 8.2.

Non-trivial backport from 1eba33d4124a248dd5c970fa7d6064d2e31b8635.
This commit is contained in:
Nikita Popov 2022-06-19 11:06:39 +02:00
parent 2d589921f2
commit 3fe2422e34
2 changed files with 57 additions and 0 deletions

View File

@ -664,6 +664,7 @@ abstract class ParserAbstract implements Parser
'false' => true,
'mixed' => true,
'never' => true,
'true' => true,
];
if (!$name->isUnqualified()) {

View File

@ -0,0 +1,56 @@
standalone null, false and true types
-----
<?php
function test(): null {}
function test(): false {}
function test(): true {}
-----
!!php7
array(
0: Stmt_Function(
attrGroups: array(
)
byRef: false
name: Identifier(
name: test
)
params: array(
)
returnType: Identifier(
name: null
)
stmts: array(
)
)
1: Stmt_Function(
attrGroups: array(
)
byRef: false
name: Identifier(
name: test
)
params: array(
)
returnType: Identifier(
name: false
)
stmts: array(
)
)
2: Stmt_Function(
attrGroups: array(
)
byRef: false
name: Identifier(
name: test
)
params: array(
)
returnType: Identifier(
name: true
)
stmts: array(
)
)
)