Loading coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php +11 −3 Original line number Diff line number Diff line Loading @@ -66,9 +66,11 @@ class FullyQualifiedNamespaceSniff implements Sniff } // Check if this is a use statement and ignore those. $before = $phpcsFile->findPrevious([T_STRING, T_NS_SEPARATOR, T_WHITESPACE], $stackPtr, null, true); $before = $phpcsFile->findPrevious([T_STRING, T_NS_SEPARATOR, T_WHITESPACE, T_COMMA, T_AS], $stackPtr, null, true); if ($tokens[$before]['code'] === T_USE || $tokens[$before]['code'] === T_NAMESPACE) { return $phpcsFile->findNext([T_STRING, T_NS_SEPARATOR], ($stackPtr + 1), null, true); return $phpcsFile->findNext([T_STRING, T_NS_SEPARATOR, T_WHITESPACE, T_COMMA, T_AS], ($stackPtr + 1), null, true); } else { $before = $phpcsFile->findPrevious([T_STRING, T_NS_SEPARATOR, T_WHITESPACE], $stackPtr, null, true); } // If this is a namespaced function call then ignore this because use Loading Loading @@ -116,6 +118,12 @@ class FullyQualifiedNamespaceSniff implements Sniff } $aliasName = false; // Check if we're currently in a multi-use statement. if ($tokens[$endPtr]['code'] === T_COMMA) { $useStatement = $endPtr; continue; } $useStatement = $phpcsFile->findNext(T_USE, ($endPtr + 1)); }//end while Loading coder_sniffer/Drupal/Test/Classes/FullyQualifiedNamespaceUnitTest.inc +9 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ use Test\Bar; use Test\NotUsed; use Test\Alias as TestAlias; use Test\MultiLine as MultiLineAlias, Test\MultiLineSecond; /** * Example. Loading Loading @@ -63,4 +65,11 @@ class Example { } /** * Description. */ public function test8(Test\MultiLine $multiLine, Test\MultiLineSecond $multiLineSecond) { } } coder_sniffer/Drupal/Test/Classes/FullyQualifiedNamespaceUnitTest.inc.fixed +9 −0 Original line number Diff line number Diff line Loading @@ -5,10 +5,12 @@ * Example. */ use Test\MultiLineSecond; use Test\Foo; use Test\NotUsed; use Test\Bar; use Test\Alias as TestAlias; use Test\MultiLine as MultiLineAlias; /** * Example. Loading Loading @@ -64,4 +66,11 @@ class Example { } /** * Description. */ public function test8(MultiLineAlias $multiLine, MultiLineSecond $multiLineSecond) { } } coder_sniffer/Drupal/Test/Classes/FullyQualifiedNamespaceUnitTest.php +6 −5 Original line number Diff line number Diff line Loading @@ -23,11 +23,12 @@ class FullyQualifiedNamespaceUnitTest extends CoderSniffUnitTest switch ($testFile) { case 'FullyQualifiedNamespaceUnitTest.inc': return [ 27 => 1, 34 => 1, 41 => 1, 55 => 1, 62 => 1, 29 => 1, 36 => 1, 43 => 1, 57 => 1, 64 => 1, 71 => 2, ]; case 'FullyQualifiedNamespaceUnitTest.1.inc': return [16 => 1]; Loading Loading
coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php +11 −3 Original line number Diff line number Diff line Loading @@ -66,9 +66,11 @@ class FullyQualifiedNamespaceSniff implements Sniff } // Check if this is a use statement and ignore those. $before = $phpcsFile->findPrevious([T_STRING, T_NS_SEPARATOR, T_WHITESPACE], $stackPtr, null, true); $before = $phpcsFile->findPrevious([T_STRING, T_NS_SEPARATOR, T_WHITESPACE, T_COMMA, T_AS], $stackPtr, null, true); if ($tokens[$before]['code'] === T_USE || $tokens[$before]['code'] === T_NAMESPACE) { return $phpcsFile->findNext([T_STRING, T_NS_SEPARATOR], ($stackPtr + 1), null, true); return $phpcsFile->findNext([T_STRING, T_NS_SEPARATOR, T_WHITESPACE, T_COMMA, T_AS], ($stackPtr + 1), null, true); } else { $before = $phpcsFile->findPrevious([T_STRING, T_NS_SEPARATOR, T_WHITESPACE], $stackPtr, null, true); } // If this is a namespaced function call then ignore this because use Loading Loading @@ -116,6 +118,12 @@ class FullyQualifiedNamespaceSniff implements Sniff } $aliasName = false; // Check if we're currently in a multi-use statement. if ($tokens[$endPtr]['code'] === T_COMMA) { $useStatement = $endPtr; continue; } $useStatement = $phpcsFile->findNext(T_USE, ($endPtr + 1)); }//end while Loading
coder_sniffer/Drupal/Test/Classes/FullyQualifiedNamespaceUnitTest.inc +9 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ use Test\Bar; use Test\NotUsed; use Test\Alias as TestAlias; use Test\MultiLine as MultiLineAlias, Test\MultiLineSecond; /** * Example. Loading Loading @@ -63,4 +65,11 @@ class Example { } /** * Description. */ public function test8(Test\MultiLine $multiLine, Test\MultiLineSecond $multiLineSecond) { } }
coder_sniffer/Drupal/Test/Classes/FullyQualifiedNamespaceUnitTest.inc.fixed +9 −0 Original line number Diff line number Diff line Loading @@ -5,10 +5,12 @@ * Example. */ use Test\MultiLineSecond; use Test\Foo; use Test\NotUsed; use Test\Bar; use Test\Alias as TestAlias; use Test\MultiLine as MultiLineAlias; /** * Example. Loading Loading @@ -64,4 +66,11 @@ class Example { } /** * Description. */ public function test8(MultiLineAlias $multiLine, MultiLineSecond $multiLineSecond) { } }
coder_sniffer/Drupal/Test/Classes/FullyQualifiedNamespaceUnitTest.php +6 −5 Original line number Diff line number Diff line Loading @@ -23,11 +23,12 @@ class FullyQualifiedNamespaceUnitTest extends CoderSniffUnitTest switch ($testFile) { case 'FullyQualifiedNamespaceUnitTest.inc': return [ 27 => 1, 34 => 1, 41 => 1, 55 => 1, 62 => 1, 29 => 1, 36 => 1, 43 => 1, 57 => 1, 64 => 1, 71 => 2, ]; case 'FullyQualifiedNamespaceUnitTest.1.inc': return [16 => 1]; Loading