예제 #1
0
 /**
  * Constructs a try catch node.
  *
  * @param Node[]        $stmts      Statements
  * @param Catch_[]      $catches    Catches
  * @param null|Finally_ $finally    Optionaly finally node
  * @param array|null    $attributes Additional attributes
  */
 public function __construct(array $stmts, array $catches, Finally_ $finally = null, array $attributes = array())
 {
     parent::__construct($attributes);
     $this->stmts = $stmts;
     $this->catches = $catches;
     $this->finally = $finally;
 }
예제 #2
0
 /**
  * Constructs a try catch node.
  *
  * @param Node[]     $stmts        Statements
  * @param Catch_[]   $catches      Catches
  * @param Node[]     $finallyStmts Finally statements (null means no finally clause)
  * @param array|null $attributes   Additional attributes
  */
 public function __construct(array $stmts, array $catches, array $finallyStmts = null, array $attributes = array())
 {
     if (empty($catches) && null === $finallyStmts) {
         throw new Error('Cannot use try without catch or finally');
     }
     parent::__construct(array('stmts' => $stmts, 'catches' => $catches, 'finallyStmts' => $finallyStmts), $attributes);
 }
예제 #3
0
파일: Catch_.php 프로젝트: sapwoo/portfolio
 /**
  * Constructs a catch node.
  *
  * @param Node\Name $type
  *        	Class of exception
  * @param string $var
  *        	Variable for exception
  * @param Node[] $stmts
  *        	Statements
  * @param array $attributes
  *        	Additional attributes
  */
 public function __construct(Node\Name $type, $var, array $stmts = array(), array $attributes = array())
 {
     parent::__construct($attributes);
     $this->type = $type;
     $this->var = $var;
     $this->stmts = $stmts;
 }
예제 #4
0
 /**
  * Constructs a group use node.
  *
  * @param Name $prefix
  *        	Prefix for uses
  * @param UseUse[] $uses
  *        	Uses
  * @param int $type
  *        	Type of group use
  * @param array $attributes
  *        	Additional attributes
  */
 public function __construct(Name $prefix, array $uses, $type = Use_::TYPE_NORMAL, array $attributes = array())
 {
     parent::__construct($attributes);
     $this->type = $type;
     $this->prefix = $prefix;
     $this->uses = $uses;
 }
예제 #5
0
 /**
  * Constructs a class property list node.
  *
  * @param int                $flags      Modifiers
  * @param PropertyProperty[] $props      Properties
  * @param array              $attributes Additional attributes
  */
 public function __construct($flags, array $props, array $attributes = array())
 {
     parent::__construct($attributes);
     $this->flags = $flags;
     $this->type = $flags;
     $this->props = $props;
 }
예제 #6
0
파일: Catch_.php 프로젝트: nikic/php-parser
 /**
  * Constructs a catch node.
  *
  * @param Node\Name[] $types      Types of exceptions to catch
  * @param string      $var        Variable for exception
  * @param Node[]      $stmts      Statements
  * @param array       $attributes Additional attributes
  */
 public function __construct(array $types, $var, array $stmts = array(), array $attributes = array())
 {
     parent::__construct($attributes);
     $this->types = $types;
     $this->var = $var;
     $this->stmts = $stmts;
 }
예제 #7
0
 /**
  * Constructs a for loop node.
  *
  * @param array $subNodes   Array of the following optional subnodes:
  *                          'init'  => array(): Init expressions
  *                          'cond'  => array(): Loop conditions
  *                          'loop'  => array(): Loop expressions
  *                          'stmts' => array(): Statements
  * @param array $attributes Additional attributes
  */
 public function __construct(array $subNodes = array(), array $attributes = array())
 {
     parent::__construct(null, $attributes);
     $this->init = isset($subNodes['init']) ? $subNodes['init'] : array();
     $this->cond = isset($subNodes['cond']) ? $subNodes['cond'] : array();
     $this->loop = isset($subNodes['loop']) ? $subNodes['loop'] : array();
     $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
 }
예제 #8
0
 /**
  * Constructs a function node.
  *
  * @param string $name       Name
  * @param array  $subNodes   Array of the following optional subnodes:
  *                           'byRef'      => false  : Whether to return by reference
  *                           'params'     => array(): Parameters
  *                           'returnType' => null   : Return type
  *                           'stmts'      => array(): Statements
  * @param array  $attributes Additional attributes
  */
 public function __construct($name, array $subNodes = array(), array $attributes = array()) {
     parent::__construct($attributes);
     $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false;
     $this->name = $name;
     $this->params = isset($subNodes['params']) ? $subNodes['params'] : array();
     $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null;
     $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
 }
