Loading coder_sniffer/Drupal/Sniffs/Arrays/ArraySniff.php +9 −1 Original line number Diff line number Diff line Loading @@ -180,8 +180,16 @@ class ArraySniff implements Sniff // in other sniffs. If the conditions of a token are different it // means that it is in a different nesting level. if ($tokens[$newLineStart]['conditions'] !== $tokens[$stackPtr]['conditions']) { // Jump to the end of the closure. $conditionKeys = array_keys($tokens[$newLineStart]['conditions']); $closureToken = end($conditionKeys); if (isset($tokens[$closureToken]['scope_closer']) === true) { $newLineStart = $tokens[$closureToken]['scope_closer']; $currentLine = $tokens[$closureToken]['line']; } else { $currentLine++; } } }//end while if ($newLineStart === $tokens[$stackPtr][$parenthesisCloser]) { Loading coder_sniffer/Drupal/Test/Arrays/ArrayUnitTest.inc +15 −0 Original line number Diff line number Diff line Loading @@ -109,3 +109,18 @@ $backend->expects($this->exactly(1)) 'module_handler_test_missing' => [], ]]] )); /** * Nested closure in an array should not throw errors. */ function mymodule_libraries_info() { $libraries['some-library'] = array( 'xautoload' => function ($adapter) { /** @var \Drupal\xautoload\Adapter\LocalDirectoryAdapter $adapter */ // Scan sites/all/libraries/some-library/composer.json to look for // autoload information. $adapter->composerJson('composer.json'); }, ); return $libraries; } coder_sniffer/Drupal/Test/Arrays/ArrayUnitTest.inc.fixed +15 −0 Original line number Diff line number Diff line Loading @@ -116,3 +116,18 @@ $backend->expects($this->exactly(1)) ], ] )); /** * Nested closure in an array should not throw errors. */ function mymodule_libraries_info() { $libraries['some-library'] = array( 'xautoload' => function ($adapter) { /** @var \Drupal\xautoload\Adapter\LocalDirectoryAdapter $adapter */ // Scan sites/all/libraries/some-library/composer.json to look for // autoload information. $adapter->composerJson('composer.json'); }, ); return $libraries; } Loading
coder_sniffer/Drupal/Sniffs/Arrays/ArraySniff.php +9 −1 Original line number Diff line number Diff line Loading @@ -180,8 +180,16 @@ class ArraySniff implements Sniff // in other sniffs. If the conditions of a token are different it // means that it is in a different nesting level. if ($tokens[$newLineStart]['conditions'] !== $tokens[$stackPtr]['conditions']) { // Jump to the end of the closure. $conditionKeys = array_keys($tokens[$newLineStart]['conditions']); $closureToken = end($conditionKeys); if (isset($tokens[$closureToken]['scope_closer']) === true) { $newLineStart = $tokens[$closureToken]['scope_closer']; $currentLine = $tokens[$closureToken]['line']; } else { $currentLine++; } } }//end while if ($newLineStart === $tokens[$stackPtr][$parenthesisCloser]) { Loading
coder_sniffer/Drupal/Test/Arrays/ArrayUnitTest.inc +15 −0 Original line number Diff line number Diff line Loading @@ -109,3 +109,18 @@ $backend->expects($this->exactly(1)) 'module_handler_test_missing' => [], ]]] )); /** * Nested closure in an array should not throw errors. */ function mymodule_libraries_info() { $libraries['some-library'] = array( 'xautoload' => function ($adapter) { /** @var \Drupal\xautoload\Adapter\LocalDirectoryAdapter $adapter */ // Scan sites/all/libraries/some-library/composer.json to look for // autoload information. $adapter->composerJson('composer.json'); }, ); return $libraries; }
coder_sniffer/Drupal/Test/Arrays/ArrayUnitTest.inc.fixed +15 −0 Original line number Diff line number Diff line Loading @@ -116,3 +116,18 @@ $backend->expects($this->exactly(1)) ], ] )); /** * Nested closure in an array should not throw errors. */ function mymodule_libraries_info() { $libraries['some-library'] = array( 'xautoload' => function ($adapter) { /** @var \Drupal\xautoload\Adapter\LocalDirectoryAdapter $adapter */ // Scan sites/all/libraries/some-library/composer.json to look for // autoload information. $adapter->composerJson('composer.json'); }, ); return $libraries; }