Skip to content

Commit 900d377

Browse files
committed
Merge branch 'feature/squiz-blockcomment-check-short-echo-tag' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents 52f440f + 93306f5 commit 900d377

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ public function process(File $phpcsFile, $stackPtr)
363363
if ((isset($tokens[$contentBefore]['scope_closer']) === true
364364
&& $tokens[$contentBefore]['scope_opener'] === $contentBefore)
365365
|| $tokens[$contentBefore]['code'] === T_OPEN_TAG
366+
|| $tokens[$contentBefore]['code'] === T_OPEN_TAG_WITH_ECHO
366367
) {
367368
if (($tokens[$stackPtr]['line'] - $tokens[$contentBefore]['line']) !== 1) {
368369
$error = 'Empty line not required before block comment';

src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,19 @@ $y = 10 + /* test */ -2;
256256
/*
257257
* No blank line allowed above the comment if it's the first non-empty token after a PHP open tag.
258258
*/
259+
260+
?>
261+
<?=
262+
/*
263+
* No blank line required above the comment if it's the first non-empty token after a PHP open tag.
264+
*/
265+
266+
$contentToEcho
267+
?>
268+
<?=
269+
270+
271+
/*
272+
* No blank line allowed above the comment if it's the first non-empty token after a PHP open tag.
273+
*/
274+
$contentToEcho

src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc.fixed

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,19 @@ $y = 10 + /* test */ -2;
258258
/*
259259
* No blank line allowed above the comment if it's the first non-empty token after a PHP open tag.
260260
*/
261+
262+
?>
263+
<?=
264+
/*
265+
* No blank line required above the comment if it's the first non-empty token after a PHP open tag.
266+
*/
267+
268+
$contentToEcho
269+
?>
270+
<?=
271+
272+
273+
/*
274+
* No blank line allowed above the comment if it's the first non-empty token after a PHP open tag.
275+
*/
276+
$contentToEcho

src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public function getErrorList()
7777
232 => 1,
7878
233 => 1,
7979
256 => 1,
80+
271 => 1,
81+
273 => 1,
8082
];
8183

8284
return $errors;

0 commit comments

Comments
 (0)