Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F3493384
ArcanistEmptyStatementXHPASTLinterRule.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
ArcanistEmptyStatementXHPASTLinterRule.php
View Options
<?php
final
class
ArcanistEmptyStatementXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
47
;
public
function
getLintName
(
)
{
return
pht
(
'Empty Block Statement'
)
;
}
public
function
getLintSeverity
(
)
{
return
ArcanistLintSeverity
::
SEVERITY_ADVICE
;
}
public
function
process
(
XHPASTNode
$root
)
{
$nodes
=
$root
->
selectDescendantsOfType
(
'n_STATEMENT_LIST'
)
;
foreach
(
$nodes
as
$node
)
{
$tokens
=
$node
->
getTokens
(
)
;
$token
=
head
(
$tokens
)
;
if
(
count
(
$tokens
)
<=
2
)
{
continue
;
}
// Safety check... if the first token isn't an opening brace then
// there's nothing to do here.
if
(
$token
->
getTypeName
(
)
!=
'{'
)
{
continue
;
}
$only_whitespace
=
true
;
for
(
$token
=
$token
->
getNextToken
(
)
;
$token
&&
$token
->
getTypeName
(
)
!=
'}'
;
$token
=
$token
->
getNextToken
(
)
)
{
$only_whitespace
=
$only_whitespace
&&
$token
->
isAnyWhitespace
(
)
;
}
if
(
count
(
$tokens
)
>
2
&&
$only_whitespace
)
{
$this
->
raiseLintAtNode
(
$node
,
pht
(
"Braces for an empty block statement shouldn't "
.
"contain only whitespace."
)
,
'{}'
)
;
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Apr 17, 06:40 (5 d, 1 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1120301
Default Alt Text
ArcanistEmptyStatementXHPASTLinterRule.php (1 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment