Esempio n. 1
0
 /**
  * Constructs a name node.
  *
  * @param string|array $parts      Parts of the name (or name as string)
  * @param int          $line       Line
  * @param null|string  $docComment Nearest doc comment
  */
 public function __construct($parts, $line = -1, $docComment = null)
 {
     if (!is_array($parts)) {
         $parts = explode('\\', $parts);
     }
     parent::__construct(array('parts' => $parts), $line, $docComment);
 }
Esempio n. 2
0
 /**
  * Constructs a name node.
  *
  * @param string|array $parts      Parts of the name (or name as string)
  * @param array        $attributes Additional attributes
  */
 public function __construct($parts, array $attributes = array())
 {
     if (!is_array($parts)) {
         $parts = explode('\\', $parts);
     }
     parent::__construct(array('parts' => $parts), $attributes);
 }
Esempio n. 3
0
    public function enterNode(PHPParser_NodeAbstract &$node) {
        if ($node instanceof PHPParser_Node_Stmt_Namespace) {
            $this->namespace = $node->name;
            $this->aliases   = array();
        } elseif ($node instanceof PHPParser_Node_Stmt_UseUse) {
            if (isset($this->aliases[$node->alias])) {
                throw new PHPParser_Error(
                    sprintf(
                        'Cannot use %s as %s because the name is already in use',
                        $node->name, $node->alias
                    ),
                    $node->getLine()
                );
            }

            $this->aliases[$node->alias] = $node->name;
        }
    }
Esempio n. 4
0
 /**
  * Constructs a const node for use in class const and const statements.
  *
  * @param string              $name       Name
  * @param PHPParser_Node_Expr $value      Value
  * @param int                 $line       Line
  * @param null|string         $docComment Nearest doc comment
  */
 public function __construct($name, PHPParser_Node_Expr $value, $line = -1, $docComment = null)
 {
     parent::__construct(array('name' => $name, 'value' => $value), $line, $docComment);
 }
Esempio n. 5
0
 /**
  * Constructs a const node for use in class const and const statements.
  *
  * @param string              $name       Name
  * @param PHPParser_Node_Expr $value      Value
  * @param array               $attributes Additional attributes
  */
 public function __construct($name, PHPParser_Node_Expr $value, array $attributes = array())
 {
     parent::__construct(array('name' => $name, 'value' => $value), $attributes);
 }
Esempio n. 6
0
 /**
  * Constructs a parameter node.
  *
  * @param string                          $name       Name
  * @param null|PHPParser_Node_Expr        $default    Default value
  * @param null|string|PHPParser_Node_Name $type       Typehint
  * @param bool                            $byRef      Whether is passed by reference
  * @param array                           $attributes Additional attributes
  */
 public function __construct($name, $default = null, $type = null, $byRef = false, array $attributes = array())
 {
     parent::__construct(array('name' => $name, 'default' => $default, 'type' => $type, 'byRef' => $byRef), $attributes);
 }
Esempio n. 7
0
 /**
  * Constructs a function call argument node.
  *
  * @param PHPParser_Node_Expr $value      Value to pass
  * @param bool                $byRef      Whether to pass by ref
  * @param array               $attributes Additional attributes
  */
 public function __construct(PHPParser_Node_Expr $value, $byRef = false, array $attributes = array())
 {
     parent::__construct(array('value' => $value, 'byRef' => $byRef), $attributes);
 }
Esempio n. 8
0
 /**
  * @depends testConstruct
  */
 public function testAttributes(PHPParser_NodeAbstract $node)
 {
     $this->assertEmpty($node->getAttributes());
     $node->setAttribute('key', 'value');
     $this->assertTrue($node->hasAttribute('key'));
     $this->assertEquals('value', $node->getAttribute('key'));
     $this->assertFalse($node->hasAttribute('doesNotExist'));
     $this->assertNull($node->getAttribute('doesNotExist'));
     $this->assertEquals('default', $node->getAttribute('doesNotExist', 'default'));
     $node->setAttribute('null', null);
     $this->assertTrue($node->hasAttribute('null'));
     $this->assertNull($node->getAttribute('null'));
     $this->assertNull($node->getAttribute('null', 'default'));
     $this->assertEquals(array('key' => 'value', 'null' => null), $node->getAttributes());
 }
Esempio n. 9
0
 /**
  * Constructs a function call argument node.
  *
  * @param PHPParser_Node_Expr $value      Value to pass
  * @param bool                $byRef      Whether to pass by ref
  * @param int                 $line       Line
  * @param null|string         $docComment Nearest doc comment
  */
 public function __construct(PHPParser_Node_Expr $value, $byRef = false, $line = -1, $docComment = null)
 {
     parent::__construct(array('value' => $value, 'byRef' => $byRef), $line, $docComment);
 }
Esempio n. 10
0
 /**
  * Constructs a parameter node.
  *
  * @param string                          $name       Name
  * @param null|PHPParser_Node_Expr        $default    Default value
  * @param null|string|PHPParser_Node_Name $type       Typehint
  * @param bool                            $byRef      Whether is passed by reference
  * @param int                             $line       Line
  * @param null|string                     $docComment Nearest doc comment
  */
 public function __construct($name, $default = null, $type = null, $byRef = false, $line = -1, $docComment = null)
 {
     parent::__construct(array('name' => $name, 'default' => $default, 'type' => $type, 'byRef' => $byRef), $line, $docComment);
 }
Esempio n. 11
0
 /**
  * Constructs a case node.
  *
  * @param null|PHPParser_Node_Expr $conds      Conditions
  * @param PHPParser_Node[]         $stmts      Statements
  * @param int                      $line       Line
  * @param null|string              $docComment Nearest doc comment
  */
 public function __construct(array $conds, array $stmts = array(), $line = -1, $docComment = null)
 {
     parent::__construct(array('conds' => $conds, 'stmts' => $stmts), $line, $docComment);
 }