function hasConstant($name) { $constants = Grabber::filterByType($this->class->stmts, ClassConst::class); foreach ($constants as $constList) { foreach ($constList->consts as $const) { if (strcasecmp($const->name, $name) == 0) { return true; } } } return false; }
function getFunction($name) { $file = $this->getFunctionFile($name); if (!$file) { return null; } $ob = $this->cache->get("Function:" . $name); if (!$ob) { $ob = Grabber::getClassFromFile($this, $file, $name, Function_::class); if ($ob) { $this->cache->add("Function:" . $name, $ob); } } return $ob; }
/** * @param Class_ $node * @param $name * @param SymbolTable $symbolTable * @return ClassMethod */ static function findProperty(Class_ $node, $name, SymbolTable $symbolTable) { while ($node) { $properties = \Guardrail\NodeVisitors\Grabber::filterByType($node->stmts, \PhpParser\Node\Stmt\Property::class); /** @var Property[] $propertyList */ foreach ($properties as $props) { /** @var Property $props */ foreach ($props->props as $prop) { if (strcasecmp($prop->name, $name) == 0) { return $prop; } } } if ($node->extends) { $parent = $node->extends->toString(); $node = $symbolTable->getClass($parent); } else { return null; } } return null; }