예제 #9
0
파일: If_.php 프로젝트: qasem2rubik/laravel
 /**
  * Constructs an if node.
  *
  * @param Node\Expr $cond       Condition
  * @param array     $subNodes   Array of the following optional subnodes:
  *                              'stmts'   => array(): Statements
  *                              'elseifs' => array(): Elseif clauses
  *                              'else'    => null   : Else clause
  * @param array     $attributes Additional attributes
  */
 public function __construct(Node\Expr $cond, array $subNodes = array(), array $attributes = array())
 {
     parent::__construct($attributes);
     $this->cond = $cond;
     $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
     $this->elseifs = isset($subNodes['elseifs']) ? $subNodes['elseifs'] : array();
     $this->else = isset($subNodes['else']) ? $subNodes['else'] : null;
 }
예제 #10
0
 /**
  * Constructs a foreach node.
  *
  * @param Node\Expr $expr
  *        	Expression to iterate
  * @param Node\Expr $valueVar
  *        	Variable to assign value to
  * @param array $subNodes
  *        	Array of the following optional subnodes:
  *        	'keyVar' => null : Variable to assign key to
  *        	'byRef' => false : Whether to assign value by reference
  *        	'stmts' => array(): Statements
  * @param array $attributes
  *        	Additional attributes
  */
 public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = array(), array $attributes = array())
 {
     parent::__construct(null, $attributes);
     $this->expr = $expr;
     $this->keyVar = isset($subNodes['keyVar']) ? $subNodes['keyVar'] : null;
     $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false;
     $this->valueVar = $valueVar;
     $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
 }
예제 #11
0
 /**
  * Constructs a try catch node.
  *
  * @param Node[] $stmts
  *        	Statements
  * @param Catch_[] $catches
  *        	Catches
  * @param null|Node[] $finallyStmts
  *        	Finally statements (null means no finally clause)
  * @param array|null $attributes
  *        	Additional attributes
  */
 public function __construct(array $stmts, array $catches, array $finallyStmts = null, array $attributes = array())
 {
     if (empty($catches) && null === $finallyStmts) {
         throw new Error('Cannot use try without catch or finally');
     }
     parent::__construct($attributes);
     $this->stmts = $stmts;
     $this->catches = $catches;
     $this->finallyStmts = $finallyStmts;
 }
예제 #12
0
파일: UseUse.php 프로젝트: nikic/php-parser
 /**
  * Constructs an alias (use) node.
  *
  * @param Node\Name   $name       Namespace/Class to alias
  * @param null|string $alias      Alias
  * @param int         $type       Type of the use element (for mixed group use declarations only)
  * @param array       $attributes Additional attributes
  */
 public function __construct(Node\Name $name, $alias = null, $type = Use_::TYPE_UNKNOWN, array $attributes = array())
 {
     if (null === $alias) {
         $alias = $name->getLast();
     }
     parent::__construct($attributes);
     $this->type = $type;
     $this->name = $name;
     $this->alias = $alias;
 }
예제 #13
0
 /**
  * Constructs an alias (use) node.
  *
  * @param Node\Name   $name       Namespace/Class to alias
  * @param null|string $alias      Alias
  * @param array       $attributes Additional attributes
  */
 public function __construct(Node\Name $name, $alias = null, array $attributes = array())
 {
     if (null === $alias) {
         $alias = $name->getLast();
     }
     if ('self' == $alias || 'parent' == $alias) {
         throw new Error(sprintf('Cannot use %s as %s because \'%2$s\' is a special class name', $name, $alias));
     }
     parent::__construct(array('name' => $name, 'alias' => $alias), $attributes);
 }
예제 #14
0
 /**
  * Constructs a class property list node.
  *
  * @param int $type
  *        	Modifiers
  * @param PropertyProperty[] $props
  *        	Properties
  * @param array $attributes
  *        	Additional attributes
  */
 public function __construct($type, array $props, array $attributes = array())
 {
     if ($type & Class_::MODIFIER_ABSTRACT) {
         throw new Error('Properties cannot be declared abstract');
     }
     if ($type & Class_::MODIFIER_FINAL) {
         throw new Error('Properties cannot be declared final');
     }
     parent::__construct($attributes);
     $this->type = $type;
     $this->props = $props;
 }
예제 #15
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));
         }
     }
 }
예제 #16
0
파일: UseUse.php 프로젝트: a53ali/CakePhP
 /**
  * Constructs an alias (use) node.
  *
  * @param Node\Name $name Namespace/Class to alias
  * @param null|string $alias Alias
  * @param array $attributes Additional attributes
  */
 public function __construct(Node\Name $name, $alias = null, array $attributes = array())
 {
     if (null === $alias) {
         $alias = $name->getLast();
     }
     if ('self' == strtolower($alias) || 'parent' == strtolower($alias)) {
         throw new Error(sprintf('Cannot use %s as %s because \'%2$s\' is a special class name', $name, $alias));
     }
     parent::__construct(null, $attributes);
     $this->name = $name;
     $this->alias = $alias;
 }
