Skip to content

Commit

Permalink
Fixed bug #3384 : Squiz.Commenting.FileComment.SpacingAfterComment fa…
Browse files Browse the repository at this point in the history
…lse positive on empty file
  • Loading branch information
gsherwood committed Jul 18, 2021
1 parent b6d6556 commit 5fff209
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed bug #3357 : Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present
-- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3362 : Generic.WhiteSpace.ScopeIndent false positive for arrow functions inside arrays
- Fixed bug #3384 : Squiz.Commenting.FileComment.SpacingAfterComment false positive on empty file
</notes>
<contents>
<dir name="/">
Expand Down Expand Up @@ -1640,6 +1641,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.5.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.6.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.7.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.8.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.1.js" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.1.js.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.2.js" role="test" />
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function process(File $phpcsFile, $stackPtr)

// Exactly one blank line after the file comment.
$next = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), null, true);
if ($tokens[$next]['line'] !== ($tokens[$commentEnd]['line'] + 2)) {
if ($next !== false && $tokens[$next]['line'] !== ($tokens[$commentEnd]['line'] + 2)) {
$error = 'There must be exactly one blank line after the file comment';
$phpcsFile->addError($error, $commentEnd, 'SpacingAfterComment');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* File comment.
*
* @package Package
* @subpackage Subpackage
* @author Squiz Pty Ltd <products@squiz.net>
* @copyright 2010-2014 Squiz Pty Ltd (ABN 77 084 670 600)
*/

0 comments on commit 5fff209

Please sign in to comment.