Skip to content

Commit 382b6a9

Browse files
committed
Generic/ScopeIndent: add extra test with multi-token "yield from"
This confirms that the Tokenizer changes related to `yield from` tokenization which were made in a previous commit also fix issue squizlabs/PHP_CodeSniffer 3808, as reported upstream. Closes squizlabs/PHP_CodeSniffer 3808 Includes moving the `phpcs:set` directives in test case file 3 to inside the PHP tags to make the tests reproducable when doing a plain `phpcs` run against the file.
1 parent ff306f2 commit 382b6a9

File tree

7 files changed

+45
-8
lines changed

7 files changed

+45
-8
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,12 @@ match (true) {
16141614
]
16151615
};
16161616

1617+
// Issue squizlabs/PHP_CodeSniffer#3808
1618+
function test() {
1619+
yield
1620+
from [ 3, 4 ];
1621+
}
1622+
16171623
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
16181624
?>
16191625

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,12 @@ match (true) {
16141614
]
16151615
};
16161616

1617+
// Issue squizlabs/PHP_CodeSniffer#3808
1618+
function test() {
1619+
yield
1620+
from [ 3, 4 ];
1621+
}
1622+
16171623
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
16181624
?>
16191625

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,12 @@ match (true) {
16141614
]
16151615
};
16161616

1617+
// Issue squizlabs/PHP_CodeSniffer#3808
1618+
function test() {
1619+
yield
1620+
from [ 3, 4 ];
1621+
}
1622+
16171623
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
16181624
?>
16191625

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,12 @@ match (true) {
16141614
]
16151615
};
16161616

1617+
// Issue squizlabs/PHP_CodeSniffer#3808
1618+
function test() {
1619+
yield
1620+
from [ 3, 4 ];
1621+
}
1622+
16171623
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
16181624
?>
16191625

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.3.inc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
phpcs:set Generic.WhiteSpace.ScopeIndent tabIndent false
2-
phpcs:set Generic.WhiteSpace.ScopeIndent exact true
31
<?php
2+
// phpcs:set Generic.WhiteSpace.ScopeIndent tabIndent false
3+
// phpcs:set Generic.WhiteSpace.ScopeIndent exact true
44
function test()
55
{
66
echo 'test';
@@ -26,3 +26,9 @@ if ($foo) {
2626
$this->foo()
2727
->bar()
2828
->baz();
29+
30+
// Issue squizlabs/PHP_CodeSniffer#3808
31+
function test() {
32+
yield
33+
from [ 3, 4 ];
34+
}

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.3.inc.fixed

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
phpcs:set Generic.WhiteSpace.ScopeIndent tabIndent false
2-
phpcs:set Generic.WhiteSpace.ScopeIndent exact true
31
<?php
2+
// phpcs:set Generic.WhiteSpace.ScopeIndent tabIndent false
3+
// phpcs:set Generic.WhiteSpace.ScopeIndent exact true
44
function test()
55
{
66
echo 'test';
@@ -26,3 +26,9 @@ if ($foo) {
2626
$this->foo()
2727
->bar()
2828
->baz();
29+
30+
// Issue squizlabs/PHP_CodeSniffer#3808
31+
function test() {
32+
yield
33+
from [ 3, 4 ];
34+
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function getErrorList($testFile='')
8484
6 => 1,
8585
7 => 1,
8686
10 => 1,
87+
33 => 1,
8788
];
8889
}
8990

@@ -192,10 +193,10 @@ public function getErrorList($testFile='')
192193
1527 => 1,
193194
1529 => 1,
194195
1530 => 1,
195-
1625 => 1,
196-
1626 => 1,
197-
1627 => 1,
198-
1628 => 1,
196+
1631 => 1,
197+
1632 => 1,
198+
1633 => 1,
199+
1634 => 1,
199200
];
200201

201202
}//end getErrorList()

0 commit comments

Comments
 (0)