Inheritance: implements phpparser\Node, implements JsonSerializable
Ejemplo n.º 1
0
Archivo: Arg.php Proyecto: saj696/pipe
 /**
  * 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;
 }
Ejemplo 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);
 }
Ejemplo n.º 3
0
 /**
  * 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');
     }
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
Ejemplo n.º 5
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($attributes);
     $this->parts = $parts;
 }
Ejemplo n.º 6
0
 /**
  * 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());
     }
 }
Ejemplo n.º 7
0
 /**
  * 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);
 }
Ejemplo n.º 8
0
 /**
  * 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;
 }
Ejemplo n.º 9
0
 /**
  * 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);
 }
Ejemplo n.º 10
0
 public function __construct($value, array $attributes = array())
 {
     parent::__construct($attributes);
 }
Ejemplo n.º 11
0
 /**
  * @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;
 }
Ejemplo n.º 12
0
 /**
  * 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;
 }
Ejemplo n.º 13
0
 /**
  * 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);
 }
Ejemplo n.º 14
0
 /**
  * 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;
 }
Ejemplo n.º 15
0
 public function __construct(Comment $comment)
 {
     parent::__construct(['startLine' => $comment->getLine(), 'endLine' => $comment->getLine()]);
 }