Chris@13: 0 : Flags Chris@0: * 'extends' => null : Name of extended class Chris@0: * 'implements' => array(): Names of implemented interfaces Chris@0: * 'stmts' => array(): Statements Chris@0: * @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->name = \is_string($name) ? new Node\Identifier($name) : $name; Chris@13: $this->extends = $subNodes['extends'] ?? null; Chris@13: $this->implements = $subNodes['implements'] ?? []; Chris@13: $this->stmts = $subNodes['stmts'] ?? []; Chris@0: } Chris@0: Chris@13: public function getSubNodeNames() : array { Chris@13: return ['flags', 'name', 'extends', 'implements', 'stmts']; Chris@0: } Chris@0: Chris@13: /** Chris@13: * Whether the class is explicitly abstract. Chris@13: * Chris@13: * @return bool Chris@13: */ Chris@13: public function isAbstract() : bool { Chris@0: return (bool) ($this->flags & self::MODIFIER_ABSTRACT); Chris@0: } Chris@0: Chris@13: /** Chris@13: * Whether the class is final. Chris@13: * Chris@13: * @return bool Chris@13: */ Chris@13: public function isFinal() : bool { Chris@0: return (bool) ($this->flags & self::MODIFIER_FINAL); Chris@0: } Chris@0: Chris@13: /** Chris@13: * Whether the class is anonymous. Chris@13: * Chris@13: * @return bool Chris@13: */ Chris@13: public function isAnonymous() : bool { Chris@0: return null === $this->name; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @internal Chris@0: */ Chris@0: public static function verifyModifier($a, $b) { Chris@0: if ($a & self::VISIBILITY_MODIFIER_MASK && $b & self::VISIBILITY_MODIFIER_MASK) { Chris@0: throw new Error('Multiple access type modifiers are not allowed'); Chris@0: } Chris@0: Chris@0: if ($a & self::MODIFIER_ABSTRACT && $b & self::MODIFIER_ABSTRACT) { Chris@0: throw new Error('Multiple abstract modifiers are not allowed'); Chris@0: } Chris@0: Chris@0: if ($a & self::MODIFIER_STATIC && $b & self::MODIFIER_STATIC) { Chris@0: throw new Error('Multiple static modifiers are not allowed'); Chris@0: } Chris@0: Chris@0: if ($a & self::MODIFIER_FINAL && $b & self::MODIFIER_FINAL) { Chris@0: throw new Error('Multiple final modifiers are not allowed'); Chris@0: } Chris@0: Chris@0: if ($a & 48 && $b & 48) { Chris@0: throw new Error('Cannot use the final modifier on an abstract class member'); Chris@0: } Chris@0: } Chris@13: Chris@13: public function getType() : string { Chris@13: return 'Stmt_Class'; Chris@13: } Chris@0: }