/** * Constructs a function call argument node. * * @param Expr $value Value to pass * @param bool $byRef Whether to pass by ref * @param bool $unpack Whether to unpack the argument * @param array $attributes Additional attributes */ public function __construct(Expr $value, $byRef = false, $unpack = false, array $attributes = array()) { parent::__construct($attributes); $this->value = $value; $this->byRef = $byRef; $this->unpack = $unpack; }
/** * 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); }
/** * Constructs a parameter node. * * @param string $name Name * @param null|Expr $default Default value * @param null|string|Name $type Typehint * @param bool $byRef Whether is passed by reference * @param bool $variadic Whether this is a variadic argument * @param array $attributes Additional attributes */ public function __construct($name, $default = null, $type = null, $byRef = false, $variadic = false, array $attributes = array()) { parent::__construct(array('type' => $type, 'byRef' => $byRef, 'variadic' => $variadic, 'name' => $name, 'default' => $default), $attributes); if ($variadic && null !== $default) { throw new Error('Variadic parameter cannot have a default value'); } }
/** * Constructs a parameter node. * * @param string $name Name * @param null|Expr $default Default value * @param null|string|Name|NullableType $type Typehint * @param bool $byRef Whether is passed by reference * @param bool $variadic Whether this is a variadic argument * @param array $attributes Additional attributes */ public function __construct($name, Expr $default = null, $type = null, $byRef = false, $variadic = false, array $attributes = array()) { parent::__construct($attributes); $this->type = $type; $this->byRef = $byRef; $this->variadic = $variadic; $this->name = $name; $this->default = $default; }
/** * 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($attributes); $this->parts = $parts; }
/** * Constructs a parameter node. * * @param string $name Name * @param null|Expr $default Default value * @param null|string|Name $type Typehint * @param bool $byRef Whether is passed by reference * @param bool $variadic Whether this is a variadic argument * @param array $attributes Additional attributes */ public function __construct($name, Expr $default = null, $type = null, $byRef = false, $variadic = false, array $attributes = array()) { parent::__construct(null, $attributes); $this->type = $type; $this->byRef = $byRef; $this->variadic = $variadic; $this->name = $name; $this->default = $default; if ($variadic && null !== $default) { throw new Error('Variadic parameter cannot have a default value', $default->getAttributes()); } }
/** * Constructs a name node. * * @param string|array|self $name Name as string, part array or Name instance (copy ctor) * @param array $attributes Additional attributes */ public function __construct($name, array $attributes = array()) { parent::__construct($attributes); $this->parts = self::prepareName($name); }
/** * Constructs a const node for use in class const and const statements. * * @param string $name Name * @param Expr $value Value * @param array $attributes Additional attributes */ public function __construct($name, Expr $value, array $attributes = array()) { parent::__construct(null, $attributes); $this->name = $name; $this->value = $value; }
/** * Constructs a const node for use in class const and const statements. * * @param string $name Name * @param Expr $value Value * @param array $attributes Additional attributes */ public function __construct($name, Expr $value, array $attributes = array()) { parent::__construct(array('name' => $name, 'value' => $value), $attributes); }
public function __construct($value, array $attributes = array()) { parent::__construct($attributes); }
/** * @param string $type * @param string $message * @param \PhpParser\NodeAbstract $expr * @return bool */ public function notice($type, $message, \PhpParser\NodeAbstract $expr) { $filepath = $this->scope ? $this->scope->getFilepath() : $this->scopePointer->getObject()->getFilepath(); $code = file($filepath); $this->output->writeln('<comment>Notice: ' . $message . " in {$filepath} on {$expr->getLine()} [{$type}]</comment>"); $this->output->writeln(''); if ($this->application->getConfiguration()->valueIsTrue('blame')) { exec("git blame --show-email -L {$expr->getLine()},{$expr->getLine()} " . $filepath, $result); if ($result && isset($result[0])) { $result[0] = trim($result[0]); $this->output->writeln("<comment>\t {$result[0]}</comment>"); } } else { $code = trim($code[$expr->getLine() - 1]); $this->output->writeln("<comment>\t {$code} </comment>"); } $this->output->writeln(''); unset($code); return true; }
/** * Creates a notice message. * * @param string $type * @param string $message * @param \PhpParser\NodeAbstract $expr * @param int $status * @return bool */ public function notice($type, $message, \PhpParser\NodeAbstract $expr, $status = Check::CHECK_SAFE) { $analyzerConfig = $this->application->getConfiguration()->getValue('analyzers'); if ($type == "language_error" && !$analyzerConfig['language_error']['enabled']) { return true; } $filepath = $this->filepath; $code = file($filepath); $this->output->writeln('<comment>Notice: ' . $message . " in {$filepath} on {$expr->getLine()} [{$type}]</comment>"); $this->output->writeln(''); if ($this->application->getConfiguration()->valueIsTrue('blame')) { exec("git blame --show-email -L {$expr->getLine()},{$expr->getLine()} " . $filepath, $result); if ($result && isset($result[0])) { $result[0] = trim($result[0]); $this->output->writeln("<comment>\t {$result[0]}</comment>"); } } else { $code = trim($code[$expr->getLine() - 1]); $this->output->writeln("<comment>\t {$code} </comment>"); } $this->output->writeln(''); $issueCollector = $this->application->getIssuesCollector(); $issueCollector->addIssue(new Issue($type, $message, new IssueLocation($this->filepath, $expr->getLine() - 1))); return true; }
/** * Constructs a function call argument node. * * @param Expr $value Value to pass * @param bool $byRef Whether to pass by ref * @param bool $unpack Whether to unpack the argument * @param array $attributes Additional attributes */ public function __construct(Expr $value, $byRef = false, $unpack = false, array $attributes = array()) { parent::__construct(array('value' => $value, 'byRef' => $byRef, 'unpack' => $unpack), $attributes); }
/** * Constructs a nullable type (wrapping another type). * * @param string|Name $type Type * @param array $attributes Additional attributes */ public function __construct($type, array $attributes = array()) { parent::__construct($attributes); $this->type = $type; }
public function __construct(Comment $comment) { parent::__construct(['startLine' => $comment->getLine(), 'endLine' => $comment->getLine()]); }