From b5110320821602f7222c3c7fd6750ecff6afdf74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Tue, 31 Jul 2018 20:59:38 +0000 Subject: [PATCH] NoSuperfluousPhpdocTagsFixer - Index invalid or out of range --- src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php | 2 +- tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php b/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php index 0e33766a8c7..f7fda46c5b7 100644 --- a/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php +++ b/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php @@ -139,7 +139,7 @@ private function findDocumentedFunction(Tokens $tokens, $index) do { $index = $tokens->getNextMeaningfulToken($index); - if ($tokens[$index]->isGivenKind(T_FUNCTION)) { + if (null === $index || $tokens[$index]->isGivenKind(T_FUNCTION)) { return $index; } } while ($tokens[$index]->isGivenKind([T_ABSTRACT, T_FINAL, T_STATIC, T_PRIVATE, T_PROTECTED, T_PUBLIC])); diff --git a/tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php b/tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php index 3e71c26ee08..f3e9cab92b5 100644 --- a/tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php +++ b/tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php @@ -264,6 +264,12 @@ class Foo { public function doFoo(array $bar, callable $baz) {} }', ], + 'PHPDoc at the end of file' => [ + '