mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-16 22:58:15 +01:00
Add php-cs-fixer config and reformat
The formatting in this project has become something of a mess, because it changed over time. Add a CS fixer config and reformat to the desired style, which is PSR-12, but with sane brace placement.
This commit is contained in:
parent
f62b2bfdec
commit
dd63ddbc24
22
.php-cs-fixer.dist.php
Normal file
22
.php-cs-fixer.dist.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->exclude('PhpParser/Parser')
|
||||
->in(__DIR__ . '/lib')
|
||||
;
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'@PSR12' => true,
|
||||
// We use PSR12 with consistent brace placement.
|
||||
'curly_braces_position' => [
|
||||
'functions_opening_brace' => 'same_line',
|
||||
'classes_opening_brace' => 'same_line',
|
||||
],
|
||||
// declare(strict_types=1) on the same line as <?php.
|
||||
'blank_line_after_opening_tag' => false,
|
||||
// Keep argument formatting for now.
|
||||
'method_argument_space' => ['on_multiline' => 'ignore'],
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
@ -2,12 +2,11 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
interface Builder
|
||||
{
|
||||
interface Builder {
|
||||
/**
|
||||
* Returns the built node.
|
||||
*
|
||||
* @return Node The built node
|
||||
*/
|
||||
public function getNode() : Node;
|
||||
public function getNode(): Node;
|
||||
}
|
||||
|
@ -12,8 +12,7 @@ use PhpParser\Node\Const_;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class ClassConst implements PhpParser\Builder
|
||||
{
|
||||
class ClassConst implements PhpParser\Builder {
|
||||
protected $flags = 0;
|
||||
protected $attributes = [];
|
||||
protected $constants = [];
|
||||
|
@ -9,8 +9,7 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class Class_ extends Declaration
|
||||
{
|
||||
class Class_ extends Declaration {
|
||||
protected $name;
|
||||
|
||||
protected $extends = null;
|
||||
@ -135,7 +134,7 @@ class Class_ extends Declaration
|
||||
*
|
||||
* @return Stmt\Class_ The built class node
|
||||
*/
|
||||
public function getNode() : PhpParser\Node {
|
||||
public function getNode(): PhpParser\Node {
|
||||
return new Stmt\Class_($this->name, [
|
||||
'flags' => $this->flags,
|
||||
'extends' => $this->extends,
|
||||
|
@ -5,8 +5,7 @@ namespace PhpParser\Builder;
|
||||
use PhpParser;
|
||||
use PhpParser\BuilderHelpers;
|
||||
|
||||
abstract class Declaration implements PhpParser\Builder
|
||||
{
|
||||
abstract class Declaration implements PhpParser\Builder {
|
||||
protected $attributes = [];
|
||||
|
||||
abstract public function addStmt($stmt);
|
||||
|
@ -10,8 +10,7 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class EnumCase implements PhpParser\Builder
|
||||
{
|
||||
class EnumCase implements PhpParser\Builder {
|
||||
protected $name;
|
||||
protected $value = null;
|
||||
protected $attributes = [];
|
||||
|
@ -9,8 +9,7 @@ use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class Enum_ extends Declaration
|
||||
{
|
||||
class Enum_ extends Declaration {
|
||||
protected $name;
|
||||
protected $scalarType = null;
|
||||
|
||||
@ -106,7 +105,7 @@ class Enum_ extends Declaration
|
||||
*
|
||||
* @return Stmt\Enum_ The built enum node
|
||||
*/
|
||||
public function getNode() : PhpParser\Node {
|
||||
public function getNode(): PhpParser\Node {
|
||||
return new Stmt\Enum_($this->name, [
|
||||
'scalarType' => $this->scalarType,
|
||||
'implements' => $this->implements,
|
||||
|
@ -5,8 +5,7 @@ namespace PhpParser\Builder;
|
||||
use PhpParser\BuilderHelpers;
|
||||
use PhpParser\Node;
|
||||
|
||||
abstract class FunctionLike extends Declaration
|
||||
{
|
||||
abstract class FunctionLike extends Declaration {
|
||||
protected $returnByRef = false;
|
||||
protected $params = [];
|
||||
|
||||
|
@ -7,8 +7,7 @@ use PhpParser\BuilderHelpers;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class Function_ extends FunctionLike
|
||||
{
|
||||
class Function_ extends FunctionLike {
|
||||
protected $name;
|
||||
protected $stmts = [];
|
||||
|
||||
@ -55,7 +54,7 @@ class Function_ extends FunctionLike
|
||||
*
|
||||
* @return Stmt\Function_ The built function node
|
||||
*/
|
||||
public function getNode() : Node {
|
||||
public function getNode(): Node {
|
||||
return new Stmt\Function_($this->name, [
|
||||
'byRef' => $this->returnByRef,
|
||||
'params' => $this->params,
|
||||
|
@ -8,8 +8,7 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class Interface_ extends Declaration
|
||||
{
|
||||
class Interface_ extends Declaration {
|
||||
protected $name;
|
||||
protected $extends = [];
|
||||
protected $constants = [];
|
||||
@ -83,7 +82,7 @@ class Interface_ extends Declaration
|
||||
*
|
||||
* @return Stmt\Interface_ The built interface node
|
||||
*/
|
||||
public function getNode() : PhpParser\Node {
|
||||
public function getNode(): PhpParser\Node {
|
||||
return new Stmt\Interface_($this->name, [
|
||||
'extends' => $this->extends,
|
||||
'stmts' => array_merge($this->constants, $this->methods),
|
||||
|
@ -8,8 +8,7 @@ use PhpParser\Modifiers;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class Method extends FunctionLike
|
||||
{
|
||||
class Method extends FunctionLike {
|
||||
protected $name;
|
||||
protected $flags = 0;
|
||||
|
||||
@ -134,7 +133,7 @@ class Method extends FunctionLike
|
||||
*
|
||||
* @return Stmt\ClassMethod The built method node
|
||||
*/
|
||||
public function getNode() : Node {
|
||||
public function getNode(): Node {
|
||||
return new Stmt\ClassMethod($this->name, [
|
||||
'flags' => $this->flags,
|
||||
'byRef' => $this->returnByRef,
|
||||
|
@ -7,8 +7,7 @@ use PhpParser\BuilderHelpers;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class Namespace_ extends Declaration
|
||||
{
|
||||
class Namespace_ extends Declaration {
|
||||
private $name;
|
||||
private $stmts = [];
|
||||
|
||||
@ -39,7 +38,7 @@ class Namespace_ extends Declaration
|
||||
*
|
||||
* @return Stmt\Namespace_ The built node
|
||||
*/
|
||||
public function getNode() : Node {
|
||||
public function getNode(): Node {
|
||||
return new Stmt\Namespace_($this->name, $this->stmts, $this->attributes);
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ use PhpParser;
|
||||
use PhpParser\BuilderHelpers;
|
||||
use PhpParser\Node;
|
||||
|
||||
class Param implements PhpParser\Builder
|
||||
{
|
||||
class Param implements PhpParser\Builder {
|
||||
protected $name;
|
||||
|
||||
protected $default = null;
|
||||
@ -100,7 +99,7 @@ class Param implements PhpParser\Builder
|
||||
*
|
||||
* @return Node\Param The built parameter node
|
||||
*/
|
||||
public function getNode() : Node {
|
||||
public function getNode(): Node {
|
||||
return new Node\Param(
|
||||
new Node\Expr\Variable($this->name),
|
||||
$this->default, $this->type, $this->byRef, $this->variadic, [], 0, $this->attributeGroups
|
||||
|
@ -11,8 +11,7 @@ use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\ComplexType;
|
||||
|
||||
class Property implements PhpParser\Builder
|
||||
{
|
||||
class Property implements PhpParser\Builder {
|
||||
protected $name;
|
||||
|
||||
protected $flags = 0;
|
||||
@ -148,7 +147,7 @@ class Property implements PhpParser\Builder
|
||||
*
|
||||
* @return Stmt\Property The built property node
|
||||
*/
|
||||
public function getNode() : PhpParser\Node {
|
||||
public function getNode(): PhpParser\Node {
|
||||
return new Stmt\Property(
|
||||
$this->flags !== 0 ? $this->flags : Modifiers::PUBLIC,
|
||||
[
|
||||
|
@ -7,8 +7,7 @@ use PhpParser\BuilderHelpers;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class TraitUse implements Builder
|
||||
{
|
||||
class TraitUse implements Builder {
|
||||
protected $traits = [];
|
||||
protected $adaptations = [];
|
||||
|
||||
@ -58,7 +57,7 @@ class TraitUse implements Builder
|
||||
*
|
||||
* @return Node The built node
|
||||
*/
|
||||
public function getNode() : Node {
|
||||
public function getNode(): Node {
|
||||
return new Stmt\TraitUse($this->traits, $this->adaptations);
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,7 @@ use PhpParser\Modifiers;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class TraitUseAdaptation implements Builder
|
||||
{
|
||||
class TraitUseAdaptation implements Builder {
|
||||
public const TYPE_UNDEFINED = 0;
|
||||
public const TYPE_ALIAS = 1;
|
||||
public const TYPE_PRECEDENCE = 2;
|
||||
@ -34,7 +33,7 @@ class TraitUseAdaptation implements Builder
|
||||
public function __construct($trait, $method) {
|
||||
$this->type = self::TYPE_UNDEFINED;
|
||||
|
||||
$this->trait = is_null($trait)? null: BuilderHelpers::normalizeName($trait);
|
||||
$this->trait = is_null($trait) ? null : BuilderHelpers::normalizeName($trait);
|
||||
$this->method = BuilderHelpers::normalizeIdentifier($method);
|
||||
}
|
||||
|
||||
@ -136,7 +135,7 @@ class TraitUseAdaptation implements Builder
|
||||
*
|
||||
* @return Node The built node
|
||||
*/
|
||||
public function getNode() : Node {
|
||||
public function getNode(): Node {
|
||||
switch ($this->type) {
|
||||
case self::TYPE_ALIAS:
|
||||
return new Stmt\TraitUseAdaptation\Alias($this->trait, $this->method, $this->modifier, $this->alias);
|
||||
|
@ -7,8 +7,7 @@ use PhpParser\BuilderHelpers;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class Trait_ extends Declaration
|
||||
{
|
||||
class Trait_ extends Declaration {
|
||||
protected $name;
|
||||
protected $uses = [];
|
||||
protected $properties = [];
|
||||
@ -67,7 +66,7 @@ class Trait_ extends Declaration
|
||||
*
|
||||
* @return Stmt\Trait_ The built interface node
|
||||
*/
|
||||
public function getNode() : PhpParser\Node {
|
||||
public function getNode(): PhpParser\Node {
|
||||
return new Stmt\Trait_(
|
||||
$this->name, [
|
||||
'stmts' => array_merge($this->uses, $this->properties, $this->methods),
|
||||
|
@ -7,8 +7,7 @@ use PhpParser\BuilderHelpers;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class Use_ implements Builder
|
||||
{
|
||||
class Use_ implements Builder {
|
||||
protected $name;
|
||||
protected $type;
|
||||
protected $alias = null;
|
||||
@ -41,7 +40,7 @@ class Use_ implements Builder
|
||||
*
|
||||
* @return Stmt\Use_ The built node
|
||||
*/
|
||||
public function getNode() : Node {
|
||||
public function getNode(): Node {
|
||||
return new Stmt\Use_([
|
||||
new Stmt\UseUse($this->name, $this->alias)
|
||||
], $this->type);
|
||||
|
@ -10,8 +10,7 @@ use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
|
||||
class BuilderFactory
|
||||
{
|
||||
class BuilderFactory {
|
||||
/**
|
||||
* Creates an attribute node.
|
||||
*
|
||||
@ -20,7 +19,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Node\Attribute
|
||||
*/
|
||||
public function attribute($name, array $args = []) : Node\Attribute {
|
||||
public function attribute($name, array $args = []): Node\Attribute {
|
||||
return new Node\Attribute(
|
||||
BuilderHelpers::normalizeName($name),
|
||||
$this->args($args)
|
||||
@ -34,7 +33,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Namespace_ The created namespace builder
|
||||
*/
|
||||
public function namespace($name) : Builder\Namespace_ {
|
||||
public function namespace($name): Builder\Namespace_ {
|
||||
return new Builder\Namespace_($name);
|
||||
}
|
||||
|
||||
@ -45,7 +44,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Class_ The created class builder
|
||||
*/
|
||||
public function class(string $name) : Builder\Class_ {
|
||||
public function class(string $name): Builder\Class_ {
|
||||
return new Builder\Class_($name);
|
||||
}
|
||||
|
||||
@ -56,7 +55,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Interface_ The created interface builder
|
||||
*/
|
||||
public function interface(string $name) : Builder\Interface_ {
|
||||
public function interface(string $name): Builder\Interface_ {
|
||||
return new Builder\Interface_($name);
|
||||
}
|
||||
|
||||
@ -67,7 +66,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Trait_ The created trait builder
|
||||
*/
|
||||
public function trait(string $name) : Builder\Trait_ {
|
||||
public function trait(string $name): Builder\Trait_ {
|
||||
return new Builder\Trait_($name);
|
||||
}
|
||||
|
||||
@ -78,7 +77,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Enum_ The created enum builder
|
||||
*/
|
||||
public function enum(string $name) : Builder\Enum_ {
|
||||
public function enum(string $name): Builder\Enum_ {
|
||||
return new Builder\Enum_($name);
|
||||
}
|
||||
|
||||
@ -89,7 +88,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\TraitUse The create trait use builder
|
||||
*/
|
||||
public function useTrait(...$traits) : Builder\TraitUse {
|
||||
public function useTrait(...$traits): Builder\TraitUse {
|
||||
return new Builder\TraitUse(...$traits);
|
||||
}
|
||||
|
||||
@ -101,7 +100,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\TraitUseAdaptation The create trait use adaptation builder
|
||||
*/
|
||||
public function traitUseAdaptation($trait, $method = null) : Builder\TraitUseAdaptation {
|
||||
public function traitUseAdaptation($trait, $method = null): Builder\TraitUseAdaptation {
|
||||
if ($method === null) {
|
||||
$method = $trait;
|
||||
$trait = null;
|
||||
@ -117,7 +116,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Method The created method builder
|
||||
*/
|
||||
public function method(string $name) : Builder\Method {
|
||||
public function method(string $name): Builder\Method {
|
||||
return new Builder\Method($name);
|
||||
}
|
||||
|
||||
@ -128,7 +127,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Param The created parameter builder
|
||||
*/
|
||||
public function param(string $name) : Builder\Param {
|
||||
public function param(string $name): Builder\Param {
|
||||
return new Builder\Param($name);
|
||||
}
|
||||
|
||||
@ -139,7 +138,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Property The created property builder
|
||||
*/
|
||||
public function property(string $name) : Builder\Property {
|
||||
public function property(string $name): Builder\Property {
|
||||
return new Builder\Property($name);
|
||||
}
|
||||
|
||||
@ -150,7 +149,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Function_ The created function builder
|
||||
*/
|
||||
public function function(string $name) : Builder\Function_ {
|
||||
public function function(string $name): Builder\Function_ {
|
||||
return new Builder\Function_($name);
|
||||
}
|
||||
|
||||
@ -161,7 +160,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Use_ The created use builder
|
||||
*/
|
||||
public function use($name) : Builder\Use_ {
|
||||
public function use($name): Builder\Use_ {
|
||||
return new Builder\Use_($name, Use_::TYPE_NORMAL);
|
||||
}
|
||||
|
||||
@ -172,7 +171,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Use_ The created use function builder
|
||||
*/
|
||||
public function useFunction($name) : Builder\Use_ {
|
||||
public function useFunction($name): Builder\Use_ {
|
||||
return new Builder\Use_($name, Use_::TYPE_FUNCTION);
|
||||
}
|
||||
|
||||
@ -183,7 +182,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\Use_ The created use const builder
|
||||
*/
|
||||
public function useConst($name) : Builder\Use_ {
|
||||
public function useConst($name): Builder\Use_ {
|
||||
return new Builder\Use_($name, Use_::TYPE_CONSTANT);
|
||||
}
|
||||
|
||||
@ -195,7 +194,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\ClassConst The created use const builder
|
||||
*/
|
||||
public function classConst($name, $value) : Builder\ClassConst {
|
||||
public function classConst($name, $value): Builder\ClassConst {
|
||||
return new Builder\ClassConst($name, $value);
|
||||
}
|
||||
|
||||
@ -206,7 +205,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Builder\EnumCase The created use const builder
|
||||
*/
|
||||
public function enumCase($name) : Builder\EnumCase {
|
||||
public function enumCase($name): Builder\EnumCase {
|
||||
return new Builder\EnumCase($name);
|
||||
}
|
||||
|
||||
@ -217,7 +216,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Expr
|
||||
*/
|
||||
public function val($value) : Expr {
|
||||
public function val($value): Expr {
|
||||
return BuilderHelpers::normalizeValue($value);
|
||||
}
|
||||
|
||||
@ -228,7 +227,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Expr\Variable
|
||||
*/
|
||||
public function var($name) : Expr\Variable {
|
||||
public function var($name): Expr\Variable {
|
||||
if (!\is_string($name) && !$name instanceof Expr) {
|
||||
throw new \LogicException('Variable name must be string or Expr');
|
||||
}
|
||||
@ -245,7 +244,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Arg[]
|
||||
*/
|
||||
public function args(array $args) : array {
|
||||
public function args(array $args): array {
|
||||
$normalizedArgs = [];
|
||||
foreach ($args as $key => $arg) {
|
||||
if (!($arg instanceof Arg)) {
|
||||
@ -267,7 +266,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Expr\FuncCall
|
||||
*/
|
||||
public function funcCall($name, array $args = []) : Expr\FuncCall {
|
||||
public function funcCall($name, array $args = []): Expr\FuncCall {
|
||||
return new Expr\FuncCall(
|
||||
BuilderHelpers::normalizeNameOrExpr($name),
|
||||
$this->args($args)
|
||||
@ -283,7 +282,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Expr\MethodCall
|
||||
*/
|
||||
public function methodCall(Expr $var, $name, array $args = []) : Expr\MethodCall {
|
||||
public function methodCall(Expr $var, $name, array $args = []): Expr\MethodCall {
|
||||
return new Expr\MethodCall(
|
||||
$var,
|
||||
BuilderHelpers::normalizeIdentifierOrExpr($name),
|
||||
@ -300,7 +299,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Expr\StaticCall
|
||||
*/
|
||||
public function staticCall($class, $name, array $args = []) : Expr\StaticCall {
|
||||
public function staticCall($class, $name, array $args = []): Expr\StaticCall {
|
||||
return new Expr\StaticCall(
|
||||
BuilderHelpers::normalizeNameOrExpr($class),
|
||||
BuilderHelpers::normalizeIdentifierOrExpr($name),
|
||||
@ -316,7 +315,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Expr\New_
|
||||
*/
|
||||
public function new($class, array $args = []) : Expr\New_ {
|
||||
public function new($class, array $args = []): Expr\New_ {
|
||||
return new Expr\New_(
|
||||
BuilderHelpers::normalizeNameOrExpr($class),
|
||||
$this->args($args)
|
||||
@ -330,7 +329,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Expr\ConstFetch
|
||||
*/
|
||||
public function constFetch($name) : Expr\ConstFetch {
|
||||
public function constFetch($name): Expr\ConstFetch {
|
||||
return new Expr\ConstFetch(BuilderHelpers::normalizeName($name));
|
||||
}
|
||||
|
||||
@ -342,7 +341,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Expr\PropertyFetch
|
||||
*/
|
||||
public function propertyFetch(Expr $var, $name) : Expr\PropertyFetch {
|
||||
public function propertyFetch(Expr $var, $name): Expr\PropertyFetch {
|
||||
return new Expr\PropertyFetch($var, BuilderHelpers::normalizeIdentifierOrExpr($name));
|
||||
}
|
||||
|
||||
@ -368,7 +367,7 @@ class BuilderFactory
|
||||
*
|
||||
* @return Concat
|
||||
*/
|
||||
public function concat(...$exprs) : Concat {
|
||||
public function concat(...$exprs): Concat {
|
||||
$numExprs = count($exprs);
|
||||
if ($numExprs < 2) {
|
||||
throw new \LogicException('Expected at least two expressions');
|
||||
@ -385,7 +384,7 @@ class BuilderFactory
|
||||
* @param string|Expr $expr
|
||||
* @return Expr
|
||||
*/
|
||||
private function normalizeStringExpr($expr) : Expr {
|
||||
private function normalizeStringExpr($expr): Expr {
|
||||
if ($expr instanceof Expr) {
|
||||
return $expr;
|
||||
}
|
||||
|
@ -15,8 +15,7 @@ use PhpParser\Node\Stmt;
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class BuilderHelpers
|
||||
{
|
||||
final class BuilderHelpers {
|
||||
/**
|
||||
* Normalizes a node: Converts builder objects to nodes.
|
||||
*
|
||||
@ -24,7 +23,7 @@ final class BuilderHelpers
|
||||
*
|
||||
* @return Node The normalized node
|
||||
*/
|
||||
public static function normalizeNode($node) : Node {
|
||||
public static function normalizeNode($node): Node {
|
||||
if ($node instanceof Builder) {
|
||||
return $node->getNode();
|
||||
}
|
||||
@ -45,7 +44,7 @@ final class BuilderHelpers
|
||||
*
|
||||
* @return Stmt The normalized statement node
|
||||
*/
|
||||
public static function normalizeStmt($node) : Stmt {
|
||||
public static function normalizeStmt($node): Stmt {
|
||||
$node = self::normalizeNode($node);
|
||||
if ($node instanceof Stmt) {
|
||||
return $node;
|
||||
@ -65,7 +64,7 @@ final class BuilderHelpers
|
||||
*
|
||||
* @return Identifier The normalized identifier
|
||||
*/
|
||||
public static function normalizeIdentifier($name) : Identifier {
|
||||
public static function normalizeIdentifier($name): Identifier {
|
||||
if ($name instanceof Identifier) {
|
||||
return $name;
|
||||
}
|
||||
@ -103,7 +102,7 @@ final class BuilderHelpers
|
||||
*
|
||||
* @return Name The normalized name
|
||||
*/
|
||||
public static function normalizeName($name) : Name {
|
||||
public static function normalizeName($name): Name {
|
||||
if ($name instanceof Name) {
|
||||
return $name;
|
||||
}
|
||||
@ -219,7 +218,7 @@ final class BuilderHelpers
|
||||
*
|
||||
* @return Expr The normalized value
|
||||
*/
|
||||
public static function normalizeValue($value) : Expr {
|
||||
public static function normalizeValue($value): Expr {
|
||||
if ($value instanceof Node\Expr) {
|
||||
return $value;
|
||||
}
|
||||
@ -279,7 +278,7 @@ final class BuilderHelpers
|
||||
*
|
||||
* @return Comment\Doc The normalized doc comment
|
||||
*/
|
||||
public static function normalizeDocComment($docComment) : Comment\Doc {
|
||||
public static function normalizeDocComment($docComment): Comment\Doc {
|
||||
if ($docComment instanceof Comment\Doc) {
|
||||
return $docComment;
|
||||
}
|
||||
@ -298,8 +297,7 @@ final class BuilderHelpers
|
||||
*
|
||||
* @return Node\AttributeGroup The Attribute Group
|
||||
*/
|
||||
public static function normalizeAttribute($attribute) : Node\AttributeGroup
|
||||
{
|
||||
public static function normalizeAttribute($attribute): Node\AttributeGroup {
|
||||
if ($attribute instanceof Node\AttributeGroup) {
|
||||
return $attribute;
|
||||
}
|
||||
@ -319,7 +317,7 @@ final class BuilderHelpers
|
||||
*
|
||||
* @return int New modifiers
|
||||
*/
|
||||
public static function addModifier(int $modifiers, int $modifier) : int {
|
||||
public static function addModifier(int $modifiers, int $modifier): int {
|
||||
Stmt\Class_::verifyModifier($modifiers, $modifier);
|
||||
return $modifiers | $modifier;
|
||||
}
|
||||
@ -328,7 +326,7 @@ final class BuilderHelpers
|
||||
* Adds a modifier and returns new modifier bitmask.
|
||||
* @return int New modifiers
|
||||
*/
|
||||
public static function addClassModifier(int $existingModifiers, int $modifierToSet) : int {
|
||||
public static function addClassModifier(int $existingModifiers, int $modifierToSet): int {
|
||||
Stmt\Class_::verifyClassModifier($existingModifiers, $modifierToSet);
|
||||
return $existingModifiers | $modifierToSet;
|
||||
}
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class Comment implements \JsonSerializable
|
||||
{
|
||||
class Comment implements \JsonSerializable {
|
||||
protected $text;
|
||||
protected $startLine;
|
||||
protected $startFilePos;
|
||||
@ -39,7 +38,7 @@ class Comment implements \JsonSerializable
|
||||
*
|
||||
* @return string The comment text (including comment delimiters like /*)
|
||||
*/
|
||||
public function getText() : string {
|
||||
public function getText(): string {
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
@ -48,7 +47,7 @@ class Comment implements \JsonSerializable
|
||||
*
|
||||
* @return int Line number (or -1 if not available)
|
||||
*/
|
||||
public function getStartLine() : int {
|
||||
public function getStartLine(): int {
|
||||
return $this->startLine;
|
||||
}
|
||||
|
||||
@ -57,7 +56,7 @@ class Comment implements \JsonSerializable
|
||||
*
|
||||
* @return int File offset (or -1 if not available)
|
||||
*/
|
||||
public function getStartFilePos() : int {
|
||||
public function getStartFilePos(): int {
|
||||
return $this->startFilePos;
|
||||
}
|
||||
|
||||
@ -66,7 +65,7 @@ class Comment implements \JsonSerializable
|
||||
*
|
||||
* @return int Token offset (or -1 if not available)
|
||||
*/
|
||||
public function getStartTokenPos() : int {
|
||||
public function getStartTokenPos(): int {
|
||||
return $this->startTokenPos;
|
||||
}
|
||||
|
||||
@ -75,7 +74,7 @@ class Comment implements \JsonSerializable
|
||||
*
|
||||
* @return int Line number (or -1 if not available)
|
||||
*/
|
||||
public function getEndLine() : int {
|
||||
public function getEndLine(): int {
|
||||
return $this->endLine;
|
||||
}
|
||||
|
||||
@ -84,7 +83,7 @@ class Comment implements \JsonSerializable
|
||||
*
|
||||
* @return int File offset (or -1 if not available)
|
||||
*/
|
||||
public function getEndFilePos() : int {
|
||||
public function getEndFilePos(): int {
|
||||
return $this->endFilePos;
|
||||
}
|
||||
|
||||
@ -93,7 +92,7 @@ class Comment implements \JsonSerializable
|
||||
*
|
||||
* @return int Token offset (or -1 if not available)
|
||||
*/
|
||||
public function getEndTokenPos() : int {
|
||||
public function getEndTokenPos(): int {
|
||||
return $this->endTokenPos;
|
||||
}
|
||||
|
||||
@ -104,7 +103,7 @@ class Comment implements \JsonSerializable
|
||||
*
|
||||
* @return int Line number
|
||||
*/
|
||||
public function getLine() : int {
|
||||
public function getLine(): int {
|
||||
return $this->startLine;
|
||||
}
|
||||
|
||||
@ -115,7 +114,7 @@ class Comment implements \JsonSerializable
|
||||
*
|
||||
* @return int File offset
|
||||
*/
|
||||
public function getFilePos() : int {
|
||||
public function getFilePos(): int {
|
||||
return $this->startFilePos;
|
||||
}
|
||||
|
||||
@ -126,7 +125,7 @@ class Comment implements \JsonSerializable
|
||||
*
|
||||
* @return int Token offset
|
||||
*/
|
||||
public function getTokenPos() : int {
|
||||
public function getTokenPos(): int {
|
||||
return $this->startTokenPos;
|
||||
}
|
||||
|
||||
@ -135,7 +134,7 @@ class Comment implements \JsonSerializable
|
||||
*
|
||||
* @return string The comment text (including comment delimiters like /*)
|
||||
*/
|
||||
public function __toString() : string {
|
||||
public function __toString(): string {
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
@ -207,7 +206,7 @@ class Comment implements \JsonSerializable
|
||||
* @param string $str String to check
|
||||
* @return int Length in characters. Tabs count as single characters.
|
||||
*/
|
||||
private function getShortestWhitespacePrefixLen(string $str) : int {
|
||||
private function getShortestWhitespacePrefixLen(string $str): int {
|
||||
$lines = explode("\n", $str);
|
||||
$shortestPrefixLen = \INF;
|
||||
foreach ($lines as $line) {
|
||||
@ -224,7 +223,7 @@ class Comment implements \JsonSerializable
|
||||
* @return array
|
||||
* @psalm-return array{nodeType:string, text:mixed, line:mixed, filePos:mixed}
|
||||
*/
|
||||
public function jsonSerialize() : array {
|
||||
public function jsonSerialize(): array {
|
||||
// Technically not a node, but we make it look like one anyway
|
||||
$type = $this instanceof Comment\Doc ? 'Comment_Doc' : 'Comment';
|
||||
return [
|
||||
|
@ -2,6 +2,5 @@
|
||||
|
||||
namespace PhpParser\Comment;
|
||||
|
||||
class Doc extends \PhpParser\Comment
|
||||
{
|
||||
class Doc extends \PhpParser\Comment {
|
||||
}
|
||||
|
@ -2,5 +2,5 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class ConstExprEvaluationException extends \Exception
|
||||
{}
|
||||
class ConstExprEvaluationException extends \Exception {
|
||||
}
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use function array_merge;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Scalar;
|
||||
|
||||
use function array_merge;
|
||||
|
||||
/**
|
||||
* Evaluates constant expressions.
|
||||
*
|
||||
@ -25,8 +26,7 @@ use PhpParser\Node\Scalar;
|
||||
* point to string conversions are affected by the precision ini setting. Secondly, they are also
|
||||
* affected by the LC_NUMERIC locale.
|
||||
*/
|
||||
class ConstExprEvaluator
|
||||
{
|
||||
class ConstExprEvaluator {
|
||||
private $fallbackEvaluator;
|
||||
|
||||
/**
|
||||
@ -38,7 +38,7 @@ class ConstExprEvaluator
|
||||
* @param callable|null $fallbackEvaluator To call if subexpression cannot be evaluated
|
||||
*/
|
||||
public function __construct(?callable $fallbackEvaluator = null) {
|
||||
$this->fallbackEvaluator = $fallbackEvaluator ?? function(Expr $expr) {
|
||||
$this->fallbackEvaluator = $fallbackEvaluator ?? function (Expr $expr) {
|
||||
throw new ConstExprEvaluationException(
|
||||
"Expression of type {$expr->getType()} cannot be evaluated"
|
||||
);
|
||||
@ -63,7 +63,7 @@ class ConstExprEvaluator
|
||||
* @throws ConstExprEvaluationException if the expression cannot be evaluated or an error occurred
|
||||
*/
|
||||
public function evaluateSilently(Expr $expr) {
|
||||
set_error_handler(function($num, $str, $file, $line) {
|
||||
set_error_handler(function ($num, $str, $file, $line) {
|
||||
throw new \ErrorException($str, 0, $num, $file, $line);
|
||||
});
|
||||
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class Error extends \RuntimeException
|
||||
{
|
||||
class Error extends \RuntimeException {
|
||||
protected $rawMessage;
|
||||
protected $attributes;
|
||||
|
||||
@ -29,7 +28,7 @@ class Error extends \RuntimeException
|
||||
*
|
||||
* @return string Error message
|
||||
*/
|
||||
public function getRawMessage() : string {
|
||||
public function getRawMessage(): string {
|
||||
return $this->rawMessage;
|
||||
}
|
||||
|
||||
@ -38,7 +37,7 @@ class Error extends \RuntimeException
|
||||
*
|
||||
* @return int Error start line
|
||||
*/
|
||||
public function getStartLine() : int {
|
||||
public function getStartLine(): int {
|
||||
return $this->attributes['startLine'] ?? -1;
|
||||
}
|
||||
|
||||
@ -47,7 +46,7 @@ class Error extends \RuntimeException
|
||||
*
|
||||
* @return int Error end line
|
||||
*/
|
||||
public function getEndLine() : int {
|
||||
public function getEndLine(): int {
|
||||
return $this->attributes['endLine'] ?? -1;
|
||||
}
|
||||
|
||||
@ -56,7 +55,7 @@ class Error extends \RuntimeException
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes() : array {
|
||||
public function getAttributes(): array {
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
@ -97,7 +96,7 @@ class Error extends \RuntimeException
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasColumnInfo() : bool {
|
||||
public function hasColumnInfo(): bool {
|
||||
return isset($this->attributes['startFilePos'], $this->attributes['endFilePos']);
|
||||
}
|
||||
|
||||
@ -107,7 +106,7 @@ class Error extends \RuntimeException
|
||||
* @param string $code Source code of the file
|
||||
* @return int
|
||||
*/
|
||||
public function getStartColumn(string $code) : int {
|
||||
public function getStartColumn(string $code): int {
|
||||
if (!$this->hasColumnInfo()) {
|
||||
throw new \RuntimeException('Error does not have column information');
|
||||
}
|
||||
@ -121,7 +120,7 @@ class Error extends \RuntimeException
|
||||
* @param string $code Source code of the file
|
||||
* @return int
|
||||
*/
|
||||
public function getEndColumn(string $code) : int {
|
||||
public function getEndColumn(string $code): int {
|
||||
if (!$this->hasColumnInfo()) {
|
||||
throw new \RuntimeException('Error does not have column information');
|
||||
}
|
||||
@ -136,7 +135,7 @@ class Error extends \RuntimeException
|
||||
*
|
||||
* @return string Formatted message
|
||||
*/
|
||||
public function getMessageWithColumnInfo(string $code) : string {
|
||||
public function getMessageWithColumnInfo(string $code): string {
|
||||
return sprintf(
|
||||
'%s from %d:%d to %d:%d', $this->getRawMessage(),
|
||||
$this->getStartLine(), $this->getStartColumn($code),
|
||||
@ -152,7 +151,7 @@ class Error extends \RuntimeException
|
||||
*
|
||||
* @return int 1-based column (relative to start of line)
|
||||
*/
|
||||
private function toColumn(string $code, int $pos) : int {
|
||||
private function toColumn(string $code, int $pos): int {
|
||||
if ($pos > strlen($code)) {
|
||||
throw new \RuntimeException('Invalid position information');
|
||||
}
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
interface ErrorHandler
|
||||
{
|
||||
interface ErrorHandler {
|
||||
/**
|
||||
* Handle an error generated during lexing, parsing or some other operation.
|
||||
*
|
||||
|
@ -10,8 +10,7 @@ use PhpParser\ErrorHandler;
|
||||
*
|
||||
* This allows graceful handling of errors.
|
||||
*/
|
||||
class Collecting implements ErrorHandler
|
||||
{
|
||||
class Collecting implements ErrorHandler {
|
||||
/** @var Error[] Collected errors */
|
||||
private $errors = [];
|
||||
|
||||
@ -24,7 +23,7 @@ class Collecting implements ErrorHandler
|
||||
*
|
||||
* @return Error[]
|
||||
*/
|
||||
public function getErrors() : array {
|
||||
public function getErrors(): array {
|
||||
return $this->errors;
|
||||
}
|
||||
|
||||
@ -33,7 +32,7 @@ class Collecting implements ErrorHandler
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasErrors() : bool {
|
||||
public function hasErrors(): bool {
|
||||
return !empty($this->errors);
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,7 @@ use PhpParser\ErrorHandler;
|
||||
*
|
||||
* This is the default strategy used by all components.
|
||||
*/
|
||||
class Throwing implements ErrorHandler
|
||||
{
|
||||
class Throwing implements ErrorHandler {
|
||||
public function handleError(Error $error) {
|
||||
throw $error;
|
||||
}
|
||||
|
@ -5,8 +5,7 @@ namespace PhpParser\Internal;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class DiffElem
|
||||
{
|
||||
class DiffElem {
|
||||
public const TYPE_KEEP = 0;
|
||||
public const TYPE_REMOVE = 1;
|
||||
public const TYPE_ADD = 2;
|
||||
|
@ -10,8 +10,7 @@ namespace PhpParser\Internal;
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Differ
|
||||
{
|
||||
class Differ {
|
||||
private $isEqual;
|
||||
|
||||
/**
|
||||
|
@ -15,8 +15,7 @@ use PhpParser\Node\Expr;
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class PrintableNewAnonClassNode extends Expr
|
||||
{
|
||||
class PrintableNewAnonClassNode extends Expr {
|
||||
/** @var Node\AttributeGroup[] PHP attribute groups */
|
||||
public $attrGroups;
|
||||
/** @var Node\Arg[] Arguments */
|
||||
@ -51,11 +50,11 @@ class PrintableNewAnonClassNode extends Expr
|
||||
);
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
public function getType(): string {
|
||||
return 'Expr_PrintableNewAnonClass';
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['attrGroups', 'args', 'extends', 'implements', 'stmts'];
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,8 @@
|
||||
namespace PhpParser\Internal;
|
||||
|
||||
if (\PHP_VERSION_ID >= 80000) {
|
||||
class TokenPolyfill extends \PhpToken {}
|
||||
class TokenPolyfill extends \PhpToken {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -78,7 +79,7 @@ class TokenPolyfill {
|
||||
if ($this->id === $entry) {
|
||||
return true;
|
||||
}
|
||||
} else if (\is_string($entry)) {
|
||||
} elseif (\is_string($entry)) {
|
||||
if ($this->text === $entry) {
|
||||
return true;
|
||||
}
|
||||
@ -196,7 +197,7 @@ class TokenPolyfill {
|
||||
if ($j > $i + 1) {
|
||||
if ($id === \T_NS_SEPARATOR) {
|
||||
$id = \T_NAME_FULLY_QUALIFIED;
|
||||
} else if ($id === \T_NAMESPACE) {
|
||||
} elseif ($id === \T_NAMESPACE) {
|
||||
$id = \T_NAME_RELATIVE;
|
||||
} else {
|
||||
$id = \T_NAME_QUALIFIED;
|
||||
|
@ -9,8 +9,7 @@ use PhpParser\Token;
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TokenStream
|
||||
{
|
||||
class TokenStream {
|
||||
/** @var Token[] Tokens (in PhpToken::tokenize() format) */
|
||||
private $tokens;
|
||||
/** @var int[] Map from position to indentation */
|
||||
@ -34,7 +33,7 @@ class TokenStream
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function haveParens(int $startPos, int $endPos) : bool {
|
||||
public function haveParens(int $startPos, int $endPos): bool {
|
||||
return $this->haveTokenImmediatelyBefore($startPos, '(')
|
||||
&& $this->haveTokenImmediatelyAfter($endPos, ')');
|
||||
}
|
||||
@ -47,7 +46,7 @@ class TokenStream
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function haveBraces(int $startPos, int $endPos) : bool {
|
||||
public function haveBraces(int $startPos, int $endPos): bool {
|
||||
return ($this->haveTokenImmediatelyBefore($startPos, '{')
|
||||
|| $this->haveTokenImmediatelyBefore($startPos, T_CURLY_OPEN))
|
||||
&& $this->haveTokenImmediatelyAfter($endPos, '}');
|
||||
@ -63,7 +62,7 @@ class TokenStream
|
||||
*
|
||||
* @return bool Whether the expected token was found
|
||||
*/
|
||||
public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType) : bool {
|
||||
public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType): bool {
|
||||
$tokens = $this->tokens;
|
||||
$pos--;
|
||||
for (; $pos >= 0; $pos--) {
|
||||
@ -88,7 +87,7 @@ class TokenStream
|
||||
*
|
||||
* @return bool Whether the expected token was found
|
||||
*/
|
||||
public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType) : bool {
|
||||
public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType): bool {
|
||||
$tokens = $this->tokens;
|
||||
$pos++;
|
||||
for ($c = \count($tokens); $pos < $c; $pos++) {
|
||||
@ -210,7 +209,7 @@ class TokenStream
|
||||
*
|
||||
* @return int Indentation depth (in spaces)
|
||||
*/
|
||||
public function getIndentationBefore(int $pos) : int {
|
||||
public function getIndentationBefore(int $pos): int {
|
||||
return $this->indentMap[$pos];
|
||||
}
|
||||
|
||||
@ -223,7 +222,7 @@ class TokenStream
|
||||
*
|
||||
* @return string Code corresponding to token range, adjusted for indentation
|
||||
*/
|
||||
public function getTokenCode(int $from, int $to, int $indent) : string {
|
||||
public function getTokenCode(int $from, int $to, int $indent): string {
|
||||
$tokens = $this->tokens;
|
||||
$result = '';
|
||||
for ($pos = $from; $pos < $to; $pos++) {
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class JsonDecoder
|
||||
{
|
||||
class JsonDecoder {
|
||||
/** @var \ReflectionClass[] Node type to reflection class map */
|
||||
private $reflectionClassCache;
|
||||
|
||||
@ -29,7 +28,7 @@ class JsonDecoder
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function decodeArray(array $array) : array {
|
||||
private function decodeArray(array $array): array {
|
||||
$decodedArray = [];
|
||||
foreach ($array as $key => $value) {
|
||||
$decodedArray[$key] = $this->decodeRecursive($value);
|
||||
@ -37,7 +36,7 @@ class JsonDecoder
|
||||
return $decodedArray;
|
||||
}
|
||||
|
||||
private function decodeNode(array $value) : Node {
|
||||
private function decodeNode(array $value): Node {
|
||||
$nodeType = $value['nodeType'];
|
||||
if (!\is_string($nodeType)) {
|
||||
throw new \RuntimeException('Node type must be a string');
|
||||
@ -66,7 +65,7 @@ class JsonDecoder
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function decodeComment(array $value) : Comment {
|
||||
private function decodeComment(array $value): Comment {
|
||||
$className = $value['nodeType'] === 'Comment' ? Comment::class : Comment\Doc::class;
|
||||
if (!isset($value['text'])) {
|
||||
throw new \RuntimeException('Comment must have text');
|
||||
@ -79,7 +78,7 @@ class JsonDecoder
|
||||
);
|
||||
}
|
||||
|
||||
private function reflectionClassFromNodeType(string $nodeType) : \ReflectionClass {
|
||||
private function reflectionClassFromNodeType(string $nodeType): \ReflectionClass {
|
||||
if (!isset($this->reflectionClassCache[$nodeType])) {
|
||||
$className = $this->classNameFromNodeType($nodeType);
|
||||
$this->reflectionClassCache[$nodeType] = new \ReflectionClass($className);
|
||||
@ -87,7 +86,7 @@ class JsonDecoder
|
||||
return $this->reflectionClassCache[$nodeType];
|
||||
}
|
||||
|
||||
private function classNameFromNodeType(string $nodeType) : string {
|
||||
private function classNameFromNodeType(string $nodeType): string {
|
||||
$className = 'PhpParser\\Node\\' . strtr($nodeType, '_', '\\');
|
||||
if (class_exists($className)) {
|
||||
return $className;
|
||||
|
@ -6,8 +6,7 @@ use PhpParser\Parser\Tokens;
|
||||
|
||||
require __DIR__ . '/compatibility_tokens.php';
|
||||
|
||||
class Lexer
|
||||
{
|
||||
class Lexer {
|
||||
/** @var string Code being tokenized */
|
||||
protected $code;
|
||||
/** @var Token[] Array of tokens */
|
||||
|
@ -19,8 +19,7 @@ use PhpParser\Lexer\TokenEmulator\ReverseEmulator;
|
||||
use PhpParser\Lexer\TokenEmulator\TokenEmulator;
|
||||
use PhpParser\PhpVersion;
|
||||
|
||||
class Emulative extends Lexer
|
||||
{
|
||||
class Emulative extends Lexer {
|
||||
/** @var mixed[] Patches used to reverse changes introduced in the code */
|
||||
private $patches = [];
|
||||
|
||||
@ -37,8 +36,7 @@ class Emulative extends Lexer
|
||||
* 'phpVersion' (PhpVersion object or string) that specifies the
|
||||
* version to emulate. Defaults to newest supported.
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
public function __construct(array $options = []) {
|
||||
$version = $options['phpVersion'] ?? PhpVersion::getNewestSupported();
|
||||
if (!$version instanceof PhpVersion) {
|
||||
$version = PhpVersion::fromString($version);
|
||||
@ -68,14 +66,14 @@ class Emulative extends Lexer
|
||||
$emulatorPhpVersion = $emulator->getPhpVersion();
|
||||
if ($this->isForwardEmulationNeeded($emulatorPhpVersion)) {
|
||||
$this->emulators[] = $emulator;
|
||||
} else if ($this->isReverseEmulationNeeded($emulatorPhpVersion)) {
|
||||
} elseif ($this->isReverseEmulationNeeded($emulatorPhpVersion)) {
|
||||
$this->emulators[] = new ReverseEmulator($emulator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startLexing(string $code, ?ErrorHandler $errorHandler = null) {
|
||||
$emulators = array_filter($this->emulators, function($emulator) use($code) {
|
||||
$emulators = array_filter($this->emulators, function ($emulator) use ($code) {
|
||||
return $emulator->isEmulationNeeded($code);
|
||||
});
|
||||
|
||||
@ -118,17 +116,15 @@ class Emulative extends Lexer
|
||||
&& $this->targetPhpVersion->older($emulatorPhpVersion);
|
||||
}
|
||||
|
||||
private function sortPatches()
|
||||
{
|
||||
private function sortPatches() {
|
||||
// Patches may be contributed by different emulators.
|
||||
// Make sure they are sorted by increasing patch position.
|
||||
usort($this->patches, function($p1, $p2) {
|
||||
usort($this->patches, function ($p1, $p2) {
|
||||
return $p1[0] <=> $p2[0];
|
||||
});
|
||||
}
|
||||
|
||||
private function fixupTokens()
|
||||
{
|
||||
private function fixupTokens() {
|
||||
if (\count($this->patches) === 0) {
|
||||
return;
|
||||
}
|
||||
@ -166,7 +162,7 @@ class Emulative extends Lexer
|
||||
$token->text, $patchText, $patchPos - $pos + $localPosDelta, 0
|
||||
);
|
||||
$localPosDelta += $patchTextLen;
|
||||
} else if ($patchType === 'replace') {
|
||||
} elseif ($patchType === 'replace') {
|
||||
// Replace inside the token string
|
||||
$token->text = substr_replace(
|
||||
$token->text, $patchText, $patchPos - $pos + $localPosDelta, $patchTextLen
|
||||
@ -211,7 +207,7 @@ class Emulative extends Lexer
|
||||
if ($patchType === 'add') {
|
||||
$posDelta += strlen($patchText);
|
||||
$lineDelta += substr_count($patchText, "\n");
|
||||
} else if ($patchType === 'remove') {
|
||||
} elseif ($patchType === 'remove') {
|
||||
$posDelta -= strlen($patchText);
|
||||
$lineDelta -= substr_count($patchText, "\n");
|
||||
}
|
||||
|
@ -5,20 +5,16 @@ namespace PhpParser\Lexer\TokenEmulator;
|
||||
use PhpParser\PhpVersion;
|
||||
use PhpParser\Token;
|
||||
|
||||
final class AttributeEmulator extends TokenEmulator
|
||||
{
|
||||
public function getPhpVersion(): PhpVersion
|
||||
{
|
||||
final class AttributeEmulator extends TokenEmulator {
|
||||
public function getPhpVersion(): PhpVersion {
|
||||
return PhpVersion::fromComponents(8, 0);
|
||||
}
|
||||
|
||||
public function isEmulationNeeded(string $code) : bool
|
||||
{
|
||||
public function isEmulationNeeded(string $code): bool {
|
||||
return strpos($code, '#[') !== false;
|
||||
}
|
||||
|
||||
public function emulate(string $code, array $tokens): array
|
||||
{
|
||||
public function emulate(string $code, array $tokens): array {
|
||||
// We need to manually iterate and manage a count because we'll change
|
||||
// the tokens array on the way.
|
||||
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
|
||||
@ -35,8 +31,7 @@ final class AttributeEmulator extends TokenEmulator
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
public function reverseEmulate(string $code, array $tokens): array
|
||||
{
|
||||
public function reverseEmulate(string $code, array $tokens): array {
|
||||
// TODO
|
||||
return $tokens;
|
||||
}
|
||||
|
@ -5,20 +5,16 @@ namespace PhpParser\Lexer\TokenEmulator;
|
||||
use PhpParser\PhpVersion;
|
||||
use PhpParser\Token;
|
||||
|
||||
final class CoaleseEqualTokenEmulator extends TokenEmulator
|
||||
{
|
||||
public function getPhpVersion(): PhpVersion
|
||||
{
|
||||
final class CoaleseEqualTokenEmulator extends TokenEmulator {
|
||||
public function getPhpVersion(): PhpVersion {
|
||||
return PhpVersion::fromComponents(7, 4);
|
||||
}
|
||||
|
||||
public function isEmulationNeeded(string $code): bool
|
||||
{
|
||||
public function isEmulationNeeded(string $code): bool {
|
||||
return strpos($code, '??=') !== false;
|
||||
}
|
||||
|
||||
public function emulate(string $code, array $tokens): array
|
||||
{
|
||||
public function emulate(string $code, array $tokens): array {
|
||||
// We need to manually iterate and manage a count because we'll change
|
||||
// the tokens array on the way
|
||||
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
|
||||
@ -37,8 +33,7 @@ final class CoaleseEqualTokenEmulator extends TokenEmulator
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
public function reverseEmulate(string $code, array $tokens): array
|
||||
{
|
||||
public function reverseEmulate(string $code, array $tokens): array {
|
||||
// ??= was not valid code previously, don't bother.
|
||||
return $tokens;
|
||||
}
|
||||
|
@ -4,25 +4,20 @@ namespace PhpParser\Lexer\TokenEmulator;
|
||||
|
||||
use PhpParser\PhpVersion;
|
||||
|
||||
final class EnumTokenEmulator extends KeywordEmulator
|
||||
{
|
||||
public function getPhpVersion(): PhpVersion
|
||||
{
|
||||
final class EnumTokenEmulator extends KeywordEmulator {
|
||||
public function getPhpVersion(): PhpVersion {
|
||||
return PhpVersion::fromComponents(8, 1);
|
||||
}
|
||||
|
||||
public function getKeywordString(): string
|
||||
{
|
||||
public function getKeywordString(): string {
|
||||
return 'enum';
|
||||
}
|
||||
|
||||
public function getKeywordToken(): int
|
||||
{
|
||||
public function getKeywordToken(): int {
|
||||
return \T_ENUM;
|
||||
}
|
||||
|
||||
protected function isKeywordContext(array $tokens, int $pos): bool
|
||||
{
|
||||
protected function isKeywordContext(array $tokens, int $pos): bool {
|
||||
return parent::isKeywordContext($tokens, $pos)
|
||||
&& isset($tokens[$pos + 2])
|
||||
&& $tokens[$pos + 1]->id === \T_WHITESPACE
|
||||
|
@ -31,8 +31,7 @@ class ExplicitOctalEmulator extends TokenEmulator {
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
private function resolveIntegerOrFloatToken(string $str): int
|
||||
{
|
||||
private function resolveIntegerOrFloatToken(string $str): int {
|
||||
$str = substr($str, 1);
|
||||
$str = str_replace('_', '', $str);
|
||||
$num = octdec($str);
|
||||
|
@ -4,32 +4,27 @@ namespace PhpParser\Lexer\TokenEmulator;
|
||||
|
||||
use PhpParser\PhpVersion;
|
||||
|
||||
final class FlexibleDocStringEmulator extends TokenEmulator
|
||||
{
|
||||
final class FlexibleDocStringEmulator extends TokenEmulator {
|
||||
private const FLEXIBLE_DOC_STRING_REGEX = <<<'REGEX'
|
||||
/<<<[ \t]*(['"]?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)\1\r?\n
|
||||
(?:.*\r?\n)*?
|
||||
(?<indentation>\h*)\2(?![a-zA-Z0-9_\x80-\xff])(?<separator>(?:;?[\r\n])?)/x
|
||||
REGEX;
|
||||
|
||||
public function getPhpVersion(): PhpVersion
|
||||
{
|
||||
public function getPhpVersion(): PhpVersion {
|
||||
return PhpVersion::fromComponents(7, 3);
|
||||
}
|
||||
|
||||
public function isEmulationNeeded(string $code) : bool
|
||||
{
|
||||
public function isEmulationNeeded(string $code): bool {
|
||||
return strpos($code, '<<<') !== false;
|
||||
}
|
||||
|
||||
public function emulate(string $code, array $tokens): array
|
||||
{
|
||||
public function emulate(string $code, array $tokens): array {
|
||||
// Handled by preprocessing + fixup.
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
public function reverseEmulate(string $code, array $tokens): array
|
||||
{
|
||||
public function reverseEmulate(string $code, array $tokens): array {
|
||||
// Not supported.
|
||||
return $tokens;
|
||||
}
|
||||
|
@ -4,20 +4,16 @@ namespace PhpParser\Lexer\TokenEmulator;
|
||||
|
||||
use PhpParser\PhpVersion;
|
||||
|
||||
final class FnTokenEmulator extends KeywordEmulator
|
||||
{
|
||||
public function getPhpVersion(): PhpVersion
|
||||
{
|
||||
final class FnTokenEmulator extends KeywordEmulator {
|
||||
public function getPhpVersion(): PhpVersion {
|
||||
return PhpVersion::fromComponents(7, 4);
|
||||
}
|
||||
|
||||
public function getKeywordString(): string
|
||||
{
|
||||
public function getKeywordString(): string {
|
||||
return 'fn';
|
||||
}
|
||||
|
||||
public function getKeywordToken(): int
|
||||
{
|
||||
public function getKeywordToken(): int {
|
||||
return \T_FN;
|
||||
}
|
||||
}
|
||||
|
@ -4,25 +4,21 @@ namespace PhpParser\Lexer\TokenEmulator;
|
||||
|
||||
use PhpParser\Token;
|
||||
|
||||
abstract class KeywordEmulator extends TokenEmulator
|
||||
{
|
||||
abstract class KeywordEmulator extends TokenEmulator {
|
||||
abstract public function getKeywordString(): string;
|
||||
abstract public function getKeywordToken(): int;
|
||||
|
||||
public function isEmulationNeeded(string $code): bool
|
||||
{
|
||||
public function isEmulationNeeded(string $code): bool {
|
||||
return strpos(strtolower($code), $this->getKeywordString()) !== false;
|
||||
}
|
||||
|
||||
/** @param Token[] $tokens */
|
||||
protected function isKeywordContext(array $tokens, int $pos): bool
|
||||
{
|
||||
protected function isKeywordContext(array $tokens, int $pos): bool {
|
||||
$previousNonSpaceToken = $this->getPreviousNonSpaceToken($tokens, $pos);
|
||||
return $previousNonSpaceToken === null || $previousNonSpaceToken->id !== \T_OBJECT_OPERATOR;
|
||||
}
|
||||
|
||||
public function emulate(string $code, array $tokens): array
|
||||
{
|
||||
public function emulate(string $code, array $tokens): array {
|
||||
$keywordString = $this->getKeywordString();
|
||||
foreach ($tokens as $i => $token) {
|
||||
if ($token->id === T_STRING && strtolower($token->text) === $keywordString
|
||||
@ -35,8 +31,7 @@ abstract class KeywordEmulator extends TokenEmulator
|
||||
}
|
||||
|
||||
/** @param Token[] $tokens */
|
||||
private function getPreviousNonSpaceToken(array $tokens, int $start): ?Token
|
||||
{
|
||||
private function getPreviousNonSpaceToken(array $tokens, int $start): ?Token {
|
||||
for ($i = $start - 1; $i >= 0; --$i) {
|
||||
if ($tokens[$i]->id === T_WHITESPACE) {
|
||||
continue;
|
||||
@ -48,8 +43,7 @@ abstract class KeywordEmulator extends TokenEmulator
|
||||
return null;
|
||||
}
|
||||
|
||||
public function reverseEmulate(string $code, array $tokens): array
|
||||
{
|
||||
public function reverseEmulate(string $code, array $tokens): array {
|
||||
$keywordToken = $this->getKeywordToken();
|
||||
foreach ($tokens as $i => $token) {
|
||||
if ($token->id === $keywordToken) {
|
||||
|
@ -4,20 +4,16 @@ namespace PhpParser\Lexer\TokenEmulator;
|
||||
|
||||
use PhpParser\PhpVersion;
|
||||
|
||||
final class MatchTokenEmulator extends KeywordEmulator
|
||||
{
|
||||
public function getPhpVersion(): PhpVersion
|
||||
{
|
||||
final class MatchTokenEmulator extends KeywordEmulator {
|
||||
public function getPhpVersion(): PhpVersion {
|
||||
return PhpVersion::fromComponents(8, 0);
|
||||
}
|
||||
|
||||
public function getKeywordString(): string
|
||||
{
|
||||
public function getKeywordString(): string {
|
||||
return 'match';
|
||||
}
|
||||
|
||||
public function getKeywordToken(): int
|
||||
{
|
||||
public function getKeywordToken(): int {
|
||||
return \T_MATCH;
|
||||
}
|
||||
}
|
||||
|
@ -5,20 +5,16 @@ namespace PhpParser\Lexer\TokenEmulator;
|
||||
use PhpParser\PhpVersion;
|
||||
use PhpParser\Token;
|
||||
|
||||
final class NullsafeTokenEmulator extends TokenEmulator
|
||||
{
|
||||
public function getPhpVersion(): PhpVersion
|
||||
{
|
||||
final class NullsafeTokenEmulator extends TokenEmulator {
|
||||
public function getPhpVersion(): PhpVersion {
|
||||
return PhpVersion::fromComponents(8, 0);
|
||||
}
|
||||
|
||||
public function isEmulationNeeded(string $code): bool
|
||||
{
|
||||
public function isEmulationNeeded(string $code): bool {
|
||||
return strpos($code, '?->') !== false;
|
||||
}
|
||||
|
||||
public function emulate(string $code, array $tokens): array
|
||||
{
|
||||
public function emulate(string $code, array $tokens): array {
|
||||
// We need to manually iterate and manage a count because we'll change
|
||||
// the tokens array on the way
|
||||
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
|
||||
@ -57,8 +53,7 @@ final class NullsafeTokenEmulator extends TokenEmulator
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
public function reverseEmulate(string $code, array $tokens): array
|
||||
{
|
||||
public function reverseEmulate(string $code, array $tokens): array {
|
||||
// ?-> was not valid code previously, don't bother.
|
||||
return $tokens;
|
||||
}
|
||||
|
@ -5,8 +5,7 @@ namespace PhpParser\Lexer\TokenEmulator;
|
||||
use PhpParser\PhpVersion;
|
||||
use PhpParser\Token;
|
||||
|
||||
final class NumericLiteralSeparatorEmulator extends TokenEmulator
|
||||
{
|
||||
final class NumericLiteralSeparatorEmulator extends TokenEmulator {
|
||||
private const BIN = '(?:0b[01]+(?:_[01]+)*)';
|
||||
private const HEX = '(?:0x[0-9a-f]+(?:_[0-9a-f]+)*)';
|
||||
private const DEC = '(?:[0-9]+(?:_[0-9]+)*)';
|
||||
@ -15,19 +14,16 @@ final class NumericLiteralSeparatorEmulator extends TokenEmulator
|
||||
private const FLOAT = '(?:' . self::SIMPLE_FLOAT . self::EXP . '?|' . self::DEC . self::EXP . ')';
|
||||
private const NUMBER = '~' . self::FLOAT . '|' . self::BIN . '|' . self::HEX . '|' . self::DEC . '~iA';
|
||||
|
||||
public function getPhpVersion(): PhpVersion
|
||||
{
|
||||
public function getPhpVersion(): PhpVersion {
|
||||
return PhpVersion::fromComponents(7, 4);
|
||||
}
|
||||
|
||||
public function isEmulationNeeded(string $code) : bool
|
||||
{
|
||||
public function isEmulationNeeded(string $code): bool {
|
||||
return preg_match('~[0-9]_[0-9]~', $code)
|
||||
|| preg_match('~0x[0-9a-f]+_[0-9a-f]~i', $code);
|
||||
}
|
||||
|
||||
public function emulate(string $code, array $tokens): array
|
||||
{
|
||||
public function emulate(string $code, array $tokens): array {
|
||||
// We need to manually iterate and manage a count because we'll change
|
||||
// the tokens array on the way
|
||||
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
|
||||
@ -76,8 +72,7 @@ final class NumericLiteralSeparatorEmulator extends TokenEmulator
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
private function resolveIntegerOrFloatToken(string $str): int
|
||||
{
|
||||
private function resolveIntegerOrFloatToken(string $str): int {
|
||||
$str = str_replace('_', '', $str);
|
||||
|
||||
if (stripos($str, '0b') === 0) {
|
||||
@ -93,8 +88,7 @@ final class NumericLiteralSeparatorEmulator extends TokenEmulator
|
||||
return is_float($num) ? T_DNUMBER : T_LNUMBER;
|
||||
}
|
||||
|
||||
public function reverseEmulate(string $code, array $tokens): array
|
||||
{
|
||||
public function reverseEmulate(string $code, array $tokens): array {
|
||||
// Numeric separators were not legal code previously, don't bother.
|
||||
return $tokens;
|
||||
}
|
||||
|
@ -4,25 +4,20 @@ namespace PhpParser\Lexer\TokenEmulator;
|
||||
|
||||
use PhpParser\PhpVersion;
|
||||
|
||||
final class ReadonlyTokenEmulator extends KeywordEmulator
|
||||
{
|
||||
public function getPhpVersion(): PhpVersion
|
||||
{
|
||||
final class ReadonlyTokenEmulator extends KeywordEmulator {
|
||||
public function getPhpVersion(): PhpVersion {
|
||||
return PhpVersion::fromComponents(8, 1);
|
||||
}
|
||||
|
||||
public function getKeywordString(): string
|
||||
{
|
||||
public function getKeywordString(): string {
|
||||
return 'readonly';
|
||||
}
|
||||
|
||||
public function getKeywordToken(): int
|
||||
{
|
||||
public function getKeywordToken(): int {
|
||||
return \T_READONLY;
|
||||
}
|
||||
|
||||
protected function isKeywordContext(array $tokens, int $pos): bool
|
||||
{
|
||||
protected function isKeywordContext(array $tokens, int $pos): bool {
|
||||
if (!parent::isKeywordContext($tokens, $pos)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -7,8 +7,7 @@ use PhpParser\PhpVersion;
|
||||
/**
|
||||
* Reverses emulation direction of the inner emulator.
|
||||
*/
|
||||
final class ReverseEmulator extends TokenEmulator
|
||||
{
|
||||
final class ReverseEmulator extends TokenEmulator {
|
||||
/** @var TokenEmulator Inner emulator */
|
||||
private $emulator;
|
||||
|
||||
|
@ -6,8 +6,7 @@ use PhpParser\PhpVersion;
|
||||
use PhpParser\Token;
|
||||
|
||||
/** @internal */
|
||||
abstract class TokenEmulator
|
||||
{
|
||||
abstract class TokenEmulator {
|
||||
abstract public function getPhpVersion(): PhpVersion;
|
||||
|
||||
abstract public function isEmulationNeeded(string $code): bool;
|
||||
|
@ -6,8 +6,7 @@ use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class NameContext
|
||||
{
|
||||
class NameContext {
|
||||
/** @var null|Name Current namespace */
|
||||
protected $namespace;
|
||||
|
||||
@ -142,7 +141,7 @@ class NameContext
|
||||
*
|
||||
* @return Name Resolved name
|
||||
*/
|
||||
public function getResolvedClassName(Name $name) : Name {
|
||||
public function getResolvedClassName(Name $name): Name {
|
||||
return $this->getResolvedName($name, Stmt\Use_::TYPE_NORMAL);
|
||||
}
|
||||
|
||||
@ -154,7 +153,7 @@ class NameContext
|
||||
*
|
||||
* @return Name[] Possible representations of the name
|
||||
*/
|
||||
public function getPossibleNames(string $name, int $type) : array {
|
||||
public function getPossibleNames(string $name, int $type): array {
|
||||
$lcName = strtolower($name);
|
||||
|
||||
if ($type === Stmt\Use_::TYPE_NORMAL) {
|
||||
@ -210,7 +209,7 @@ class NameContext
|
||||
*
|
||||
* @return Name Shortest representation
|
||||
*/
|
||||
public function getShortName(string $name, int $type) : Name {
|
||||
public function getShortName(string $name, int $type): Name {
|
||||
$possibleNames = $this->getPossibleNames($name, $type);
|
||||
|
||||
// Find shortest name
|
||||
@ -224,7 +223,7 @@ class NameContext
|
||||
}
|
||||
}
|
||||
|
||||
return $shortestName;
|
||||
return $shortestName;
|
||||
}
|
||||
|
||||
private function resolveAlias(Name $name, $type) {
|
||||
|
@ -2,28 +2,27 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
interface Node
|
||||
{
|
||||
interface Node {
|
||||
/**
|
||||
* Gets the type of the node.
|
||||
*
|
||||
* @return string Type of the node
|
||||
*/
|
||||
public function getType() : string;
|
||||
public function getType(): string;
|
||||
|
||||
/**
|
||||
* Gets the names of the sub nodes.
|
||||
*
|
||||
* @return array Names of sub nodes
|
||||
*/
|
||||
public function getSubNodeNames() : array;
|
||||
public function getSubNodeNames(): array;
|
||||
|
||||
/**
|
||||
* Gets line the node started in (alias of getStartLine).
|
||||
*
|
||||
* @return int Start line (or -1 if not available)
|
||||
*/
|
||||
public function getLine() : int;
|
||||
public function getLine(): int;
|
||||
|
||||
/**
|
||||
* Gets line the node started in.
|
||||
@ -32,7 +31,7 @@ interface Node
|
||||
*
|
||||
* @return int Start line (or -1 if not available)
|
||||
*/
|
||||
public function getStartLine() : int;
|
||||
public function getStartLine(): int;
|
||||
|
||||
/**
|
||||
* Gets the line the node ended in.
|
||||
@ -41,7 +40,7 @@ interface Node
|
||||
*
|
||||
* @return int End line (or -1 if not available)
|
||||
*/
|
||||
public function getEndLine() : int;
|
||||
public function getEndLine(): int;
|
||||
|
||||
/**
|
||||
* Gets the token offset of the first token that is part of this node.
|
||||
@ -52,7 +51,7 @@ interface Node
|
||||
*
|
||||
* @return int Token start position (or -1 if not available)
|
||||
*/
|
||||
public function getStartTokenPos() : int;
|
||||
public function getStartTokenPos(): int;
|
||||
|
||||
/**
|
||||
* Gets the token offset of the last token that is part of this node.
|
||||
@ -63,7 +62,7 @@ interface Node
|
||||
*
|
||||
* @return int Token end position (or -1 if not available)
|
||||
*/
|
||||
public function getEndTokenPos() : int;
|
||||
public function getEndTokenPos(): int;
|
||||
|
||||
/**
|
||||
* Gets the file offset of the first character that is part of this node.
|
||||
@ -72,7 +71,7 @@ interface Node
|
||||
*
|
||||
* @return int File start position (or -1 if not available)
|
||||
*/
|
||||
public function getStartFilePos() : int;
|
||||
public function getStartFilePos(): int;
|
||||
|
||||
/**
|
||||
* Gets the file offset of the last character that is part of this node.
|
||||
@ -81,7 +80,7 @@ interface Node
|
||||
*
|
||||
* @return int File end position (or -1 if not available)
|
||||
*/
|
||||
public function getEndFilePos() : int;
|
||||
public function getEndFilePos(): int;
|
||||
|
||||
/**
|
||||
* Gets all comments directly preceding this node.
|
||||
@ -90,7 +89,7 @@ interface Node
|
||||
*
|
||||
* @return Comment[]
|
||||
*/
|
||||
public function getComments() : array;
|
||||
public function getComments(): array;
|
||||
|
||||
/**
|
||||
* Gets the doc comment of the node.
|
||||
@ -123,7 +122,7 @@ interface Node
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAttribute(string $key) : bool;
|
||||
public function hasAttribute(string $key): bool;
|
||||
|
||||
/**
|
||||
* Returns the value of an attribute.
|
||||
@ -140,7 +139,7 @@ interface Node
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes() : array;
|
||||
public function getAttributes(): array;
|
||||
|
||||
/**
|
||||
* Replaces all the attributes of this node.
|
||||
|
@ -4,8 +4,7 @@ namespace PhpParser\Node;
|
||||
|
||||
use PhpParser\NodeAbstract;
|
||||
|
||||
class Arg extends NodeAbstract
|
||||
{
|
||||
class Arg extends NodeAbstract {
|
||||
/** @var Identifier|null Parameter name (for named parameters) */
|
||||
public $name;
|
||||
/** @var Expr Value to pass */
|
||||
@ -35,11 +34,11 @@ class Arg extends NodeAbstract
|
||||
$this->unpack = $unpack;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['name', 'value', 'byRef', 'unpack'];
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Arg';
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,7 @@ namespace PhpParser\Node;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\NodeAbstract;
|
||||
|
||||
class Attribute extends NodeAbstract
|
||||
{
|
||||
class Attribute extends NodeAbstract {
|
||||
/** @var Name Attribute name */
|
||||
public $name;
|
||||
|
||||
@ -24,11 +23,11 @@ class Attribute extends NodeAbstract
|
||||
$this->args = $args;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['name', 'args'];
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
public function getType(): string {
|
||||
return 'Attribute';
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ namespace PhpParser\Node;
|
||||
|
||||
use PhpParser\NodeAbstract;
|
||||
|
||||
class AttributeGroup extends NodeAbstract
|
||||
{
|
||||
class AttributeGroup extends NodeAbstract {
|
||||
/** @var Attribute[] Attributes */
|
||||
public $attrs;
|
||||
|
||||
@ -18,11 +17,11 @@ class AttributeGroup extends NodeAbstract
|
||||
$this->attrs = $attrs;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['attrs'];
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
public function getType(): string {
|
||||
return 'AttributeGroup';
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ namespace PhpParser\Node;
|
||||
|
||||
use PhpParser\NodeAbstract;
|
||||
|
||||
class ClosureUse extends NodeAbstract
|
||||
{
|
||||
class ClosureUse extends NodeAbstract {
|
||||
/** @var Expr\Variable Variable to use */
|
||||
public $var;
|
||||
/** @var bool Whether to use by reference */
|
||||
@ -24,11 +23,11 @@ class ClosureUse extends NodeAbstract
|
||||
$this->byRef = $byRef;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['var', 'byRef'];
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'ClosureUse';
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,5 @@ use PhpParser\NodeAbstract;
|
||||
*
|
||||
* It does not provide any shared behavior and exists only for type-checking purposes.
|
||||
*/
|
||||
abstract class ComplexType extends NodeAbstract
|
||||
{
|
||||
abstract class ComplexType extends NodeAbstract {
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ namespace PhpParser\Node;
|
||||
|
||||
use PhpParser\NodeAbstract;
|
||||
|
||||
class Const_ extends NodeAbstract
|
||||
{
|
||||
class Const_ extends NodeAbstract {
|
||||
/** @var Identifier Name */
|
||||
public $name;
|
||||
/** @var Expr Value */
|
||||
@ -27,11 +26,11 @@ class Const_ extends NodeAbstract
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['name', 'value'];
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
public function getType(): string {
|
||||
return 'Const';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,5 @@ namespace PhpParser\Node;
|
||||
|
||||
use PhpParser\NodeAbstract;
|
||||
|
||||
abstract class Expr extends NodeAbstract
|
||||
{
|
||||
abstract class Expr extends NodeAbstract {
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
class ArrayDimFetch extends Expr
|
||||
{
|
||||
class ArrayDimFetch extends Expr {
|
||||
/** @var Expr Variable */
|
||||
public $var;
|
||||
/** @var null|Expr Array index / dim */
|
||||
@ -24,11 +23,11 @@ class ArrayDimFetch extends Expr
|
||||
$this->dim = $dim;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['var', 'dim'];
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_ArrayDimFetch';
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
class ArrayItem extends Expr
|
||||
{
|
||||
class ArrayItem extends Expr {
|
||||
/** @var null|Expr Key */
|
||||
public $key;
|
||||
/** @var Expr Value */
|
||||
@ -31,11 +30,11 @@ class ArrayItem extends Expr
|
||||
$this->unpack = $unpack;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['key', 'value', 'byRef', 'unpack'];
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
public function getType(): string {
|
||||
return 'Expr_ArrayItem';
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
class Array_ extends Expr
|
||||
{
|
||||
class Array_ extends Expr {
|
||||
// For use in "kind" attribute
|
||||
public const KIND_LONG = 1; // array() syntax
|
||||
public const KIND_SHORT = 2; // [] syntax
|
||||
@ -24,11 +23,11 @@ class Array_ extends Expr
|
||||
$this->items = $items;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['items'];
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_Array';
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
|
||||
class ArrowFunction extends Expr implements FunctionLike
|
||||
{
|
||||
class ArrowFunction extends Expr implements FunctionLike {
|
||||
/** @var bool */
|
||||
public $static;
|
||||
|
||||
@ -46,15 +45,15 @@ class ArrowFunction extends Expr implements FunctionLike
|
||||
$this->attrGroups = $subNodes['attrGroups'] ?? [];
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['attrGroups', 'static', 'byRef', 'params', 'returnType', 'expr'];
|
||||
}
|
||||
|
||||
public function returnsByRef() : bool {
|
||||
public function returnsByRef(): bool {
|
||||
return $this->byRef;
|
||||
}
|
||||
|
||||
public function getParams() : array {
|
||||
public function getParams(): array {
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
@ -62,18 +61,18 @@ class ArrowFunction extends Expr implements FunctionLike
|
||||
return $this->returnType;
|
||||
}
|
||||
|
||||
public function getAttrGroups() : array {
|
||||
public function getAttrGroups(): array {
|
||||
return $this->attrGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Node\Stmt\Return_[]
|
||||
*/
|
||||
public function getStmts() : array {
|
||||
public function getStmts(): array {
|
||||
return [new Node\Stmt\Return_($this->expr)];
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
public function getType(): string {
|
||||
return 'Expr_ArrowFunction';
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
class Assign extends Expr
|
||||
{
|
||||
class Assign extends Expr {
|
||||
/** @var Expr Variable */
|
||||
public $var;
|
||||
/** @var Expr Expression */
|
||||
@ -24,11 +23,11 @@ class Assign extends Expr
|
||||
$this->expr = $expr;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['var', 'expr'];
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_Assign';
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
abstract class AssignOp extends Expr
|
||||
{
|
||||
abstract class AssignOp extends Expr {
|
||||
/** @var Expr Variable */
|
||||
public $var;
|
||||
/** @var Expr Expression */
|
||||
@ -24,7 +23,7 @@ abstract class AssignOp extends Expr
|
||||
$this->expr = $expr;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['var', 'expr'];
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class BitwiseAnd extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class BitwiseAnd extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_BitwiseAnd';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class BitwiseOr extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class BitwiseOr extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_BitwiseOr';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class BitwiseXor extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class BitwiseXor extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_BitwiseXor';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Coalesce extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class Coalesce extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_Coalesce';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Concat extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class Concat extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_Concat';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Div extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class Div extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_Div';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Minus extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class Minus extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_Minus';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Mod extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class Mod extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_Mod';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Mul extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class Mul extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_Mul';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Plus extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class Plus extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_Plus';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Pow extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class Pow extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_Pow';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class ShiftLeft extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class ShiftLeft extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_ShiftLeft';
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ namespace PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class ShiftRight extends AssignOp
|
||||
{
|
||||
public function getType() : string {
|
||||
class ShiftRight extends AssignOp {
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignOp_ShiftRight';
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
class AssignRef extends Expr
|
||||
{
|
||||
class AssignRef extends Expr {
|
||||
/** @var Expr Variable reference is assigned to */
|
||||
public $var;
|
||||
/** @var Expr Variable which is referenced */
|
||||
@ -24,11 +23,11 @@ class AssignRef extends Expr
|
||||
$this->expr = $expr;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['var', 'expr'];
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_AssignRef';
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
abstract class BinaryOp extends Expr
|
||||
{
|
||||
abstract class BinaryOp extends Expr {
|
||||
/** @var Expr The left hand side expression */
|
||||
public $left;
|
||||
/** @var Expr The right hand side expression */
|
||||
@ -24,7 +23,7 @@ abstract class BinaryOp extends Expr
|
||||
$this->right = $right;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
public function getSubNodeNames(): array {
|
||||
return ['left', 'right'];
|
||||
}
|
||||
|
||||
@ -36,5 +35,5 @@ abstract class BinaryOp extends Expr
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getOperatorSigil() : string;
|
||||
abstract public function getOperatorSigil(): string;
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class BitwiseAnd extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class BitwiseAnd extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '&';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_BitwiseAnd';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class BitwiseOr extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class BitwiseOr extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '|';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_BitwiseOr';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class BitwiseXor extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class BitwiseXor extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '^';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_BitwiseXor';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class BooleanAnd extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class BooleanAnd extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '&&';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_BooleanAnd';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class BooleanOr extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class BooleanOr extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '||';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_BooleanOr';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class Coalesce extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class Coalesce extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '??';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_Coalesce';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class Concat extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class Concat extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '.';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_Concat';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class Div extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class Div extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '/';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_Div';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class Equal extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class Equal extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '==';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_Equal';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class Greater extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class Greater extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '>';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_Greater';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class GreaterOrEqual extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class GreaterOrEqual extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '>=';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_GreaterOrEqual';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class Identical extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class Identical extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '===';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_Identical';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class LogicalAnd extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class LogicalAnd extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return 'and';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_LogicalAnd';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class LogicalOr extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class LogicalOr extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return 'or';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_LogicalOr';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class LogicalXor extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class LogicalXor extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return 'xor';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_LogicalXor';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class Minus extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class Minus extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '-';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_Minus';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class Mod extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class Mod extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '%';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_Mod';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class Mul extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class Mul extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '*';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_Mul';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class NotEqual extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class NotEqual extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '!=';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_NotEqual';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class NotIdentical extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class NotIdentical extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '!==';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_NotIdentical';
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
|
||||
class Plus extends BinaryOp
|
||||
{
|
||||
public function getOperatorSigil() : string {
|
||||
class Plus extends BinaryOp {
|
||||
public function getOperatorSigil(): string {
|
||||
return '+';
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
|
||||
public function getType(): string {
|
||||
return 'Expr_BinaryOp_Plus';
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user