Skip to content

Commit

Permalink
Fixed bug #2619 : PSR12.Files.FileHeader locks up when inline comment…
Browse files Browse the repository at this point in the history
… is the last content in a file
  • Loading branch information
gsherwood committed Oct 1, 2019
1 parent a81e341 commit 716b619
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
<notes>
- Fixed bug #2615 : Constant visibility false positive on non-class constants
- Fixed bug #2619 : PSR12.Files.FileHeader locks up when inline comment is the last content in a file
</notes>
<contents>
<dir name="/">
Expand Down Expand Up @@ -1055,6 +1056,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file baseinstalldir="PHP/CodeSniffer" name="FileHeaderUnitTest.4.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="FileHeaderUnitTest.5.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="FileHeaderUnitTest.6.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="FileHeaderUnitTest.7.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="FileHeaderUnitTest.php" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ImportStatementUnitTest.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ImportStatementUnitTest.php" role="test" />
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function process(File $phpcsFile, $stackPtr)
}//end switch

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

if (count($headerLines) === 1) {
// This is only an open tag and doesn't contain the file header.
Expand Down
2 changes: 2 additions & 0 deletions src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.7.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Do nothing

0 comments on commit 716b619

Please sign in to comment.