mirror of
https://github.com/danog/PHP-Parser.git
synced 2025-01-22 13:51:12 +01:00
PHP 7.1: Add void+iterable support
In PHP 7 mode, these will now be represented as strings 'void' and 'iterable'.
This commit is contained in:
parent
038e11da4b
commit
5044fce1ff
@ -364,7 +364,7 @@ parameter:
|
||||
;
|
||||
|
||||
type:
|
||||
name { $$ = $this->handleScalarTypes($1); }
|
||||
name { $$ = $this->handleBuiltinTypes($1); }
|
||||
| T_ARRAY { $$ = 'array'; }
|
||||
| T_CALLABLE { $$ = 'callable'; }
|
||||
;
|
||||
|
@ -1677,7 +1677,7 @@ class Php7 extends \PhpParser\ParserAbstract
|
||||
}
|
||||
|
||||
protected function reduceRule221() {
|
||||
$this->semValue = $this->handleScalarTypes($this->semStack[$this->stackPos-(1-1)]);
|
||||
$this->semValue = $this->handleBuiltinTypes($this->semStack[$this->stackPos-(1-1)]);
|
||||
}
|
||||
|
||||
protected function reduceRule222() {
|
||||
|
@ -481,12 +481,14 @@ abstract class ParserAbstract implements Parser
|
||||
return $style;
|
||||
}
|
||||
|
||||
protected function handleScalarTypes(Name $name) {
|
||||
protected function handleBuiltinTypes(Name $name) {
|
||||
$scalarTypes = [
|
||||
'bool' => true,
|
||||
'int' => true,
|
||||
'float' => true,
|
||||
'string' => true,
|
||||
'bool' => true,
|
||||
'int' => true,
|
||||
'float' => true,
|
||||
'string' => true,
|
||||
'iterable' => true,
|
||||
'void' => true,
|
||||
];
|
||||
|
||||
if (!$name->isUnqualified()) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
Scalar type declarations
|
||||
-----
|
||||
<?php
|
||||
function test(bool $a, Int $b, FLOAT $c, StRiNg $d) {}
|
||||
function test(bool $a, Int $b, FLOAT $c, StRiNg $d, iterable $e) : void {}
|
||||
-----
|
||||
!!php7
|
||||
array(
|
||||
@ -37,8 +37,15 @@ array(
|
||||
name: d
|
||||
default: null
|
||||
)
|
||||
4: Param(
|
||||
type: iterable
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: e
|
||||
default: null
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
returnType: void
|
||||
stmts: array(
|
||||
)
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user