Skip to content

Commit 132d641

Browse files
committed
Merge branch 'master' into 3.0
2 parents fa2e8af + 22b8abb commit 132d641

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
3838
- Added more guard code for syntax errors to various sniffs
3939
- Squiz CommentedOutCodeSniff is now better at ignoring URLs inside comments
4040
- Fixed bug #584 : Squiz.Arrays.ArrayDeclaration sniff gives incorrect NoComma error for multiline string values
41+
- Fixed bug #592 : USE statement tokenising can sometimes result in mismatched scopes
4142
- Fixed bug #594 : Tokenizer issue on closure that returns by reference
4243
</notes>
4344
<contents>

src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.inc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,18 @@ switch (true) {
8888
return null;
8989
}
9090
}
91-
?>
91+
92+
use Vendor\Test\FooBar;
93+
94+
function test()
95+
{
96+
switch ($val) {
97+
case 'foo':
98+
echo 'foo';
99+
break;
100+
default:
101+
echo 'foo';
102+
}
103+
104+
exit;
105+
}

src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.inc.fixed

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,18 @@ switch (true) {
8888
return null;
8989
}
9090
}
91-
?>
91+
92+
use Vendor\Test\FooBar;
93+
94+
function test()
95+
{
96+
switch ($val) {
97+
case 'foo':
98+
echo 'foo';
99+
break;
100+
default:
101+
echo 'foo';
102+
}
103+
104+
exit;
105+
}

src/Tokenizers/Tokenizer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,14 @@ private function createScopeMap()
451451
echo "\tStart scope map at $i:$type => $content".PHP_EOL;
452452
}
453453

454+
if (isset($this->tokens[$i]['scope_condition']) === true) {
455+
if (PHP_CODESNIFFER_VERBOSITY > 1) {
456+
echo "\t* already processed, skipping *".PHP_EOL;
457+
}
458+
459+
continue;
460+
}
461+
454462
$i = $this->recurseScopeMap($i);
455463
}//end if
456464
}//end for

0 commit comments

Comments
 (0)