Chris@0: true, Chris@0: 'parent' => true, Chris@0: 'static' => true, Chris@0: ); Chris@0: Chris@0: /** Chris@0: * Constructs a class node. Chris@0: * Chris@0: * @param string|null $name Name Chris@0: * @param array $subNodes Array of the following optional subnodes: Chris@0: * 'flags' => 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@0: public function __construct($name, array $subNodes = array(), array $attributes = array()) { Chris@0: parent::__construct($attributes); Chris@0: $this->flags = isset($subNodes['flags']) ? $subNodes['flags'] Chris@0: : (isset($subNodes['type']) ? $subNodes['type'] : 0); Chris@0: $this->type = $this->flags; Chris@0: $this->name = $name; Chris@0: $this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : null; Chris@0: $this->implements = isset($subNodes['implements']) ? $subNodes['implements'] : array(); Chris@0: $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); Chris@0: } Chris@0: Chris@0: public function getSubNodeNames() { Chris@0: return array('flags', 'name', 'extends', 'implements', 'stmts'); Chris@0: } Chris@0: Chris@0: public function isAbstract() { Chris@0: return (bool) ($this->flags & self::MODIFIER_ABSTRACT); Chris@0: } Chris@0: Chris@0: public function isFinal() { Chris@0: return (bool) ($this->flags & self::MODIFIER_FINAL); Chris@0: } Chris@0: Chris@0: public function isAnonymous() { 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@0: }