mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-16 22:58:15 +01:00
Fix PhpStan errors
This commit is contained in:
parent
4b497045e0
commit
62853b179c
@ -158,7 +158,7 @@ abstract class ParserAbstract implements Parser {
|
||||
$this->initReduceCallbacks();
|
||||
$this->phpTokenToSymbol = $this->createTokenMap();
|
||||
$this->dropTokens = array_fill_keys(
|
||||
[\T_WHITESPACE, \T_OPEN_TAG, \T_COMMENT, \T_DOC_COMMENT, \T_BAD_CHARACTER], 1
|
||||
[\T_WHITESPACE, \T_OPEN_TAG, \T_COMMENT, \T_DOC_COMMENT, \T_BAD_CHARACTER], true
|
||||
);
|
||||
}
|
||||
|
||||
@ -471,7 +471,7 @@ abstract class ParserAbstract implements Parser {
|
||||
*
|
||||
* @param int $tokenStartPos Token position the node starts at
|
||||
* @param int $tokenEndPos Token position the node ends at
|
||||
* @return array Attributes
|
||||
* @return array<string, mixed> Attributes
|
||||
*/
|
||||
protected function getAttributes(int $tokenStartPos, int $tokenEndPos): array {
|
||||
$startToken = $this->tokens[$tokenStartPos];
|
||||
@ -491,7 +491,12 @@ abstract class ParserAbstract implements Parser {
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
protected function getAttributesForToken(int $tokenPos) {
|
||||
/**
|
||||
* Get attributes for a single token at the given token position.
|
||||
*
|
||||
* @return array<string, mixed> Attributes
|
||||
*/
|
||||
protected function getAttributesForToken(int $tokenPos): array {
|
||||
if ($tokenPos < \count($this->tokens) - 1) {
|
||||
return $this->getAttributes($tokenPos, $tokenPos);
|
||||
}
|
||||
@ -896,6 +901,11 @@ abstract class ParserAbstract implements Parser {
|
||||
$token->getEndLine(), $token->getEndPos() - 1, $tokenPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comments before the given token position.
|
||||
*
|
||||
* @return Comment[] Comments
|
||||
*/
|
||||
protected function getCommentsBeforeToken(int $tokenPos): array {
|
||||
$comments = [];
|
||||
while (--$tokenPos >= 0) {
|
||||
@ -913,9 +923,6 @@ abstract class ParserAbstract implements Parser {
|
||||
|
||||
/**
|
||||
* Create a zero-length nop to capture preceding comments, if any.
|
||||
*
|
||||
* @param Comment[] $comments
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function maybeCreateZeroLengthNop(int $tokenPos): ?Nop {
|
||||
$comments = $this->getCommentsBeforeToken($tokenPos);
|
||||
|
@ -254,8 +254,3 @@ parameters:
|
||||
message: "#^Variable \\$action might not be defined\\.$#"
|
||||
count: 1
|
||||
path: lib/PhpParser/ParserAbstract.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$tokenValue might not be defined\\.$#"
|
||||
count: 1
|
||||
path: lib/PhpParser/ParserAbstract.php
|
||||
|
Loading…
x
Reference in New Issue
Block a user