Inheritance: extends PhpParser\Node\Stmt
コード例 #1
0
 public function visitStruct(ClassLike $node)
 {
     $struct = $this->getStruct();
     $struct->setName($node->name);
     if (($doc = $node->getDocComment()) !== null) {
         $struct->setDocblock($doc->getReformattedText());
         $docblock = $struct->getDocblock();
         $struct->setDescription($docblock->getShortDescription());
         $struct->setLongDescription($docblock->getLongDescription());
     }
 }
コード例 #2
0
 private function importMethods(ClassLike $class, array $methods)
 {
     $stmts = [];
     foreach ($methods as $methodName => $methodArr) {
         if (count($methodArr) > 1) {
             echo "Too many implementations for {$methodName}\n";
         }
         foreach ($methodArr as $traitName => $method) {
             if (!$class->getMethod($method->name)) {
                 $stmts[] = $method;
             }
         }
     }
     return $stmts;
 }
コード例 #3
0
ファイル: Interface_.php プロジェクト: nikic/php-parser
 /**
  * Constructs a class node.
  *
  * @param string $name       Name
  * @param array  $subNodes   Array of the following optional subnodes:
  *                           'extends' => array(): Name of extended interfaces
  *                           'stmts'   => array(): Statements
  * @param array  $attributes Additional attributes
  */
 public function __construct($name, array $subNodes = array(), array $attributes = array())
 {
     parent::__construct($attributes);
     $this->name = $name;
     $this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : array();
     $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
 }
コード例 #4
0
 /**
  * Parses interfaces from the concrete class node
  *
  * @param ClassLike $classLikeNode Class-like node
  *
  * @return array|\ReflectionClass[] List of reflections of interfaces
  */
 public static function collectInterfacesFromClassNode(ClassLike $classLikeNode)
 {
     $interfaces = [];
     $isInterface = $classLikeNode instanceof Interface_;
     $interfaceField = $isInterface ? 'extends' : 'implements';
     $hasInterfaces = in_array($interfaceField, $classLikeNode->getSubNodeNames());
     $implementsList = $hasInterfaces ? $classLikeNode->{$interfaceField} : array();
     if ($implementsList) {
         foreach ($implementsList as $implementNode) {
             if ($implementNode instanceof FullyQualified) {
                 $implementName = $implementNode->toString();
                 $interface = interface_exists($implementName, false) ? new parent($implementName) : new static($implementName);
                 $interfaces[$implementName] = $interface;
             }
         }
     }
     return $interfaces;
 }
コード例 #5
0
ファイル: Class_.php プロジェクト: nikic/php-parser
 /**
  * Constructs a class node.
  *
  * @param string|null $name       Name
  * @param array       $subNodes   Array of the following optional subnodes:
  *                                'flags'      => 0      : Flags
  *                                'extends'    => null   : Name of extended class
  *                                'implements' => array(): Names of implemented interfaces
  *                                'stmts'      => array(): Statements
  * @param array       $attributes Additional attributes
  */
 public function __construct($name, array $subNodes = array(), array $attributes = array())
 {
     parent::__construct($attributes);
     $this->flags = isset($subNodes['flags']) ? $subNodes['flags'] : (isset($subNodes['type']) ? $subNodes['type'] : 0);
     $this->type = $this->flags;
     $this->name = $name;
     $this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : null;
     $this->implements = isset($subNodes['implements']) ? $subNodes['implements'] : array();
     $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
 }
コード例 #6
0
 /**
  * Constructs a class node.
  *
  * @param string $name       Name
  * @param array  $subNodes   Array of the following optional subnodes:
  *                           'extends' => array(): Name of extended interfaces
  *                           'stmts'   => array(): Statements
  * @param array  $attributes Additional attributes
  */
 public function __construct($name, array $subNodes = array(), array $attributes = array())
 {
     parent::__construct(array('name' => $name, 'extends' => isset($subNodes['extends']) ? $subNodes['extends'] : array(), 'stmts' => isset($subNodes['stmts']) ? $subNodes['stmts'] : array()), $attributes);
     if (isset(self::$specialNames[(string) $this->name])) {
         throw new Error(sprintf('Cannot use \'%s\' as class name as it is reserved', $this->name));
     }
     foreach ($this->extends as $interface) {
         if (isset(self::$specialNames[(string) $interface])) {
             throw new Error(sprintf('Cannot use \'%s\' as interface name as it is reserved', $interface));
         }
     }
 }
