Skip to content

Commit 716b619

Browse files
committed
Fixed bug #2619 : PSR12.Files.FileHeader locks up when inline comment is the last content in a file
1 parent a81e341 commit 716b619

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

package.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
2727
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
2828
<notes>
2929
- Fixed bug #2615 : Constant visibility false positive on non-class constants
30+
- Fixed bug #2619 : PSR12.Files.FileHeader locks up when inline comment is the last content in a file
3031
</notes>
3132
<contents>
3233
<dir name="/">
@@ -1055,6 +1056,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
10551056
<file baseinstalldir="PHP/CodeSniffer" name="FileHeaderUnitTest.4.inc.fixed" role="test" />
10561057
<file baseinstalldir="PHP/CodeSniffer" name="FileHeaderUnitTest.5.inc" role="test" />
10571058
<file baseinstalldir="PHP/CodeSniffer" name="FileHeaderUnitTest.6.inc" role="test" />
1059+
<file baseinstalldir="PHP/CodeSniffer" name="FileHeaderUnitTest.7.inc" role="test" />
10581060
<file baseinstalldir="PHP/CodeSniffer" name="FileHeaderUnitTest.php" role="test" />
10591061
<file baseinstalldir="PHP/CodeSniffer" name="ImportStatementUnitTest.inc" role="test" />
10601062
<file baseinstalldir="PHP/CodeSniffer" name="ImportStatementUnitTest.php" role="test" />

src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function process(File $phpcsFile, $stackPtr)
130130
}//end switch
131131

132132
$next = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true);
133-
} while ($next !== false);
133+
} while ($next !== false && ($next !== $phpcsFile->numTokens - 1));
134134

135135
if (count($headerLines) === 1) {
136136
// This is only an open tag and doesn't contain the file header.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
// Do nothing

0 commit comments

Comments
 (0)