Skip to content

Commit fc6d98a

Browse files
committed
Generic/DisallowSpaceIndent: add test with multi-line yield from
As the indentation whitespace in a multi-line `yield from` expression is now tokenized as `T_WHITESPACE`, instead of being tokenized as part of the (second) `T_YIELD_FROM` token, space indentation of such a line will now be handled correctly by the sniff. This commit just adds a test to confirm and safeguard this.
1 parent 7349295 commit fc6d98a

5 files changed

+29
-0
lines changed

src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.1.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,10 @@ $x = 1;
116116
117117
Another line.
118118
*/
119+
120+
// A `yield from` can be multiline and may contain spaces in the indentation whitespace between the keywords.
121+
function myGenerator() {
122+
yield
123+
from
124+
gen2();
125+
}

src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.1.inc.fixed

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,10 @@ $x = 1;
116116

117117
Another line.
118118
*/
119+
120+
// A `yield from` can be multiline and may contain spaces in the indentation whitespace between the keywords.
121+
function myGenerator() {
122+
yield
123+
from
124+
gen2();
125+
}

src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.2.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,10 @@ $x = 1;
116116
117117
Another line.
118118
*/
119+
120+
// A `yield from` can be multiline and may contain spaces in the indentation whitespace between the keywords.
121+
function myGenerator() {
122+
yield
123+
from
124+
gen2();
125+
}

src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.2.inc.fixed

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,10 @@ $x = 1;
116116

117117
Another line.
118118
*/
119+
120+
// A `yield from` can be multiline and may contain spaces in the indentation whitespace between the keywords.
121+
function myGenerator() {
122+
yield
123+
from
124+
gen2();
125+
}

src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function getErrorList($testFile='')
8989
115 => 1,
9090
117 => 1,
9191
118 => 1,
92+
123 => 1,
9293
];
9394

9495
case 'DisallowSpaceIndentUnitTest.3.inc':

0 commit comments

Comments
 (0)