Skip to content

Commit 1802f6b

Browse files
committed
Fixed bug #2943 : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed
1 parent 73e2e7f commit 1802f6b

File tree

4 files changed

+9
-27
lines changed

4 files changed

+9
-27
lines changed

package.xml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,16 @@ http://pear.php.net/dtd/package-2.0.xsd">
1717
<date>2020-04-17</date>
1818
<time>11:07:00</time>
1919
<version>
20-
<release>3.5.5</release>
21-
<api>3.5.5</api>
20+
<release>3.5.6</release>
21+
<api>3.5.6</api>
2222
</version>
2323
<stability>
2424
<release>stable</release>
2525
<api>stable</api>
2626
</stability>
2727
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
2828
<notes>
29-
- The T_FN backfill now works more reliably so T_FN tokens only ever represent real arrow functions
30-
-- Thanks to Juliette Reinders Folmer for the patch
31-
- Fixed an issue where including sniffs using paths containing multiple dots would silently fail
32-
- Generic.CodeAnalysis.EmptyPHPStatement now detects empty statements at the start of control structures
33-
- Error wording in PEAR.Functions.FunctionCallSignature now always uses "parenthesis" instead of sometimes using "bracket"
34-
-- Thanks to Vincent Langlet for the patch
35-
- Fixed bug #2787 : Squiz.PHP.DisallowMultipleAssignments not ignoring typed property declarations
36-
-- Thanks to Juliette Reinders Folmer for the patch
37-
- Fixed bug #2810 : PHPCBF fails to fix file with empty statement at start on control structure
38-
- Fixed bug #2812 : Squiz.Arrays.ArrayDeclaration not detecting some arrays with multiple arguments on the same line
39-
-- Thanks to Jakub Chábek for the patch
40-
- Fixed bug #2826 : Generic.WhiteSpace.ArbitraryParenthesesSpacing doesn't detect issues for statements directly after a control structure
41-
-- Thanks to Vincent Langlet for the patch
42-
- Fixed bug #2848 : PSR12.Files.FileHeader false positive for file with mixed PHP and HTML and no file header
43-
- Fixed bug #2849 : Generic.WhiteSpace.ScopeIndent false positive with arrow function inside array
44-
- Fixed bug #2850 : Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase
45-
- Fixed bug #2853 : Undefined variable error when using Info report
46-
-- Thanks to Juliette Reinders Folmer for the patch
47-
- Fixed bug #2865 : Double arrow tokenized as T_STRING when placed after function named "fn"
48-
- Fixed bug #2867 : Incorrect scope matching when arrow function used inside IF condition
49-
- Fixed bug #2868 : phpcs:ignore annotation doesnt work inside a docblock
50-
- Fixed bug #2878 : PSR12.Files.FileHeader conflicts with Generic.Files.LineEndings
51-
- Fixed bug #2895 : PSR2.Methods.FunctionCallSignature.MultipleArguments false positive with arrow function argument
29+
- Fixed bug #2943 : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed
5230
</notes>
5331
<contents>
5432
<dir name="/">
@@ -1240,6 +1218,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
12401218
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.5.inc.fixed" role="test" />
12411219
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.6.inc" role="test" />
12421220
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.6.inc.fixed" role="test" />
1221+
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.7.inc" role="test" />
1222+
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.7.inc.fixed" role="test" />
12431223
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagUnitTest.php" role="test" />
12441224
<file baseinstalldir="PHP/CodeSniffer" name="EndFileNewlineUnitTest.1.inc" role="test" />
12451225
<file baseinstalldir="PHP/CodeSniffer" name="EndFileNewlineUnitTest.1.inc.fixed" role="test" />

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Config
7979
*
8080
* @var string
8181
*/
82-
const VERSION = '3.5.5';
82+
const VERSION = '3.5.6';
8383

8484
/**
8585
* Package stability; either stable, beta or alpha.

src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function process(File $phpcsFile, $stackPtr)
6767
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($last - 1), null, true);
6868
if ($tokens[$prev]['code'] !== T_SEMICOLON
6969
&& $tokens[$prev]['code'] !== T_CLOSE_CURLY_BRACKET
70+
&& $tokens[$prev]['code'] !== T_OPEN_TAG
7071
) {
7172
$phpcsFile->fixer->addContent($prev, ';');
7273
}
@@ -77,7 +78,7 @@ public function process(File $phpcsFile, $stackPtr)
7778
$phpcsFile->recordMetric($stackPtr, 'PHP closing tag at end of PHP-only file', 'yes');
7879
} else {
7980
$phpcsFile->recordMetric($stackPtr, 'PHP closing tag at end of PHP-only file', 'no');
80-
}
81+
}//end if
8182

8283
// Ignore the rest of the file.
8384
return $phpcsFile->numTokens;

src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function getErrorList($testFile='')
3636
return [1 => 1];
3737

3838
case 'ClosingTagUnitTest.6.inc':
39+
case 'ClosingTagUnitTest.7.inc':
3940
return [5 => 1];
4041

4142
default:

0 commit comments

Comments
 (0)