From 1802f6b3827b66dc392219fdba27dadd2cd7d057 Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Fri, 1 May 2020 13:07:36 +1000 Subject: [PATCH] Fixed bug #2943 : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed --- package.xml | 30 ++++--------------- src/Config.php | 2 +- .../PSR2/Sniffs/Files/ClosingTagSniff.php | 3 +- .../PSR2/Tests/Files/ClosingTagUnitTest.php | 1 + 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/package.xml b/package.xml index 4aa78f788a..dd161175ae 100644 --- a/package.xml +++ b/package.xml @@ -17,8 +17,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> 2020-04-17 - 3.5.5 - 3.5.5 + 3.5.6 + 3.5.6 stable @@ -26,29 +26,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> BSD 3-Clause License - - The T_FN backfill now works more reliably so T_FN tokens only ever represent real arrow functions - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed an issue where including sniffs using paths containing multiple dots would silently fail - - Generic.CodeAnalysis.EmptyPHPStatement now detects empty statements at the start of control structures - - Error wording in PEAR.Functions.FunctionCallSignature now always uses "parenthesis" instead of sometimes using "bracket" - -- Thanks to Vincent Langlet for the patch - - Fixed bug #2787 : Squiz.PHP.DisallowMultipleAssignments not ignoring typed property declarations - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2810 : PHPCBF fails to fix file with empty statement at start on control structure - - Fixed bug #2812 : Squiz.Arrays.ArrayDeclaration not detecting some arrays with multiple arguments on the same line - -- Thanks to Jakub Chábek for the patch - - Fixed bug #2826 : Generic.WhiteSpace.ArbitraryParenthesesSpacing doesn't detect issues for statements directly after a control structure - -- Thanks to Vincent Langlet for the patch - - Fixed bug #2848 : PSR12.Files.FileHeader false positive for file with mixed PHP and HTML and no file header - - Fixed bug #2849 : Generic.WhiteSpace.ScopeIndent false positive with arrow function inside array - - Fixed bug #2850 : Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase - - Fixed bug #2853 : Undefined variable error when using Info report - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2865 : Double arrow tokenized as T_STRING when placed after function named "fn" - - Fixed bug #2867 : Incorrect scope matching when arrow function used inside IF condition - - Fixed bug #2868 : phpcs:ignore annotation doesnt work inside a docblock - - Fixed bug #2878 : PSR12.Files.FileHeader conflicts with Generic.Files.LineEndings - - Fixed bug #2895 : PSR2.Methods.FunctionCallSignature.MultipleArguments false positive with arrow function argument + - Fixed bug #2943 : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed @@ -1240,6 +1218,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + diff --git a/src/Config.php b/src/Config.php index 23b327f9e5..74198153cd 100644 --- a/src/Config.php +++ b/src/Config.php @@ -79,7 +79,7 @@ class Config * * @var string */ - const VERSION = '3.5.5'; + const VERSION = '3.5.6'; /** * Package stability; either stable, beta or alpha. diff --git a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php index 853a3a5b6c..39834b3869 100644 --- a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php @@ -67,6 +67,7 @@ public function process(File $phpcsFile, $stackPtr) $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($last - 1), null, true); if ($tokens[$prev]['code'] !== T_SEMICOLON && $tokens[$prev]['code'] !== T_CLOSE_CURLY_BRACKET + && $tokens[$prev]['code'] !== T_OPEN_TAG ) { $phpcsFile->fixer->addContent($prev, ';'); } @@ -77,7 +78,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->recordMetric($stackPtr, 'PHP closing tag at end of PHP-only file', 'yes'); } else { $phpcsFile->recordMetric($stackPtr, 'PHP closing tag at end of PHP-only file', 'no'); - } + }//end if // Ignore the rest of the file. return $phpcsFile->numTokens; diff --git a/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php b/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php index 41fa148cbb..619f024918 100644 --- a/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php +++ b/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php @@ -36,6 +36,7 @@ public function getErrorList($testFile='') return [1 => 1]; case 'ClosingTagUnitTest.6.inc': + case 'ClosingTagUnitTest.7.inc': return [5 => 1]; default: