mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-05-31 17:19:23 +02:00
Fix some phpstan warnings
This commit is contained in:
parent
468c0ef6bc
commit
f59f226f65
@ -20,7 +20,8 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
|
||||
"ircmaxell/php-yacc": "^0.0.7"
|
||||
"ircmaxell/php-yacc": "^0.0.7",
|
||||
"phpstan/phpstan": "^1.8"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
@ -1309,7 +1309,7 @@ array_pair:
|
||||
| expr T_DOUBLE_ARROW expr { $$ = Node\ArrayItem[$3, $1, false]; }
|
||||
| expr T_DOUBLE_ARROW ampersand variable { $$ = Node\ArrayItem[$4, $1, true]; }
|
||||
| expr T_DOUBLE_ARROW list_expr { $$ = Node\ArrayItem[$3, $1, false]; }
|
||||
| T_ELLIPSIS expr { $$ = Node\ArrayItem[$2, null, false, attributes(), true]; }
|
||||
| T_ELLIPSIS expr { $$ = new Node\ArrayItem($2, null, false, attributes(), true); }
|
||||
| /* empty */
|
||||
{ /* Create an Error node now to remember the position. We'll later either report an error,
|
||||
or convert this into a null element, depending on whether this is a creation or destructuring context. */
|
||||
|
@ -35,7 +35,7 @@ class Enum_ extends Declaration {
|
||||
/**
|
||||
* Sets the scalar type.
|
||||
*
|
||||
* @param string|Identifier $type
|
||||
* @param string|Identifier $scalarType
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
@ -18,7 +18,7 @@ class Property implements PhpParser\Builder {
|
||||
protected $default = null;
|
||||
protected $attributes = [];
|
||||
|
||||
/** @var null|Identifier|Name|NullableType */
|
||||
/** @var null|Identifier|Name|ComplexType */
|
||||
protected $type;
|
||||
|
||||
/** @var Node\AttributeGroup[] */
|
||||
|
@ -12,7 +12,7 @@ abstract class TokenEmulator {
|
||||
abstract public function isEmulationNeeded(string $code): bool;
|
||||
|
||||
/**
|
||||
* @param Token[] Original tokens
|
||||
* @param Token[] $tokens Original tokens
|
||||
* @return Token[] Modified Tokens
|
||||
*/
|
||||
abstract public function emulate(string $code, array $tokens): array;
|
||||
|
@ -20,7 +20,7 @@ class Name extends NodeAbstract {
|
||||
* @param string|string[]|self $name Name as string, part array or Name instance (copy ctor)
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $attributes = []) {
|
||||
final public function __construct($name, array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->parts = self::prepareName($name);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ interface NodeVisitor {
|
||||
*
|
||||
* @param Node $node Node
|
||||
*
|
||||
* @return null|int|Node Replacement node (or special return value)
|
||||
* @return null|int|Node|Node[] Replacement node (or special return value)
|
||||
*/
|
||||
public function enterNode(Node $node);
|
||||
|
||||
|
@ -2961,7 +2961,7 @@ class Php7 extends \PhpParser\ParserAbstract
|
||||
$this->semValue = new Node\ArrayItem($this->semStack[$stackPos-(3-3)], $this->semStack[$stackPos-(3-1)], false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes);
|
||||
},
|
||||
588 => function ($stackPos) {
|
||||
$this->semValue = new Node\ArrayItem($this->semStack[$stackPos-(2-2)], null, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes);
|
||||
$this->semValue = new Node\ArrayItem($this->semStack[$stackPos-(2-2)], null, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, true);
|
||||
},
|
||||
589 => function ($stackPos) {
|
||||
/* Create an Error node now to remember the position. We'll later either report an error,
|
||||
|
@ -2979,7 +2979,7 @@ class Php8 extends \PhpParser\ParserAbstract
|
||||
$this->semValue = new Node\ArrayItem($this->semStack[$stackPos-(3-3)], $this->semStack[$stackPos-(3-1)], false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes);
|
||||
},
|
||||
588 => function ($stackPos) {
|
||||
$this->semValue = new Node\ArrayItem($this->semStack[$stackPos-(2-2)], null, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes);
|
||||
$this->semValue = new Node\ArrayItem($this->semStack[$stackPos-(2-2)], null, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, true);
|
||||
},
|
||||
589 => function ($stackPos) {
|
||||
/* Create an Error node now to remember the position. We'll later either report an error,
|
||||
|
@ -483,7 +483,8 @@ class Standard extends PrettyPrinterAbstract {
|
||||
$cast = '(double)';
|
||||
} elseif ($kind === Cast\Double::KIND_FLOAT) {
|
||||
$cast = '(float)';
|
||||
} elseif ($kind === Cast\Double::KIND_REAL) {
|
||||
} else {
|
||||
assert($kind === Cast\Double::KIND_REAL);
|
||||
$cast = '(real)';
|
||||
}
|
||||
return $this->pPrefixOp(Cast\Double::class, $cast . ' ', $node->expr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user