Chris@13: true, Chris@13: '__destruct' => true, Chris@13: '__call' => true, Chris@13: '__callstatic' => true, Chris@13: '__get' => true, Chris@13: '__set' => true, Chris@13: '__isset' => true, Chris@13: '__unset' => true, Chris@13: '__sleep' => true, Chris@13: '__wakeup' => true, Chris@13: '__tostring' => true, Chris@13: '__set_state' => true, Chris@13: '__clone' => true, Chris@13: '__invoke' => true, Chris@13: '__debuginfo' => true, Chris@13: ]; Chris@0: Chris@0: /** Chris@0: * Constructs a class method node. Chris@0: * Chris@13: * @param string|Node\Identifier $name Name Chris@13: * @param array $subNodes Array of the following optional subnodes: Chris@13: * 'flags => MODIFIER_PUBLIC: Flags Chris@13: * 'byRef' => false : Whether to return by reference Chris@13: * 'params' => array() : Parameters Chris@13: * 'returnType' => null : Return type Chris@13: * 'stmts' => array() : Statements Chris@13: * @param array $attributes Additional attributes Chris@0: */ Chris@13: public function __construct($name, array $subNodes = [], array $attributes = []) { Chris@0: parent::__construct($attributes); Chris@13: $this->flags = $subNodes['flags'] ?? $subNodes['type'] ?? 0; Chris@13: $this->byRef = $subNodes['byRef'] ?? false; Chris@13: $this->name = \is_string($name) ? new Node\Identifier($name) : $name; Chris@13: $this->params = $subNodes['params'] ?? []; Chris@13: $returnType = $subNodes['returnType'] ?? null; Chris@13: $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; Chris@13: $this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : []; Chris@0: } Chris@0: Chris@13: public function getSubNodeNames() : array { Chris@13: return ['flags', 'byRef', 'name', 'params', 'returnType', 'stmts']; Chris@0: } Chris@0: Chris@13: public function returnsByRef() : bool { Chris@0: return $this->byRef; Chris@0: } Chris@0: Chris@13: public function getParams() : array { Chris@0: return $this->params; Chris@0: } Chris@0: Chris@0: public function getReturnType() { Chris@0: return $this->returnType; Chris@0: } Chris@0: Chris@0: public function getStmts() { Chris@0: return $this->stmts; Chris@0: } Chris@0: Chris@13: /** Chris@13: * Whether the method is explicitly or implicitly public. Chris@13: * Chris@13: * @return bool Chris@13: */ Chris@13: public function isPublic() : bool { Chris@0: return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 Chris@0: || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; Chris@0: } Chris@0: Chris@13: /** Chris@13: * Whether the method is protected. Chris@13: * Chris@13: * @return bool Chris@13: */ Chris@13: public function isProtected() : bool { Chris@0: return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); Chris@0: } Chris@0: Chris@13: /** Chris@13: * Whether the method is private. Chris@13: * Chris@13: * @return bool Chris@13: */ Chris@13: public function isPrivate() : bool { Chris@0: return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); Chris@0: } Chris@0: Chris@13: /** Chris@13: * Whether the method is abstract. Chris@13: * Chris@13: * @return bool Chris@13: */ Chris@13: public function isAbstract() : bool { Chris@0: return (bool) ($this->flags & Class_::MODIFIER_ABSTRACT); Chris@0: } Chris@0: Chris@13: /** Chris@13: * Whether the method is final. Chris@13: * Chris@13: * @return bool Chris@13: */ Chris@13: public function isFinal() : bool { Chris@0: return (bool) ($this->flags & Class_::MODIFIER_FINAL); Chris@0: } Chris@0: Chris@13: /** Chris@13: * Whether the method is static. Chris@13: * Chris@13: * @return bool Chris@13: */ Chris@13: public function isStatic() : bool { Chris@0: return (bool) ($this->flags & Class_::MODIFIER_STATIC); Chris@0: } Chris@13: Chris@13: /** Chris@13: * Whether the method is magic. Chris@13: * Chris@13: * @return bool Chris@13: */ Chris@13: public function isMagic() : bool { Chris@13: return isset(self::$magicNames[$this->name->toLowerString()]); Chris@13: } Chris@13: Chris@13: public function getType() : string { Chris@13: return 'Stmt_ClassMethod'; Chris@13: } Chris@0: }