Skip to content

Commit

Permalink
Merge branch 'feature/squiz-blockcomment-noblankline-after-php-open-t…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Apr 16, 2019
2 parents e1dcba4 + 134134e commit 4abd43e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ public function process(File $phpcsFile, $stackPtr)

// Check that the lines before and after this comment are blank.
$contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
if (isset($tokens[$contentBefore]['scope_closer']) === true
&& $tokens[$contentBefore]['scope_opener'] === $contentBefore
if ((isset($tokens[$contentBefore]['scope_closer']) === true
&& $tokens[$contentBefore]['scope_opener'] === $contentBefore)
|| $tokens[$contentBefore]['code'] === T_OPEN_TAG
) {
if (($tokens[$stackPtr]['line'] - $tokens[$contentBefore]['line']) !== 1) {
$error = 'Empty line not required before block comment';
Expand Down
14 changes: 14 additions & 0 deletions src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,17 @@ $y = 10 + /* test */ -2;
* See: {@link https://github.com/squizlabs/PHP_CodeSniffer/issues/1918}
* @phpcs:disable Standard.Category.Sniff
*/

?>
<?php
/*
* No blank line required above the comment if it's the first non-empty token after a PHP open tag.
*/

?>
<?php


/*
* No blank line allowed above the comment if it's the first non-empty token after a PHP open tag.
*/
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,17 @@ $y = 10 + /* test */ -2;
* See: {@link https://github.com/squizlabs/PHP_CodeSniffer/issues/1918}
* @phpcs:disable Standard.Category.Sniff
*/

?>
<?php
/*
* No blank line required above the comment if it's the first non-empty token after a PHP open tag.
*/

?>
<?php


/*
* No blank line allowed above the comment if it's the first non-empty token after a PHP open tag.
*/
2 changes: 2 additions & 0 deletions src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function setCliValues($testFile, $config)
public function getErrorList()
{
$errors = [
3 => 1,
8 => 1,
20 => 1,
24 => 1,
Expand Down Expand Up @@ -75,6 +76,7 @@ public function getErrorList()
227 => 1,
232 => 1,
233 => 1,
256 => 1,
];

return $errors;
Expand Down

0 comments on commit 4abd43e

Please sign in to comment.