Page MenuHomeSealhub

ArcanistNamespaceFirstStatementXHPASTLinterRule.php
No OneTemporary

Authored By
Unknown
Size
1018 B
Referenced Files
None
Subscribers
None

ArcanistNamespaceFirstStatementXHPASTLinterRule.php

<?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

Mime Type
text/x-php
Expires
Sat, Nov 28, 01:32 (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1209254
Default Alt Text
ArcanistNamespaceFirstStatementXHPASTLinterRule.php (1018 B)

Event Timeline