예제 #17
0
 /**
  * Constructs a class method node.
  *
  * @param string      $name       Name
  * @param array       $subNodes   Array of the following optional subnodes:
  *                                'type'   => MODIFIER_PUBLIC: Type
  *                                'byRef'  => false          : Whether to return by reference
  *                                'params' => array()        : Parameters
  *                                'stmts'  => array()        : Statements
  * @param array       $attributes Additional attributes
  */
 public function __construct($name, array $subNodes = array(), array $attributes = array())
 {
     parent::__construct(array('type' => isset($subNodes['type']) ? $subNodes['type'] : Class_::MODIFIER_PUBLIC, 'byRef' => isset($subNodes['byRef']) ? $subNodes['byRef'] : false, 'name' => $name, 'params' => isset($subNodes['params']) ? $subNodes['params'] : array(), 'stmts' => array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : array()), $attributes);
     if ($this->type & Class_::MODIFIER_STATIC) {
         switch (strtolower($this->name)) {
             case '__construct':
                 throw new Error(sprintf('Constructor %s() cannot be static', $this->name));
             case '__destruct':
                 throw new Error(sprintf('Destructor %s() cannot be static', $this->name));
             case '__clone':
                 throw new Error(sprintf('Clone method %s() cannot be static', $this->name));
         }
     }
 }
예제 #18
0
파일: Property.php 프로젝트: samj1912/repo
 /**
  * Constructs a class property list node.
  *
  * @param int                $type       Modifiers
  * @param PropertyProperty[] $props      Properties
  * @param array              $attributes Additional attributes
  */
 public function __construct($type, array $props, array $attributes = array())
 {
     if (0 === ($type & Class_::VISIBILITY_MODIFER_MASK)) {
         // If no visibility modifier given, PHP defaults to public
         $type |= Class_::MODIFIER_PUBLIC;
     }
     if ($type & Class_::MODIFIER_ABSTRACT) {
         throw new Error('Properties cannot be declared abstract');
     }
     if ($type & Class_::MODIFIER_FINAL) {
         throw new Error('Properties cannot be declared final');
     }
     parent::__construct(array('type' => $type, 'props' => $props), $attributes);
 }
 /**
  * Constructs a namespace node.
  *
  * @param null|Node\Name $name       Name
  * @param Node[]         $stmts      Statements
  * @param array          $attributes Additional attributes
  */
 public function __construct(Node\Name $name = null, $stmts = array(), array $attributes = array())
 {
     parent::__construct(array('name' => $name, 'stmts' => $stmts), $attributes);
     if (isset(self::$specialNames[(string) $this->name])) {
         throw new Error(sprintf('Cannot use \'%s\' as namespace name', $this->name));
     }
     if (null !== $this->stmts) {
         foreach ($this->stmts as $stmt) {
             if ($stmt instanceof self) {
                 throw new Error('Namespace declarations cannot be nested', $stmt->getLine());
             }
         }
     }
 }
예제 #20
0
 /**
  * Constructs a namespace node.
  *
  * @param null|Node\Name $name       Name
  * @param null|Node[]    $stmts      Statements
  * @param array          $attributes Additional attributes
  */
 public function __construct(Node\Name $name = null, $stmts = array(), array $attributes = array())
 {
     parent::__construct(null, $attributes);
     $this->name = $name;
     $this->stmts = $stmts;
     if (isset(self::$specialNames[strtolower($this->name)])) {
         throw new Error(sprintf('Cannot use \'%s\' as namespace name', $this->name), $this->name->getAttributes());
     }
     if (null !== $this->stmts) {
         foreach ($this->stmts as $stmt) {
             if ($stmt instanceof self) {
                 throw new Error('Namespace declarations cannot be nested', $stmt->getAttributes());
             }
         }
     }
 }
예제 #21
0
 /**
  * Constructs a class method node.
  *
  * @param string      $name       Name
  * @param array       $subNodes   Array of the following optional subnodes:
  *                                'type'   => MODIFIER_PUBLIC: Type
  *                                'byRef'  => false          : Whether to return by reference
  *                                'params' => array()        : Parameters
  *                                'stmts'  => array()        : Statements
  * @param array       $attributes Additional attributes
  */
 public function __construct($name, array $subNodes = array(), array $attributes = array())
 {
     $type = isset($subNodes['type']) ? $subNodes['type'] : 0;
     if (0 === ($type & Class_::VISIBILITY_MODIFER_MASK)) {
         // If no visibility modifier given, PHP defaults to public
         $type |= Class_::MODIFIER_PUBLIC;
     }
     parent::__construct(array('type' => $type, 'byRef' => isset($subNodes['byRef']) ? $subNodes['byRef'] : false, 'name' => $name, 'params' => isset($subNodes['params']) ? $subNodes['params'] : array(), 'stmts' => array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : array()), $attributes);
     if ($this->type & Class_::MODIFIER_STATIC) {
         switch (strtolower($this->name)) {
             case '__construct':
                 throw new Error(sprintf('Constructor %s() cannot be static', $this->name));
             case '__destruct':
                 throw new Error(sprintf('Destructor %s() cannot be static', $this->name));
             case '__clone':
                 throw new Error(sprintf('Clone method %s() cannot be static', $this->name));
         }
     }
 }
