/** * 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); }
/** * 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); }
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; } }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * @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()); }
/** * 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); }
/** * 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); }
/** * 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); }