Skip to content

Commit 1e64373

Browse files
committed
Squiz/EmbeddedPhp: add tests safeguarding that single line embedded PHP blocks are never ignored
The exception conditions for the first/last tag set only apply to multi-line PHP blocks and PHP blocks without a closing tag. Single-line embedded PHP with a complete set of tags should not be affected. This is already handled correctly. This commit just adds tests to safeguard this.
1 parent b166d65 commit 1e64373

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!--
2+
Test file safeguarding that if a file only contains single line embedded statements with a complete set of tags,
3+
these will always be examined and that the special casing of the first/last PHP block does not apply.
4+
-->
5+
<?php if ($var) { ?>
6+
<?php echo $var ?>
7+
<?php } ?>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!--
2+
Test file safeguarding that if a file only contains single line embedded statements with a complete set of tags,
3+
these will always be examined and that the special casing of the first/last PHP block does not apply.
4+
-->
5+
<?php if ($var) { ?>
6+
<?php echo $var; ?>
7+
<?php } ?>

src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ public function getErrorList($testFile='')
8686
181 => 1,
8787
];
8888

89+
case 'EmbeddedPhpUnitTest.2.inc':
90+
return [
91+
5 => 2,
92+
6 => 2,
93+
7 => 2,
94+
];
95+
8996
default:
9097
return [];
9198
}//end switch

0 commit comments

Comments
 (0)