Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22416360
ArcanistNamespaceFirstStatementXHPASTLinterRule.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
1018 B
Referenced Files
None
Subscribers
None
ArcanistNamespaceFirstStatementXHPASTLinterRule.php
View Options
<?php
final
class
ArcanistNamespaceFirstStatementXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
98
;
public
function
getLintName
()
{
return
pht
(
'`%s` Statement Must Be The First Statement'
,
'namespace'
);
}
public
function
process
(
XHPASTNode
$root
)
{
$namespaces
=
$root
->
selectDescendantsOfType
(
'n_NAMESPACE'
);
if
(!
count
(
$namespaces
))
{
return
;
}
$statements
=
$root
->
getChildOfType
(
0
,
'n_STATEMENT_LIST'
);
// Ignore the first statement, which should be `n_OPEN_TAG`.
$second_statement
=
$statements
->
getChildByIndex
(
1
)->
getChildByIndex
(
0
);
if
(
$second_statement
->
getTypeName
()
!=
'n_NAMESPACE'
)
{
$this
->
raiseLintAtNode
(
$second_statement
,
pht
(
'A script which contains a `%s` statement expects the very first '
.
'statement to be a `%s` statement. Otherwise, a PHP fatal error '
.
'will occur. %s'
,
'namespace'
,
'namespace'
,
$second_statement
->
getTypeName
()));
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 28, 01:32 (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1209254
Default Alt Text
ArcanistNamespaceFirstStatementXHPASTLinterRule.php (1018 B)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline