Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
coder-3433266
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
coder-3433266
Commits
c835ff5c
"README.md" did not exist on "3c5abe4"
Commit
c835ff5c
authored
8 years ago
by
Klaus Purer
Browse files
Options
Downloads
Patches
Plain Diff
chore(ScopeIndentSniff): Backport anonymous classes support from upstream PHPCS
parent
2e7f3cf9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php
+32
-11
32 additions, 11 deletions
coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php
with
32 additions
and
11 deletions
coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php
+
32
−
11
View file @
c835ff5c
...
...
@@ -223,9 +223,7 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
&&
$tokens
[
$checkToken
][
'code'
]
===
T_CLOSE_PARENTHESIS
&&
isset
(
$tokens
[
$checkToken
][
'parenthesis_opener'
])
===
true
)
||
(
$tokens
[
$i
][
'code'
]
===
T_CLOSE_PARENTHESIS
&&
isset
(
$tokens
[
$i
][
'parenthesis_opener'
])
===
true
&&
isset
(
$tokens
[
$i
][
'parenthesis_owner'
])
===
true
&&
$tokens
[
$tokens
[
$i
][
'parenthesis_owner'
]][
'code'
]
===
T_ARRAY
)
&&
isset
(
$tokens
[
$i
][
'parenthesis_opener'
])
===
true
)
)
{
if
(
$checkToken
!==
null
)
{
$parenCloser
=
$checkToken
;
...
...
@@ -283,7 +281,26 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
$exact
=
false
;
if
(
$condition
>
0
$lastOpenTagConditions
=
array_keys
(
$tokens
[
$lastOpenTag
][
'conditions'
]);
$lastOpenTagCondition
=
array_pop
(
$lastOpenTagConditions
);
if
(
$condition
>
0
&&
$lastOpenTagCondition
===
$condition
)
{
if
(
$this
->
_debug
===
true
)
{
echo
"
\t
* open tag is inside condition; using open tag *"
.
PHP_EOL
;
}
$checkIndent
=
(
$tokens
[
$lastOpenTag
][
'column'
]
-
1
);
if
(
isset
(
$adjustments
[
$condition
])
===
true
)
{
$checkIndent
+=
$adjustments
[
$condition
];
}
$currentIndent
=
$checkIndent
;
if
(
$this
->
_debug
===
true
)
{
$type
=
$tokens
[
$lastOpenTag
][
'type'
];
echo
"
\t
=> checking indent of
$checkIndent
; main indent set to
$currentIndent
by token
$lastOpenTag
(
$type
)"
.
PHP_EOL
;
}
}
else
if
(
$condition
>
0
&&
isset
(
$tokens
[
$condition
][
'scope_opener'
])
===
true
&&
isset
(
$setIndents
[
$tokens
[
$condition
][
'scope_opener'
]])
===
true
)
{
...
...
@@ -990,13 +1007,14 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
continue
;
}
//end if
//
Closure
s set the indent based on their own indent level.
if
(
$tokens
[
$i
][
'code'
]
===
T_CLOSURE
)
{
//
Anon classes and function
s set the indent based on their own indent level.
if
(
$tokens
[
$i
][
'code'
]
===
T_CLOSURE
||
$tokens
[
$i
][
'code'
]
===
T_ANON_CLASS
)
{
$closer
=
$tokens
[
$i
][
'scope_closer'
];
if
(
$tokens
[
$i
][
'line'
]
===
$tokens
[
$closer
][
'line'
])
{
if
(
$this
->
_debug
===
true
)
{
$type
=
str_replace
(
'_'
,
' '
,
strtolower
(
substr
(
$tokens
[
$i
][
'type'
],
2
)));
$line
=
$tokens
[
$i
][
'line'
];
echo
"* ignoring single-line
closur
e on line
$line
"
.
PHP_EOL
;
echo
"* ignoring single-line
$typ
e
on line
$line
"
.
PHP_EOL
;
}
$i
=
$closer
;
...
...
@@ -1004,8 +1022,9 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
}
if
(
$this
->
_debug
===
true
)
{
$type
=
str_replace
(
'_'
,
' '
,
strtolower
(
substr
(
$tokens
[
$i
][
'type'
],
2
)));
$line
=
$tokens
[
$i
][
'line'
];
echo
"Open
closur
e on line
$line
"
.
PHP_EOL
;
echo
"Open
$typ
e
on line
$line
"
.
PHP_EOL
;
}
$first
=
$phpcsFile
->
findFirstOnLine
(
T_WHITESPACE
,
$i
,
true
);
...
...
@@ -1106,14 +1125,16 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
continue
;
}
//end if
// Closing a
closure
.
// Closing a
n anon class or function
.
if
(
isset
(
$tokens
[
$i
][
'scope_condition'
])
===
true
&&
$tokens
[
$i
][
'scope_closer'
]
===
$i
&&
$tokens
[
$tokens
[
$i
][
'scope_condition'
]][
'code'
]
===
T_CLOSURE
&&
(
$tokens
[
$tokens
[
$i
][
'scope_condition'
]][
'code'
]
===
T_CLOSURE
||
$tokens
[
$tokens
[
$i
][
'scope_condition'
]][
'code'
]
===
T_ANON_CLASS
)
)
{
if
(
$this
->
_debug
===
true
)
{
$type
=
str_replace
(
'_'
,
' '
,
strtolower
(
substr
(
$tokens
[
$tokens
[
$i
][
'scope_condition'
]][
'type'
],
2
)));
$line
=
$tokens
[
$i
][
'line'
];
echo
"Close
closur
e on line
$line
"
.
PHP_EOL
;
echo
"Close
$typ
e
on line
$line
"
.
PHP_EOL
;
}
$prev
=
false
;
...
...
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