本文整理汇总了PHP中PhpParser\Node\Stmt::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Stmt::__construct方法的具体用法?PHP Stmt::__construct怎么用?PHP Stmt::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpParser\Node\Stmt
的用法示例。
在下文中一共展示了Stmt::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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));
}
}
}