Skip to content

Commit 1016d40

Browse files
committed
Squiz/EmbeddedPhp: document the behaviour for closed tag block at end of file [2]
The last tag block in a file will **not** be ignored if it is followed by non-empty inline HTML. These tests document this behaviour.
1 parent f2c3f47 commit 1016d40

9 files changed

+132
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
// This test case file MUST always start with a long open PHP tag set (with this comment) to prevent
3+
// the tests running into the "first PHP open tag excepted" condition breaking the tests.
4+
// Tests related to that "first PHP open tag excepted" condition should go in separate files.
5+
?>
6+
<!--
7+
The complete tag block will **NOT** be ignored when it is the last (closed) tag block in a file
8+
as long as it is followed by non-empty inline HTML.
9+
-->
10+
<div>
11+
<?php
12+
?>
13+
14+
</div>
15+
<p>Some more content after the last PHP tag block.</p>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
// This test case file MUST always start with a long open PHP tag set (with this comment) to prevent
3+
// the tests running into the "first PHP open tag excepted" condition breaking the tests.
4+
// Tests related to that "first PHP open tag excepted" condition should go in separate files.
5+
?>
6+
<!--
7+
The complete tag block will **NOT** be ignored when it is the last (closed) tag block in a file
8+
as long as it is followed by non-empty inline HTML.
9+
-->
10+
<div>
11+
12+
</div>
13+
<p>Some more content after the last PHP tag block.</p>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
// This test case file MUST always start with a long open PHP tag set (with this comment) to prevent
3+
// the tests running into the "first PHP open tag excepted" condition breaking the tests.
4+
// Tests related to that "first PHP open tag excepted" condition should go in separate files.
5+
?>
6+
<!--
7+
The complete tag block will **NOT** be ignored when it is the last (closed) tag block in a file
8+
as long as it is followed by non-empty inline HTML.
9+
10+
Note: with short open tags, the empty PHP tag set is a parse error.
11+
-->
12+
<div>
13+
<?=
14+
?>
15+
16+
</div>
17+
<p>Some more content after the last PHP tag block.</p>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
// This test case file MUST always start with a long open PHP tag set (with this comment) to prevent
3+
// the tests running into the "first PHP open tag excepted" condition breaking the tests.
4+
// Tests related to that "first PHP open tag excepted" condition should go in separate files.
5+
?>
6+
<!--
7+
The complete tag block will **NOT** be ignored when it is the last (closed) tag block in a file
8+
as long as it is followed by non-empty inline HTML.
9+
10+
Note: with short open tags, the empty PHP tag set is a parse error.
11+
-->
12+
<div>
13+
14+
</div>
15+
<p>Some more content after the last PHP tag block.</p>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
// This test case file MUST always start with a long open PHP tag set (with this comment) to prevent
3+
// the tests running into the "first PHP open tag excepted" condition breaking the tests.
4+
// Tests related to that "first PHP open tag excepted" condition should go in separate files.
5+
?>
6+
<!--
7+
The complete tag block will **NOT** be ignored when it is the last (closed) tag block in a file
8+
as long as it is followed by non-empty inline HTML.
9+
-->
10+
<div>
11+
<?php
12+
echo 'too much indent and close tag not on own line'; ?>
13+
14+
</div>
15+
<p>Some more content after the last PHP tag block.</p>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
// This test case file MUST always start with a long open PHP tag set (with this comment) to prevent
3+
// the tests running into the "first PHP open tag excepted" condition breaking the tests.
4+
// Tests related to that "first PHP open tag excepted" condition should go in separate files.
5+
?>
6+
<!--
7+
The complete tag block will **NOT** be ignored when it is the last (closed) tag block in a file
8+
as long as it is followed by non-empty inline HTML.
9+
-->
10+
<div>
11+
<?php
12+
echo 'too much indent and close tag not on own line';
13+
?>
14+
15+
</div>
16+
<p>Some more content after the last PHP tag block.</p>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
// This test case file MUST always start with a long open PHP tag set (with this comment) to prevent
3+
// the tests running into the "first PHP open tag excepted" condition breaking the tests.
4+
// Tests related to that "first PHP open tag excepted" condition should go in separate files.
5+
?>
6+
<!--
7+
The complete tag block will **NOT** be ignored when it is the last (closed) tag block in a file
8+
as long as it is followed by non-empty inline HTML.
9+
-->
10+
<div>
11+
<?=
12+
'too much indent and close tag not on own line'; ?>
13+
14+
</div>
15+
<p>Some more content after the last PHP tag block.</p>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
// This test case file MUST always start with a long open PHP tag set (with this comment) to prevent
3+
// the tests running into the "first PHP open tag excepted" condition breaking the tests.
4+
// Tests related to that "first PHP open tag excepted" condition should go in separate files.
5+
?>
6+
<!--
7+
The complete tag block will **NOT** be ignored when it is the last (closed) tag block in a file
8+
as long as it is followed by non-empty inline HTML.
9+
-->
10+
<div>
11+
<?=
12+
'too much indent and close tag not on own line';
13+
?>
14+
15+
</div>
16+
<p>Some more content after the last PHP tag block.</p>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ public function getErrorList($testFile='')
158158
12 => 1,
159159
];
160160

161+
case 'EmbeddedPhpUnitTest.18.inc':
162+
return [11 => 1];
163+
164+
case 'EmbeddedPhpUnitTest.19.inc':
165+
return [13 => 1];
166+
167+
case 'EmbeddedPhpUnitTest.20.inc':
168+
case 'EmbeddedPhpUnitTest.21.inc':
169+
return [12 => 2];
170+
161171
default:
162172
return [];
163173
}//end switch

0 commit comments

Comments
 (0)