Skip to content
Snippets Groups Projects
Commit 74cd8596 authored by Klaus Purer's avatar Klaus Purer
Browse files

Issue #2676100: Fully namespaced function calls are allowed

parent 40ea3357
Branches
Tags 8.x-4.11
No related merge requests found
......@@ -68,6 +68,13 @@ class Drupal_Sniffs_Classes_FullyQualifiedNamespaceSniff implements PHP_CodeSnif
return $phpcsFile->findNext([T_STRING, T_NS_SEPARATOR], ($stackPtr + 1), null, true);
}
// If this is a namespaced function call then ignore this because use
// statements for functions are not possible in PHP 5.5 and lower.
$after = $phpcsFile->findNext([T_STRING, T_NS_SEPARATOR, T_WHITESPACE], $stackPtr, null, true);
if ($tokens[$after]['code'] === T_OPEN_PARENTHESIS && $tokens[$before]['code'] !== T_NEW) {
return ($after + 1);
}
$error = 'Namespaced classes/interfaces/traits should be referenced with use statements';
$phpcsFile->addError($error, $stackPtr, 'UseStatementMissing');
......
......@@ -1243,3 +1243,14 @@ class OperatorTest {
}
}
// Namespaced function call is allowed because PHP 5.5 and lower do not support
// use statements for functions.
$default_config = [
'verify' => TRUE,
'timeout' => 30,
'headers' => [
'User-Agent' => 'Drupal/' . \Drupal::VERSION . ' (+https://www.drupal.org/) ' . \GuzzleHttp\default_user_agent(),
],
'handler' => $stack,
];
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment