Skip to content

Commit dd0f63b

Browse files
authored
Merge pull request #26 from magento-commerce/imported-magento-magento-coding-standard-220
[Imported] Fix ImportsFromTestNamespace from lock on group use with trailing comma
2 parents bfa1033 + 696c3aa commit dd0f63b

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Magento2/Sniffs/Namespaces/ImportsFromTestNamespaceSniff.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ public function process(File $phpcsFile, $stackPtr)
5757
$closingCurly = $phpcsFile->findNext(T_CLOSE_USE_GROUP, ($next + 1));
5858
do {
5959
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), $closingCurly, true);
60-
$groupedAsContent = $baseUse. $tokens[$next]['content'];
61-
$next = $phpcsFile->findNext(T_COMMA, ($next + 1), $closingCurly);
62-
if (strpos($groupedAsContent, $this->prohibitNamespace) !== false) {
63-
$phpcsFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode);
64-
return;
60+
if ($next !== false) {
61+
$groupedAsContent = $baseUse. $tokens[$next]['content'];
62+
$next = $phpcsFile->findNext(T_COMMA, ($next + 1), $closingCurly);
63+
if (strpos($groupedAsContent, $this->prohibitNamespace) !== false) {
64+
$phpcsFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode);
65+
return;
66+
}
6567
}
6668
} while ($next !== false);
6769
}

Magento2/Tests/Namespaces/ImportsFromTestNamespaceUnitTest.inc

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ use Magento\Tests;
33
use Magento\Foo\Tests as FakeTest;
44
use Magento\Real\Classes;
55
use \Magento\{Tests\String, Tests\Int};
6-
use \Magento\{Foo\string, Bar\float};
6+
use \Magento\{Foo\string, Bar\float};
7+
use \Foo\{Trailing, Space,};

0 commit comments

Comments
 (0)