예제 #22
0
 /**
  * Constructs a class method node.
  *
  * @param string $name
  *        	Name
  * @param array $subNodes
  *        	Array of the following optional subnodes:
  *        	'type' => MODIFIER_PUBLIC: Type
  *        	'byRef' => false : Whether to return by reference
  *        	'params' => array() : Parameters
  *        	'returnType' => null : Return type
  *        	'stmts' => array() : Statements
  * @param array $attributes
  *        	Additional attributes
  */
 public function __construct($name, array $subNodes = array(), array $attributes = array())
 {
     parent::__construct($attributes);
     $this->type = isset($subNodes['type']) ? $subNodes['type'] : 0;
     $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false;
     $this->name = $name;
     $this->params = isset($subNodes['params']) ? $subNodes['params'] : array();
     $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null;
     $this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : array();
     if ($this->type & Class_::MODIFIER_STATIC) {
         switch (strtolower($this->name)) {
             case '__construct':
                 throw new Error(sprintf('Constructor %s() cannot be static', $this->name));
             case '__destruct':
                 throw new Error(sprintf('Destructor %s() cannot be static', $this->name));
             case '__clone':
                 throw new Error(sprintf('Clone method %s() cannot be static', $this->name));
         }
     }
 }
예제 #23
0
 /**
  * Constructs a __halt_compiler node.
  *
  * @param string $remaining  Remaining text after halt compiler statement.
  * @param array  $attributes Additional attributes
  */
 public function __construct($remaining, array $attributes = array())
 {
     parent::__construct(array('remaining' => $remaining), $attributes);
 }
예제 #24
0
 /**
  * Constructs an unset node.
  *
  * @param Node\Expr[] $vars Variables to unset
  * @param array $attributes Additional attributes
  */
 public function __construct(array $vars, array $attributes = array())
 {
     parent::__construct($attributes);
     $this->vars = $vars;
 }
예제 #25
0
 /**
  * Constructs a throw node.
  *
  * @param Node\Expr $expr Expression
  * @param array $attributes Additional attributes
  */
 public function __construct(Node\Expr $expr, array $attributes = array())
 {
     parent::__construct($attributes);
     $this->expr = $expr;
 }
예제 #26
0
파일: Break_.php 프로젝트: saj696/pipe
 /**
  * Constructs a break node.
  *
  * @param null|Node\Expr $num Number of loops to break
  * @param array $attributes Additional attributes
  */
 public function __construct(Node\Expr $num = null, array $attributes = array())
 {
     parent::__construct($attributes);
     $this->num = $num;
 }
예제 #27
0
 /**
  * Constructs a return node.
  *
  * @param null|Node\Expr $expr       Expression
  * @param array          $attributes Additional attributes
  */
 public function __construct(Node\Expr $expr = null, array $attributes = array())
 {
     parent::__construct(array('expr' => $expr), $attributes);
 }
예제 #28
0
파일: ElseIf_.php 프로젝트: saj696/pipe
 /**
  * Constructs an elseif node.
  *
  * @param Node\Expr $cond Condition
  * @param Node[] $stmts Statements
  * @param array $attributes Additional attributes
  */
 public function __construct(Node\Expr $cond, array $stmts = array(), array $attributes = array())
 {
     parent::__construct($attributes);
     $this->cond = $cond;
     $this->stmts = $stmts;
 }
예제 #29
0
파일: Label.php 프로젝트: a53ali/CakePhP
 /**
  * Constructs a label node.
  *
  * @param string $name Name
  * @param array $attributes Additional attributes
  */
 public function __construct($name, array $attributes = array())
 {
     parent::__construct(null, $attributes);
     $this->name = $name;
 }
예제 #30
0
 /**
  * Constructs a case node.
  *
  * @param Node\Expr $cond       Condition
  * @param Case_[]   $cases      Case list
  * @param array     $attributes Additional attributes
  */
 public function __construct(Node\Expr $cond, array $cases, array $attributes = array())
 {
     parent::__construct(array('cond' => $cond, 'cases' => $cases), $attributes);
 }