mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-04-21 22:42:06 +02:00
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:
parent
2d589921f2
commit
3fe2422e34
@ -664,6 +664,7 @@ abstract class ParserAbstract implements Parser
|
||||
'false' => true,
|
||||
'mixed' => true,
|
||||
'never' => true,
|
||||
'true' => true,
|
||||
];
|
||||
|
||||
if (!$name->isUnqualified()) {
|
||||
|
56
test/code/parser/stmt/function/nullFalseTrueTypes.test
Normal file
56
test/code/parser/stmt/function/nullFalseTrueTypes.test
Normal 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(
|
||||
)
|
||||
)
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user