From 34c7c05a35f05695463179fbe3f66fa7edd8ab1f Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Wed, 13 Dec 2023 13:02:30 +0000 Subject: [PATCH] Fix PHP Notice --- .../PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php index 61c45f5e2e..5b029417da 100644 --- a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php @@ -86,7 +86,7 @@ public function process(File $phpcsFile, $stackPtr) } $colon = $phpcsFile->findPrevious(T_COLON, $returnType); - if ($tokens[($colon - 1)]['code'] !== T_CLOSE_PARENTHESIS) { + if (isset($colon, $tokens[($colon - 1)]) === true && $tokens[($colon - 1)]['code'] !== T_CLOSE_PARENTHESIS) { $error = 'There must not be a space before the colon in a return type declaration'; $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($colon - 1), null, true); if ($tokens[$prev]['code'] === T_CLOSE_PARENTHESIS) {