コード例 #7
0
ファイル: Interface_.php プロジェクト: iarmoa/gaia
 /**
  * Constructs a class node.
  *
  * @param string $name       Name
  * @param array  $subNodes   Array of the following optional subnodes:
  *                           'extends' => array(): Name of extended interfaces
  *                           'stmts'   => array(): Statements
  * @param array  $attributes Additional attributes
  */
 public function __construct($name, array $subNodes = array(), array $attributes = array())
 {
     parent::__construct($attributes);
     $this->name = $name;
     $this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : array();
     $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
     if (isset(self::$specialNames[strtolower($this->name)])) {
         throw new Error(sprintf('Cannot use \'%s\' as class name as it is reserved', $this->name));
     }
     foreach ($this->extends as $interface) {
         if (isset(self::$specialNames[strtolower($interface)])) {
             throw new Error(sprintf('Cannot use \'%s\' as interface name as it is reserved', $interface), $interface->getAttributes());
         }
     }
 }
コード例 #8
0
ファイル: Class_.php プロジェクト: NikoNick/EventsBerry
 /**
  * Constructs a class node.
  *
  * @param string      $name       Name
  * @param array       $subNodes   Array of the following optional subnodes:
  *                                'type'       => 0      : Type
  *                                'extends'    => null   : Name of extended class
  *                                'implements' => array(): Names of implemented interfaces
  *                                'stmts'      => array(): Statements
  * @param array       $attributes Additional attributes
  */
 public function __construct($name, array $subNodes = array(), array $attributes = array())
 {
     parent::__construct(null, $attributes);
     $this->type = isset($subNodes['type']) ? $subNodes['type'] : 0;
     $this->name = $name;
     $this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : null;
     $this->implements = isset($subNodes['implements']) ? $subNodes['implements'] : array();
     $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
     if (isset(self::$specialNames[(string) $this->name])) {
         throw new Error(sprintf('Cannot use \'%s\' as class name as it is reserved', $this->name));
     }
     if (isset(self::$specialNames[(string) $this->extends])) {
         throw new Error(sprintf('Cannot use \'%s\' as class name as it is reserved', $this->extends));
     }
     foreach ($this->implements as $interface) {
         if (isset(self::$specialNames[(string) $interface])) {
             throw new Error(sprintf('Cannot use \'%s\' as interface name as it is reserved', $interface));
         }
     }
 }
コード例 #9
0
ファイル: Trait_.php プロジェクト: sapwoo/portfolio
 /**
  * Constructs a trait node.
  *
  * @param string $name
  *        	Name
  * @param Node[] $stmts
  *        	Statements
  * @param array $attributes
  *        	Additional attributes
  */
 public function __construct($name, array $stmts = array(), array $attributes = array())
 {
     parent::__construct($attributes);
     $this->name = $name;
     $this->stmts = $stmts;
 }
コード例 #10
0
 /**
  * Is this class a final class.
  *
  * @return bool
  */
 public function isFinal()
 {
     return $this->node instanceof ClassNode && $this->node->isFinal();
 }
コード例 #11
0
ファイル: Trait_.php プロジェクト: eristoddle/zen-notebook
 /**
  * Constructs a trait node.
  *
  * @param string $name       Name
  * @param Node[] $stmts      Statements
  * @param array  $attributes Additional attributes
  */
 public function __construct($name, array $stmts = array(), array $attributes = array())
 {
     parent::__construct(array('name' => $name, 'stmts' => $stmts), $attributes);
 }
コード例 #12
0
 /**
  * {@inheritDoc}
  */
 public function isFinal()
 {
     $isFinal = $this->classLikeNode instanceof Class_ && $this->classLikeNode->isFinal();
     return $isFinal;
 }
コード例 #13
0
 /**
  * Parses methods from the concrete class node
  *
  * @param ClassLike $classLikeNode Class-like node
  * @param ReflectionClass $reflectionClass Reflection of the class
  *
  * @return array|ReflectionMethod[]
  */
 public static function collectFromClassNode(ClassLike $classLikeNode, ReflectionClass $reflectionClass)
 {
     $methods = [];
     foreach ($classLikeNode->stmts as $classLevelNode) {
         if ($classLevelNode instanceof ClassMethod) {
             $classLevelNode->setAttribute('fileName', $classLikeNode->getAttribute('fileName'));
             $methodName = $classLevelNode->name;
             $methods[$methodName] = new ReflectionMethod($reflectionClass->name, $methodName, $classLevelNode, $reflectionClass);
         }
     }
     return $methods;
 }
コード例 #14
0
ファイル: Php70Features.php プロジェクト: suralc/pvra
 private function detectAndHandleReservedNames(Node\Stmt\ClassLike $cls)
 {
     $this->handleClassName($cls->name, $cls->getLine());
 }