本文整理汇总了PHP中PhpParser\Node::isFinal方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::isFinal方法的具体用法?PHP Node::isFinal怎么用?PHP Node::isFinal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpParser\Node
的用法示例。
在下文中一共展示了Node::isFinal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enterNode
function enterNode(\PhpParser\Node $node)
{
if ($node instanceof \PhpParser\Node\Stmt\Namespace_) {
$this->addNamespace(array('namespace' => $node->name->toString(), 'line' => $node->getLine(), 'file' => $this->file));
}
if ($node instanceof \PhpParser\Node\Stmt\Use_) {
foreach ($node->uses as $use) {
$this->addUse(array('name' => $use->name, 'alias' => $use->alias));
}
}
if ($node instanceof \PhpParser\Node\Stmt\Class_) {
$this->addClass(array('name' => $node->name, 'extends' => $node->extends, 'implements' => $node->implements, 'abstract' => $node->isAbstract(), 'final' => $node->isFinal(), 'comment' => $node->getDocComment(), 'doc' => $this->doc_comment_parser->parse($node->getDocComment()), 'line' => $node->getLine(), 'file' => $this->file));
}
if ($node instanceof \PhpParser\Node\Stmt\Interface_) {
$this->addInterface(array('name' => $node->name, 'extends' => $node->extends, 'comment' => $node->getDocComment(), 'doc' => $this->doc_comment_parser->parse($node->getDocComment()), 'line' => $node->getLine(), 'file' => $this->file));
}
if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) {
$this->addClassMethod(array('byRef' => $node->byRef, 'name' => $node->name, 'params' => $node->params, 'returnType' => $node->returnType, 'public' => $node->isPublic(), 'protected' => $node->isProtected(), 'private' => $node->isPrivate(), 'abstract' => $node->isAbstract(), 'final' => $node->isFinal(), 'static' => $node->isStatic(), 'comment' => $node->getDocComment(), 'doc' => $this->doc_comment_parser->parse($node->getDocComment()), 'line' => $node->getLine(), 'file' => $this->file));
}
if ($node instanceof \PhpParser\Node\Stmt\Property) {
$this->last_property = $node;
}
if ($node instanceof \PhpParser\Node\Stmt\PropertyProperty) {
$this->addClassProperty(array('name' => $node->name, 'default' => $node->default, 'public' => $this->last_property->isPublic(), 'protected' => $this->last_property->isProtected(), 'private' => $this->last_property->isPrivate(), 'static' => $this->last_property->isStatic(), 'comment' => $node->getDocComment(), 'doc' => $this->doc_comment_parser->parse($node->getDocComment()), 'line' => $node->getLine(), 'file' => $this->file));
}
// $this->logger->info(get_class($node));
}
示例2: enterNode
public function enterNode(PhpParser\Node $node)
{
if ($node instanceof Stmt\ClassMethod) {
// create new context, keep parent
$this->stack->start(new MethodContext($node->name, $node->getLine(), $node->getAttribute('endLine')));
// report non public methods
if ($node->isPrivate()) {
$this->stack->addIssue(new PrivateMethodIssue($node));
} elseif ($node->isProtected()) {
$this->stack->addIssue(new ProtectedMethodIssue($node));
}
// report final methods
if ($node->isFinal()) {
$this->stack->addIssue(new FinalMethodIssue($node));
}
}
}
示例3: initUserClass
/**
* Initialize a new User Class
*
* @param Node $node
*
* @return void
*/
private function initUserClass(Node $node)
{
if (isset($node->namespacedName) && $node->namespacedName instanceof Node\Name && $node->namespacedName->isQualified()) {
$min = '5.3.0';
} else {
if ($node->isAbstract() || $node->isFinal()) {
$min = '5.0.0';
} else {
$min = '4.0.0';
}
}
$max = '';
$element = 'classes';
$name = (string) $node->namespacedName;
$this->contextStack[] = array($element, $name);
// parent class
if (isset($node->extends)) {
$name = (string) $node->extends;
$group = $this->findObjectType($name);
$versions = $this->metrics[$group][$name];
if ('user' == $versions['ext.name']) {
if ($node->extends->isFullyQualified()) {
if (count($node->extends->parts) === 1) {
// PHP4 syntax (global namespace)
$versions = array('php.min' => '4.0.0');
} else {
$versions = array('php.min' => '5.3.0');
}
} else {
$versions = array();
}
}
$this->updateElementVersion('classes', $name, $versions);
++$this->metrics['classes'][$name]['matches'];
if ('objects' == $group) {
// now object is categorized, remove from temp queue
unset($this->metrics[$group][$name]);
}
$this->updateLocalVersions($versions);
}
// interfaces
foreach ($node->implements as $interface) {
$name = (string) $interface;
$group = $this->findObjectType($name);
$versions = $this->metrics[$group][$name];
$this->updateElementVersion('interfaces', $name, $versions);
++$this->metrics['interfaces'][$name]['matches'];
if ('objects' == $group) {
// now object is categorized, remove from temp queue
unset($this->metrics[$group][$name]);
}
$this->updateLocalVersions($versions);
}
$name = (string) $node->namespacedName;
$group = $this->findObjectType($name);
$versions = $this->metrics[$group][$name];
if ('objects' == $group) {
// now object is categorized, remove from temp queue
unset($this->metrics[$group][$name]);
}
$versions = array_merge($versions, array('php.min' => $min, 'php.max' => $max, 'declared' => true));
$this->updateLocalVersions($versions);
}