Skip to content

Commit

Permalink
Fixed bug #2943 : Redundant semicolon added to a file when fixing PSR…
Browse files Browse the repository at this point in the history
…2.Files.ClosingTag.NotAllowed
  • Loading branch information
gsherwood committed May 1, 2020
1 parent 73e2e7f commit 1802f6b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 27 deletions.
30 changes: 5 additions & 25 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,16 @@ http://pear.php.net/dtd/package-2.0.xsd">
<date>2020-04-17</date>
<time>11:07:00</time>
<version>
<release>3.5.5</release>
<api>3.5.5</api>
<release>3.5.6</release>
<api>3.5.6</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
<notes>
- 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
</notes>
<contents>
<dir name="/">
Expand Down Expand Up @@ -1240,6 +1218,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.5.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.6.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.6.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.7.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.7.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.php" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="EndFileNewlineUnitTest.1.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="EndFileNewlineUnitTest.1.inc.fixed" role="test" />
Expand Down
2 changes: 1 addition & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, ';');
}
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function getErrorList($testFile='')
return [1 => 1];

case 'ClosingTagUnitTest.6.inc':
case 'ClosingTagUnitTest.7.inc':
return [5 => 1];

default:
Expand Down

0 comments on commit 1802f6b

Please sign in to comment.