Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22395364
ArcanistLanguageConstructParenthesesXHPASTLinterRule.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
ArcanistLanguageConstructParenthesesXHPASTLinterRule.php
View Options
<?php
final
class
ArcanistLanguageConstructParenthesesXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
46
;
public
function
getLintName
()
{
return
pht
(
'Language Construct Parentheses'
);
}
public
function
getLintSeverity
()
{
return
ArcanistLintSeverity
::
SEVERITY_WARNING
;
}
public
function
process
(
XHPASTNode
$root
)
{
$nodes
=
$root
->
selectDescendantsOfTypes
(
array
(
'n_INCLUDE_FILE'
,
'n_ECHO_LIST'
,
));
foreach
(
$nodes
as
$node
)
{
$child
=
head
(
$node
->
getChildren
());
if
(
$child
->
getTypeName
()
===
'n_PARENTHETICAL_EXPRESSION'
)
{
list
(
$before
,
$after
)
=
$child
->
getSurroundingNonsemanticTokens
();
$replace
=
preg_replace
(
'/^
\(
(.*)
\)
$/'
,
'$1'
,
$child
->
getConcreteString
());
if
(!
$before
)
{
$replace
=
' '
.
$replace
;
}
$this
->
raiseLintAtNode
(
$child
,
pht
(
'Language constructs do not require parentheses.'
),
$replace
);
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 27, 16:25 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1220273
Default Alt Text
ArcanistLanguageConstructParenthesesXHPASTLinterRule.php (1 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline