From 0c70d2c566e899666f367ab7b80986beb3581e6f Mon Sep 17 00:00:00 2001 From: Jaapio Date: Wed, 6 Nov 2024 12:58:54 +0100 Subject: [PATCH] Resolve notice on undefined index fixes #384 --- phpstan.neon | 1 + src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index a43a75f3..c2365775 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,5 +2,6 @@ parameters: level: max ignoreErrors: - '#Method phpDocumentor\\Reflection\\DocBlock\\StandardTagFactory::createTag\(\) should return phpDocumentor\\Reflection\\DocBlock\\Tag but returns mixed#' + - '#Offset 2 on array\{string, 28, int\} on left side of \?\? always exists and is not nullable\.#' paths: - src diff --git a/src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php b/src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php index 876d15f1..240e79d9 100644 --- a/src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php +++ b/src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php @@ -104,12 +104,12 @@ private function tokenizeLine(string $tagLine): TokenIterator $fixed[] = [ rtrim($token[Lexer::VALUE_OFFSET], " \t"), Lexer::TOKEN_PHPDOC_EOL, - $token[2], + $token[2] ?? 0, ]; $fixed[] = [ ltrim($token[Lexer::VALUE_OFFSET], "\n\r"), Lexer::TOKEN_HORIZONTAL_WS, - $token[2] + 1, + ($token[2] ?? 0) + 1, ]; continue; }