本文整理汇总了PHP中PHP_PMD_AbstractNode::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_PMD_AbstractNode::getType方法的具体用法?PHP PHP_PMD_AbstractNode::getType怎么用?PHP PHP_PMD_AbstractNode::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP_PMD_AbstractNode
的用法示例。
在下文中一共展示了PHP_PMD_AbstractNode::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply
/**
* Extracts all variable and variable declarator nodes from the given node
* and checks the variable name length against the configured maximum
* length.
*
* @param PHP_PMD_AbstractNode $node The context source code node.
*
* @return void
*/
public function apply(PHP_PMD_AbstractNode $node)
{
$this->resetProcessed();
if ($node->getType() === 'class') {
$fields = $node->findChildrenOfType('FieldDeclaration');
foreach ($fields as $field) {
if ($field->isPrivate()) {
continue;
}
$declarators = $field->findChildrenOfType('VariableDeclarator');
foreach ($declarators as $declarator) {
$this->checkNodeImage($declarator);
}
}
} else {
$declarators = $node->findChildrenOfType('VariableDeclarator');
foreach ($declarators as $declarator) {
$this->checkNodeImage($declarator);
}
$variables = $node->findChildrenOfType('Variable');
foreach ($variables as $variable) {
$this->checkNodeImage($variable);
}
}
$this->resetProcessed();
}
示例2: apply
/**
* This method checks if a given function or method contains an eval-expression
* and emits a rule violation when it exists.
*
* @param PHP_PMD_AbstractNode $node The context source code node.
*
* @return void
*/
public function apply(PHP_PMD_AbstractNode $node)
{
foreach ($node->findChildrenOfType('EvalExpression') as $eval) {
$this->addViolation($eval, array($node->getType(), $node->getName()));
}
}
示例3: apply
/**
* This method should implement the violation analysis algorithm of concrete
* rule implementations. All extending classes must implement this method.
*
* @param PHP_PMD_AbstractNode $node The current context for analysis.
*
* @return void
*/
public function apply(PHP_PMD_AbstractNode $node)
{
foreach ($node->findChildrenOfType('GotoStatement') as $goto) {
$this->addViolation($goto, array($node->getType(), $node->getName()));
}
}