Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
coder
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
coder
Commits
74cd8596
Commit
74cd8596
authored
9 years ago
by
Klaus Purer
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2676100
: Fully namespaced function calls are allowed
parent
40ea3357
Branches
Branches containing commit
Tags
8.x-4.11
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php
+7
-0
7 additions, 0 deletions
...er/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php
coder_sniffer/Drupal/Test/good/good.php
+11
-0
11 additions, 0 deletions
coder_sniffer/Drupal/Test/good/good.php
with
18 additions
and
0 deletions
coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php
+
7
−
0
View file @
74cd8596
...
...
@@ -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'
);
...
...
This diff is collapsed.
Click to expand it.
coder_sniffer/Drupal/Test/good/good.php
+
11
−
0
View file @
74cd8596
...
...
@@ -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
,
];
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment