code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
public function addStmt($stmt) { $this->stmts[] = BuilderHelpers::normalizeStmt($stmt); return $this; }
Adds a statement. @param Node|PhpParser\Builder $stmt The statement to add @return $this The builder instance (for fluid interface)
addStmt
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php
MIT
public function getNode() : Node { return new Stmt\Namespace_($this->name, $this->stmts, $this->attributes); }
Returns the built node. @return Stmt\Namespace_ The built node
getNode
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php
MIT
public function __construct(string $name) { $this->name = $name; }
Creates a parameter builder. @param string $name Name of the parameter
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function setDefault($value) { $this->default = BuilderHelpers::normalizeValue($value); return $this; }
Sets default value for the parameter. @param mixed $value Default value to use @return $this The builder instance (for fluid interface)
setDefault
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function setType($type) { $this->type = BuilderHelpers::normalizeType($type); if ($this->type == 'void') { throw new \LogicException('Parameter type cannot be void'); } return $this; }
Sets type for the parameter. @param string|Node\Name|Node\Identifier|Node\ComplexType $type Parameter type @return $this The builder instance (for fluid interface)
setType
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function makeByRef() { $this->byRef = \true; return $this; }
Make the parameter accept the value by reference. @return $this The builder instance (for fluid interface)
makeByRef
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function makeVariadic() { $this->variadic = \true; return $this; }
Make the parameter variadic @return $this The builder instance (for fluid interface)
makeVariadic
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function makePublic() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC); return $this; }
Makes the (promoted) parameter public. @return $this The builder instance (for fluid interface)
makePublic
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function makeProtected() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED); return $this; }
Makes the (promoted) parameter protected. @return $this The builder instance (for fluid interface)
makeProtected
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function makePrivate() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE); return $this; }
Makes the (promoted) parameter private. @return $this The builder instance (for fluid interface)
makePrivate
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function makeReadonly() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::READONLY); return $this; }
Makes the (promoted) parameter readonly. @return $this The builder instance (for fluid interface)
makeReadonly
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function makePrivateSet() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE_SET); return $this; }
Gives the promoted property private(set) visibility. @return $this The builder instance (for fluid interface)
makePrivateSet
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function makeProtectedSet() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED_SET); return $this; }
Gives the promoted property protected(set) visibility. @return $this The builder instance (for fluid interface)
makeProtectedSet
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; }
Adds an attribute group. @param Node\Attribute|Node\AttributeGroup $attribute @return $this The builder instance (for fluid interface)
addAttribute
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function getNode() : Node { return new Node\Param(new Node\Expr\Variable($this->name), $this->default, $this->type, $this->byRef, $this->variadic, [], $this->flags, $this->attributeGroups); }
Returns the built parameter node. @return Node\Param The built parameter node
getNode
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
MIT
public function __construct(string $name) { $this->name = $name; }
Creates a property builder. @param string $name Name of the property
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function makePublic() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC); return $this; }
Makes the property public. @return $this The builder instance (for fluid interface)
makePublic
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function makeProtected() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED); return $this; }
Makes the property protected. @return $this The builder instance (for fluid interface)
makeProtected
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function makePrivate() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE); return $this; }
Makes the property private. @return $this The builder instance (for fluid interface)
makePrivate
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function makeStatic() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::STATIC); return $this; }
Makes the property static. @return $this The builder instance (for fluid interface)
makeStatic
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function makeReadonly() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::READONLY); return $this; }
Makes the property readonly. @return $this The builder instance (for fluid interface)
makeReadonly
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function makeAbstract() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::ABSTRACT); return $this; }
Makes the property abstract. Requires at least one property hook to be specified as well. @return $this The builder instance (for fluid interface)
makeAbstract
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function makeFinal() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::FINAL); return $this; }
Makes the property final. @return $this The builder instance (for fluid interface)
makeFinal
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function makePrivateSet() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE_SET); return $this; }
Gives the property private(set) visibility. @return $this The builder instance (for fluid interface)
makePrivateSet
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function makeProtectedSet() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED_SET); return $this; }
Gives the property protected(set) visibility. @return $this The builder instance (for fluid interface)
makeProtectedSet
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function setDefault($value) { $this->default = BuilderHelpers::normalizeValue($value); return $this; }
Sets default value for the property. @param mixed $value Default value to use @return $this The builder instance (for fluid interface)
setDefault
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function setDocComment($docComment) { $this->attributes = ['comments' => [BuilderHelpers::normalizeDocComment($docComment)]]; return $this; }
Sets doc comment for the property. @param PhpParser\Comment\Doc|string $docComment Doc comment to set @return $this The builder instance (for fluid interface)
setDocComment
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function setType($type) { $this->type = BuilderHelpers::normalizeType($type); return $this; }
Sets the property type for PHP 7.4+. @param string|Name|Identifier|ComplexType $type @return $this
setType
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; }
Adds an attribute group. @param Node\Attribute|Node\AttributeGroup $attribute @return $this The builder instance (for fluid interface)
addAttribute
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function addHook(Node\PropertyHook $hook) { $this->hooks[] = $hook; return $this; }
Adds a property hook. @return $this The builder instance (for fluid interface)
addHook
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function getNode() : PhpParser\Node { if ($this->flags & Modifiers::ABSTRACT && !$this->hooks) { throw new PhpParser\Error('Only hooked properties may be declared abstract'); } return new Stmt\Property($this->flags !== 0 ? $this->flags : Modifiers::PUBLIC, [new Node\PropertyItem($this->name, $this->default)], $this->attributes, $this->type, $this->attributeGroups, $this->hooks); }
Returns the built class node. @return Stmt\Property The built property node
getNode
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php
MIT
public function __construct(...$traits) { foreach ($traits as $trait) { $this->and($trait); } }
Creates a trait use builder. @param Node\Name|string ...$traits Names of used traits
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php
MIT
public function and($trait) { $this->traits[] = BuilderHelpers::normalizeName($trait); return $this; }
Adds used trait. @param Node\Name|string $trait Trait name @return $this The builder instance (for fluid interface)
and
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php
MIT
public function with($adaptation) { $adaptation = BuilderHelpers::normalizeNode($adaptation); if (!$adaptation instanceof Stmt\TraitUseAdaptation) { throw new \LogicException('Adaptation must have type TraitUseAdaptation'); } $this->adaptations[] = $adaptation; return $this; }
Adds trait adaptation. @param Stmt\TraitUseAdaptation|Builder\TraitUseAdaptation $adaptation Trait adaptation @return $this The builder instance (for fluid interface)
with
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php
MIT
public function getNode() : Node { return new Stmt\TraitUse($this->traits, $this->adaptations); }
Returns the built node. @return Node The built node
getNode
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php
MIT
public function __construct($trait, $method) { $this->type = self::TYPE_UNDEFINED; $this->trait = \is_null($trait) ? null : BuilderHelpers::normalizeName($trait); $this->method = BuilderHelpers::normalizeIdentifier($method); }
Creates a trait use adaptation builder. @param Node\Name|string|null $trait Name of adapted trait @param Node\Identifier|string $method Name of adapted method
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
MIT
public function as($alias) { if ($this->type === self::TYPE_UNDEFINED) { $this->type = self::TYPE_ALIAS; } if ($this->type !== self::TYPE_ALIAS) { throw new \LogicException('Cannot set alias for not alias adaptation buider'); } $this->alias = BuilderHelpers::normalizeIdentifier($alias); return $this; }
Sets alias of method. @param Node\Identifier|string $alias Alias for adapted method @return $this The builder instance (for fluid interface)
as
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
MIT
public function makePublic() { $this->setModifier(Modifiers::PUBLIC); return $this; }
Sets adapted method public. @return $this The builder instance (for fluid interface)
makePublic
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
MIT
public function makeProtected() { $this->setModifier(Modifiers::PROTECTED); return $this; }
Sets adapted method protected. @return $this The builder instance (for fluid interface)
makeProtected
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
MIT
public function makePrivate() { $this->setModifier(Modifiers::PRIVATE); return $this; }
Sets adapted method private. @return $this The builder instance (for fluid interface)
makePrivate
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
MIT
public function insteadof(...$traits) { if ($this->type === self::TYPE_UNDEFINED) { if (\is_null($this->trait)) { throw new \LogicException('Precedence adaptation must have trait'); } $this->type = self::TYPE_PRECEDENCE; } if ($this->type !== self::TYPE_PRECEDENCE) { throw new \LogicException('Cannot add overwritten traits for not precedence adaptation buider'); } foreach ($traits as $trait) { $this->insteadof[] = BuilderHelpers::normalizeName($trait); } return $this; }
Adds overwritten traits. @param Node\Name|string ...$traits Traits for overwrite @return $this The builder instance (for fluid interface)
insteadof
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
MIT
public function getNode() : Node { switch ($this->type) { case self::TYPE_ALIAS: return new Stmt\TraitUseAdaptation\Alias($this->trait, $this->method, $this->modifier, $this->alias); case self::TYPE_PRECEDENCE: return new Stmt\TraitUseAdaptation\Precedence($this->trait, $this->method, $this->insteadof); default: throw new \LogicException('Type of adaptation is not defined'); } }
Returns the built node. @return Node The built node
getNode
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php
MIT
public function __construct(string $name) { $this->name = $name; }
Creates an interface builder. @param string $name Name of the interface
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php
MIT
public function addStmt($stmt) { $stmt = BuilderHelpers::normalizeNode($stmt); if ($stmt instanceof Stmt\Property) { $this->properties[] = $stmt; } elseif ($stmt instanceof Stmt\ClassMethod) { $this->methods[] = $stmt; } elseif ($stmt instanceof Stmt\TraitUse) { $this->uses[] = $stmt; } elseif ($stmt instanceof Stmt\ClassConst) { $this->constants[] = $stmt; } else { throw new \LogicException(\sprintf('Unexpected node of type "%s"', $stmt->getType())); } return $this; }
Adds a statement. @param Stmt|PhpParser\Builder $stmt The statement to add @return $this The builder instance (for fluid interface)
addStmt
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php
MIT
public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; }
Adds an attribute group. @param Node\Attribute|Node\AttributeGroup $attribute @return $this The builder instance (for fluid interface)
addAttribute
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php
MIT
public function getNode() : PhpParser\Node { return new Stmt\Trait_($this->name, ['stmts' => \array_merge($this->uses, $this->constants, $this->properties, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes); }
Returns the built trait node. @return Stmt\Trait_ The built interface node
getNode
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php
MIT
public function __construct($name, int $type) { $this->name = BuilderHelpers::normalizeName($name); $this->type = $type; }
Creates a name use (alias) builder. @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias @param Stmt\Use_::TYPE_* $type One of the Stmt\Use_::TYPE_* constants
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php
MIT
public function as(string $alias) { $this->alias = $alias; return $this; }
Sets alias for used name. @param string $alias Alias to use (last component of full name by default) @return $this The builder instance (for fluid interface)
as
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php
MIT
public function getNode() : Node { return new Stmt\Use_([new Node\UseItem($this->name, $this->alias)], $this->type); }
Returns the built node. @return Stmt\Use_ The built node
getNode
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php
MIT
public function hasErrors() : bool { return !empty($this->errors); }
Check whether there are any errors.
hasErrors
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php
MIT
public function __construct(int $type, $old, $new) { $this->type = $type; $this->old = $old; $this->new = $new; }
@param int $type One of the TYPE_* constants @param mixed $old Is null for add operations @param mixed $new Is null for remove operations
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/DiffElem.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/DiffElem.php
MIT
public function __construct(callable $isEqual) { $this->isEqual = $isEqual; }
Create differ over the given equality relation. @param callable(T, T): bool $isEqual Equality relation
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
MIT
public function diff(array $old, array $new) : array { $old = \array_values($old); $new = \array_values($new); list($trace, $x, $y) = $this->calculateTrace($old, $new); return $this->extractDiff($trace, $x, $y, $old, $new); }
Calculate diff (edit script) from $old to $new. @param T[] $old Original array @param T[] $new New array @return DiffElem[] Diff (edit script)
diff
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
MIT
public function diffWithReplacements(array $old, array $new) : array { return $this->coalesceReplacements($this->diff($old, $new)); }
Calculate diff, including "replace" operations. If a sequence of remove operations is followed by the same number of add operations, these will be coalesced into replace operations. @param T[] $old Original array @param T[] $new New array @return DiffElem[] Diff (edit script), including replace operations
diffWithReplacements
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
MIT
private function calculateTrace(array $old, array $new) : array { $n = \count($old); $m = \count($new); $max = $n + $m; $v = [1 => 0]; $trace = []; for ($d = 0; $d <= $max; $d++) { $trace[] = $v; for ($k = -$d; $k <= $d; $k += 2) { if ($k === -$d || $k !== $d && $v[$k - 1] < $v[$k + 1]) { $x = $v[$k + 1]; } else { $x = $v[$k - 1] + 1; } $y = $x - $k; while ($x < $n && $y < $m && ($this->isEqual)($old[$x], $new[$y])) { $x++; $y++; } $v[$k] = $x; if ($x >= $n && $y >= $m) { return [$trace, $x, $y]; } } } throw new \Exception('Should not happen'); }
@param T[] $old @param T[] $new @return array{array<int, array<int, int>>, int, int}
calculateTrace
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
MIT
private function extractDiff(array $trace, int $x, int $y, array $old, array $new) : array { $result = []; for ($d = \count($trace) - 1; $d >= 0; $d--) { $v = $trace[$d]; $k = $x - $y; if ($k === -$d || $k !== $d && $v[$k - 1] < $v[$k + 1]) { $prevK = $k + 1; } else { $prevK = $k - 1; } $prevX = $v[$prevK]; $prevY = $prevX - $prevK; while ($x > $prevX && $y > $prevY) { $result[] = new DiffElem(DiffElem::TYPE_KEEP, $old[$x - 1], $new[$y - 1]); $x--; $y--; } if ($d === 0) { break; } while ($x > $prevX) { $result[] = new DiffElem(DiffElem::TYPE_REMOVE, $old[$x - 1], null); $x--; } while ($y > $prevY) { $result[] = new DiffElem(DiffElem::TYPE_ADD, null, $new[$y - 1]); $y--; } } return \array_reverse($result); }
@param array<int, array<int, int>> $trace @param T[] $old @param T[] $new @return DiffElem[]
extractDiff
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
MIT
private function coalesceReplacements(array $diff) : array { $newDiff = []; $c = \count($diff); for ($i = 0; $i < $c; $i++) { $diffType = $diff[$i]->type; if ($diffType !== DiffElem::TYPE_REMOVE) { $newDiff[] = $diff[$i]; continue; } $j = $i; while ($j < $c && $diff[$j]->type === DiffElem::TYPE_REMOVE) { $j++; } $k = $j; while ($k < $c && $diff[$k]->type === DiffElem::TYPE_ADD) { $k++; } if ($j - $i === $k - $j) { $len = $j - $i; for ($n = 0; $n < $len; $n++) { $newDiff[] = new DiffElem(DiffElem::TYPE_REPLACE, $diff[$i + $n]->old, $diff[$j + $n]->new); } } else { for (; $i < $k; $i++) { $newDiff[] = $diff[$i]; } } $i = $k - 1; } return $newDiff; }
Coalesce equal-length sequences of remove+add into a replace operation. @param DiffElem[] $diff @return DiffElem[]
coalesceReplacements
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php
MIT
public function __construct(array $attrGroups, int $flags, array $args, ?Node\Name $extends, array $implements, array $stmts, array $attributes) { parent::__construct($attributes); $this->attrGroups = $attrGroups; $this->flags = $flags; $this->args = $args; $this->extends = $extends; $this->implements = $implements; $this->stmts = $stmts; }
@param Node\AttributeGroup[] $attrGroups PHP attribute groups @param (Node\Arg|Node\VariadicPlaceholder)[] $args Arguments @param Node\Name|null $extends Name of extended class @param Node\Name[] $implements Names of implemented interfaces @param Node\Stmt[] $stmts Statements @param array<string, mixed> $attributes Attributes
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php
MIT
public final function __construct(int $id, string $text, int $line = -1, int $pos = -1) { $this->id = $id; $this->text = $text; $this->line = $line; $this->pos = $pos; }
Create a Token with the given ID and text, as well optional line and position information.
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
MIT
public function getTokenName() : ?string { if ($this->id < 256) { return \chr($this->id); } $name = \token_name($this->id); return $name === 'UNKNOWN' ? null : $name; }
Get the name of the token. For single-char tokens this will be the token character. Otherwise it will be a T_* style name, or null if the token ID is unknown.
getTokenName
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
MIT
public function is($kind) : bool { if (\is_int($kind)) { return $this->id === $kind; } if (\is_string($kind)) { return $this->text === $kind; } if (\is_array($kind)) { foreach ($kind as $entry) { if (\is_int($entry)) { if ($this->id === $entry) { return \true; } } elseif (\is_string($entry)) { if ($this->text === $entry) { return \true; } } else { throw new \TypeError('Argument #1 ($kind) must only have elements of type string|int, ' . \gettype($entry) . ' given'); } } return \false; } throw new \TypeError('Argument #1 ($kind) must be of type string|int|array, ' . \gettype($kind) . ' given'); }
Check whether the token is of the given kind. The kind may be either an integer that matches the token ID, a string that matches the token text, or an array of integers/strings. In the latter case, the function returns true if any of the kinds in the array match. @param int|string|(int|string)[] $kind
is
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
MIT
public function isIgnorable() : bool { return isset(self::IGNORABLE_TOKENS[$this->id]); }
Check whether this token would be ignored by the PHP parser. Returns true for T_WHITESPACE, T_COMMENT, T_DOC_COMMENT and T_OPEN_TAG, and false for everything else.
isIgnorable
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
MIT
public function __toString() : string { return $this->text; }
Return the textual content of the token.
__toString
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
MIT
private static function init() : void { if (isset(self::$identifierTokens)) { return; } // Based on semi_reserved production. self::$identifierTokens = \array_fill_keys([\T_STRING, \T_STATIC, \T_ABSTRACT, \T_FINAL, \T_PRIVATE, \T_PROTECTED, \T_PUBLIC, \T_READONLY, \T_INCLUDE, \T_INCLUDE_ONCE, \T_EVAL, \T_REQUIRE, \T_REQUIRE_ONCE, \T_LOGICAL_OR, \T_LOGICAL_XOR, \T_LOGICAL_AND, \T_INSTANCEOF, \T_NEW, \T_CLONE, \T_EXIT, \T_IF, \T_ELSEIF, \T_ELSE, \T_ENDIF, \T_ECHO, \T_DO, \T_WHILE, \T_ENDWHILE, \T_FOR, \T_ENDFOR, \T_FOREACH, \T_ENDFOREACH, \T_DECLARE, \T_ENDDECLARE, \T_AS, \T_TRY, \T_CATCH, \T_FINALLY, \T_THROW, \T_USE, \T_INSTEADOF, \T_GLOBAL, \T_VAR, \T_UNSET, \T_ISSET, \T_EMPTY, \T_CONTINUE, \T_GOTO, \T_FUNCTION, \T_CONST, \T_RETURN, \T_PRINT, \T_YIELD, \T_LIST, \T_SWITCH, \T_ENDSWITCH, \T_CASE, \T_DEFAULT, \T_BREAK, \T_ARRAY, \T_CALLABLE, \T_EXTENDS, \T_IMPLEMENTS, \T_NAMESPACE, \T_TRAIT, \T_INTERFACE, \T_CLASS, \T_CLASS_C, \T_TRAIT_C, \T_FUNC_C, \T_METHOD_C, \T_LINE, \T_FILE, \T_DIR, \T_NS_C, \T_HALT_COMPILER, \T_FN, \T_MATCH], \true); }
Initialize private static state needed by tokenize().
init
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
MIT
public function __construct(array $tokens, int $tabWidth) { $this->tokens = $tokens; $this->indentMap = $this->calcIndentMap($tabWidth); }
Create token stream instance. @param Token[] $tokens Tokens in PhpToken::tokenize() format
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function haveParens(int $startPos, int $endPos) : bool { return $this->haveTokenImmediatelyBefore($startPos, '(') && $this->haveTokenImmediatelyAfter($endPos, ')'); }
Whether the given position is immediately surrounded by parenthesis. @param int $startPos Start position @param int $endPos End position
haveParens
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function haveBraces(int $startPos, int $endPos) : bool { return ($this->haveTokenImmediatelyBefore($startPos, '{') || $this->haveTokenImmediatelyBefore($startPos, \T_CURLY_OPEN)) && $this->haveTokenImmediatelyAfter($endPos, '}'); }
Whether the given position is immediately surrounded by braces. @param int $startPos Start position @param int $endPos End position
haveBraces
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType) : bool { $tokens = $this->tokens; $pos--; for (; $pos >= 0; $pos--) { $token = $tokens[$pos]; if ($token->is($expectedTokenType)) { return \true; } if (!$token->isIgnorable()) { break; } } return \false; }
Check whether the position is directly preceded by a certain token type. During this check whitespace and comments are skipped. @param int $pos Position before which the token should occur @param int|string $expectedTokenType Token to check for @return bool Whether the expected token was found
haveTokenImmediatelyBefore
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType) : bool { $tokens = $this->tokens; $pos++; for ($c = \count($tokens); $pos < $c; $pos++) { $token = $tokens[$pos]; if ($token->is($expectedTokenType)) { return \true; } if (!$token->isIgnorable()) { break; } } return \false; }
Check whether the position is directly followed by a certain token type. During this check whitespace and comments are skipped. @param int $pos Position after which the token should occur @param int|string $expectedTokenType Token to check for @return bool Whether the expected token was found
haveTokenImmediatelyAfter
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function skipLeft(int $pos, $skipTokenType) : int { $tokens = $this->tokens; $pos = $this->skipLeftWhitespace($pos); if ($skipTokenType === \T_WHITESPACE) { return $pos; } if (!$tokens[$pos]->is($skipTokenType)) { // Shouldn't happen. The skip token MUST be there throw new \Exception('Encountered unexpected token'); } $pos--; return $this->skipLeftWhitespace($pos); }
@param int|string|(int|string)[] $skipTokenType
skipLeft
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function skipRight(int $pos, $skipTokenType) : int { $tokens = $this->tokens; $pos = $this->skipRightWhitespace($pos); if ($skipTokenType === \T_WHITESPACE) { return $pos; } if (!$tokens[$pos]->is($skipTokenType)) { // Shouldn't happen. The skip token MUST be there throw new \Exception('Encountered unexpected token'); } $pos++; return $this->skipRightWhitespace($pos); }
@param int|string|(int|string)[] $skipTokenType
skipRight
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function skipLeftWhitespace(int $pos) : int { $tokens = $this->tokens; for (; $pos >= 0; $pos--) { if (!$tokens[$pos]->isIgnorable()) { break; } } return $pos; }
Return first non-whitespace token position smaller or equal to passed position. @param int $pos Token position @return int Non-whitespace token position
skipLeftWhitespace
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function skipRightWhitespace(int $pos) : int { $tokens = $this->tokens; for ($count = \count($tokens); $pos < $count; $pos++) { if (!$tokens[$pos]->isIgnorable()) { break; } } return $pos; }
Return first non-whitespace position greater or equal to passed position. @param int $pos Token position @return int Non-whitespace token position
skipRightWhitespace
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function findRight(int $pos, $findTokenType) : int { $tokens = $this->tokens; for ($count = \count($tokens); $pos < $count; $pos++) { if ($tokens[$pos]->is($findTokenType)) { return $pos; } } return -1; }
@param int|string|(int|string)[] $findTokenType
findRight
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function haveTokenInRange(int $startPos, int $endPos, $tokenType) : bool { $tokens = $this->tokens; for ($pos = $startPos; $pos < $endPos; $pos++) { if ($tokens[$pos]->is($tokenType)) { return \true; } } return \false; }
Whether the given position range contains a certain token type. @param int $startPos Starting position (inclusive) @param int $endPos Ending position (exclusive) @param int|string $tokenType Token type to look for @return bool Whether the token occurs in the given range
haveTokenInRange
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function getIndentationBefore(int $pos) : int { return $this->indentMap[$pos]; }
Get indentation before token position. @param int $pos Token position @return int Indentation depth (in spaces)
getIndentationBefore
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function getTokenCode(int $from, int $to, int $indent) : string { $tokens = $this->tokens; $result = ''; for ($pos = $from; $pos < $to; $pos++) { $token = $tokens[$pos]; $id = $token->id; $text = $token->text; if ($id === \T_CONSTANT_ENCAPSED_STRING || $id === \T_ENCAPSED_AND_WHITESPACE) { $result .= $text; } else { // TODO Handle non-space indentation if ($indent < 0) { $result .= \str_replace("\n" . \str_repeat(" ", -$indent), "\n", $text); } elseif ($indent > 0) { $result .= \str_replace("\n", "\n" . \str_repeat(" ", $indent), $text); } else { $result .= $text; } } } return $result; }
Get the code corresponding to a token offset range, optionally adjusted for indentation. @param int $from Token start position (inclusive) @param int $to Token end position (exclusive) @param int $indent By how much the code should be indented (can be negative as well) @return string Code corresponding to token range, adjusted for indentation
getTokenCode
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
private function calcIndentMap(int $tabWidth) : array { $indentMap = []; $indent = 0; foreach ($this->tokens as $i => $token) { $indentMap[] = $indent; if ($token->id === \T_WHITESPACE) { $content = $token->text; $newlinePos = \strrpos($content, "\n"); if (\false !== $newlinePos) { $indent = $this->getIndent(\substr($content, $newlinePos + 1), $tabWidth); } elseif ($i === 1 && $this->tokens[0]->id === \T_OPEN_TAG && $this->tokens[0]->text[\strlen($this->tokens[0]->text) - 1] === "\n") { // Special case: Newline at the end of opening tag followed by whitespace. $indent = $this->getIndent($content, $tabWidth); } } } // Add a sentinel for one past end of the file $indentMap[] = $indent; return $indentMap; }
Precalculate the indentation at every token position. @return int[] Token position to indentation map
calcIndentMap
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
MIT
public function __construct(?PhpVersion $phpVersion = null) { $this->targetPhpVersion = $phpVersion ?? PhpVersion::getNewestSupported(); $this->hostPhpVersion = PhpVersion::getHostVersion(); $emulators = [new MatchTokenEmulator(), new NullsafeTokenEmulator(), new AttributeEmulator(), new EnumTokenEmulator(), new ReadonlyTokenEmulator(), new ExplicitOctalEmulator(), new ReadonlyFunctionTokenEmulator(), new PropertyTokenEmulator(), new AsymmetricVisibilityTokenEmulator()]; // Collect emulators that are relevant for the PHP version we're running // and the PHP version we're targeting for emulation. foreach ($emulators as $emulator) { $emulatorPhpVersion = $emulator->getPhpVersion(); if ($this->isForwardEmulationNeeded($emulatorPhpVersion)) { $this->emulators[] = $emulator; } elseif ($this->isReverseEmulationNeeded($emulatorPhpVersion)) { $this->emulators[] = new ReverseEmulator($emulator); } } }
@param PhpVersion|null $phpVersion PHP version to emulate. Defaults to newest supported.
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php
MIT
private function fixupTokens(array $tokens) : array { if (\count($this->patches) === 0) { return $tokens; } // Load first patch $patchIdx = 0; list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx]; // We use a manual loop over the tokens, because we modify the array on the fly $posDelta = 0; $lineDelta = 0; for ($i = 0, $c = \count($tokens); $i < $c; $i++) { $token = $tokens[$i]; $pos = $token->pos; $token->pos += $posDelta; $token->line += $lineDelta; $localPosDelta = 0; $len = \strlen($token->text); while ($patchPos >= $pos && $patchPos < $pos + $len) { $patchTextLen = \strlen($patchText); if ($patchType === 'remove') { if ($patchPos === $pos && $patchTextLen === $len) { // Remove token entirely \array_splice($tokens, $i, 1, []); $i--; $c--; } else { // Remove from token string $token->text = \substr_replace($token->text, '', $patchPos - $pos + $localPosDelta, $patchTextLen); $localPosDelta -= $patchTextLen; } $lineDelta -= \substr_count($patchText, "\n"); } elseif ($patchType === 'add') { // Insert into the token string $token->text = \substr_replace($token->text, $patchText, $patchPos - $pos + $localPosDelta, 0); $localPosDelta += $patchTextLen; $lineDelta += \substr_count($patchText, "\n"); } elseif ($patchType === 'replace') { // Replace inside the token string $token->text = \substr_replace($token->text, $patchText, $patchPos - $pos + $localPosDelta, $patchTextLen); } else { \assert(\false); } // Fetch the next patch $patchIdx++; if ($patchIdx >= \count($this->patches)) { // No more patches. However, we still need to adjust position. $patchPos = \PHP_INT_MAX; break; } list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx]; } $posDelta += $localPosDelta; } return $tokens; }
@param list<Token> $tokens @return list<Token>
fixupTokens
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php
MIT
private function fixupErrors(array $errors) : void { foreach ($errors as $error) { $attrs = $error->getAttributes(); $posDelta = 0; $lineDelta = 0; foreach ($this->patches as $patch) { list($patchPos, $patchType, $patchText) = $patch; if ($patchPos >= $attrs['startFilePos']) { // No longer relevant break; } if ($patchType === 'add') { $posDelta += \strlen($patchText); $lineDelta += \substr_count($patchText, "\n"); } elseif ($patchType === 'remove') { $posDelta -= \strlen($patchText); $lineDelta -= \substr_count($patchText, "\n"); } } $attrs['startFilePos'] += $posDelta; $attrs['endFilePos'] += $posDelta; $attrs['startLine'] += $lineDelta; $attrs['endLine'] += $lineDelta; $error->setAttributes($attrs); } }
Fixup line and position information in errors. @param Error[] $errors
fixupErrors
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php
MIT
public function preprocessCode(string $code, array &$patches) : string { return $code; }
@param array{int, string, string}[] $patches
preprocessCode
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php
MIT
public function __construct(Expr $value, bool $byRef = \false, bool $unpack = \false, array $attributes = [], ?Identifier $name = null) { $this->attributes = $attributes; $this->name = $name; $this->value = $value; $this->byRef = $byRef; $this->unpack = $unpack; }
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<string, mixed> $attributes Additional attributes @param Identifier|null $name Parameter name (for named parameters)
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/Arg.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/Arg.php
MIT
public function __construct(Expr $value, ?Expr $key = null, bool $byRef = \false, array $attributes = [], bool $unpack = \false) { $this->attributes = $attributes; $this->key = $key; $this->value = $value; $this->byRef = $byRef; $this->unpack = $unpack; }
Constructs an array item node. @param Expr $value Value @param null|Expr $key Key @param bool $byRef Whether to assign by reference @param array<string, mixed> $attributes Additional attributes
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/ArrayItem.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/ArrayItem.php
MIT
public function __construct(Name $name, array $args = [], array $attributes = []) { $this->attributes = $attributes; $this->name = $name; $this->args = $args; }
@param Node\Name $name Attribute name @param list<Arg> $args Attribute arguments @param array<string, mixed> $attributes Additional node attributes
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/Attribute.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/Attribute.php
MIT
public function __construct(array $attrs, array $attributes = []) { $this->attributes = $attributes; $this->attrs = $attrs; }
@param Attribute[] $attrs PHP attributes @param array<string, mixed> $attributes Additional node attributes
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php
MIT
public function __construct(Expr\Variable $var, bool $byRef = \false, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; $this->byRef = $byRef; }
Constructs a closure use node. @param Expr\Variable $var Variable to use @param bool $byRef Whether to use by reference @param array<string, mixed> $attributes Additional attributes
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/ClosureUse.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/ClosureUse.php
MIT
public function __construct($name, Expr $value, array $attributes = []) { $this->attributes = $attributes; $this->name = \is_string($name) ? new Identifier($name) : $name; $this->value = $value; }
Constructs a const node for use in class const and const statements. @param string|Identifier $name Name @param Expr $value Value @param array<string, mixed> $attributes Additional attributes
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/Const_.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/Const_.php
MIT
public function __construct($key, Node\Expr $value, array $attributes = []) { $this->attributes = $attributes; $this->key = \is_string($key) ? new Node\Identifier($key) : $key; $this->value = $value; }
Constructs a declare key=>value pair node. @param string|Node\Identifier $key Key @param Node\Expr $value Value @param array<string, mixed> $attributes Additional attributes
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/DeclareItem.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/DeclareItem.php
MIT
public function __construct(string $name, array $attributes = []) { if ($name === '') { throw new \InvalidArgumentException('Identifier name cannot be empty'); } $this->attributes = $attributes; $this->name = $name; }
Constructs an identifier node. @param string $name Identifier as string @param array<string, mixed> $attributes Additional attributes
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php
MIT
public function toString() : string { return $this->name; }
Get identifier as string. @psalm-return non-empty-string @return string Identifier as string.
toString
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php
MIT
public function toLowerString() : string { return \strtolower($this->name); }
Get lowercased identifier as string. @psalm-return non-empty-string&lowercase-string @return string Lowercased identifier as string
toLowerString
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php
MIT
public function isSpecialClassName() : bool { return isset(self::$specialClassNames[\strtolower($this->name)]); }
Checks whether the identifier is a special class name (self, parent or static). @return bool Whether identifier is a special class name
isSpecialClassName
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php
MIT
public function __toString() : string { return $this->name; }
Get identifier as string. @psalm-return non-empty-string @return string Identifier as string
__toString
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php
MIT
public function __construct(string $value, array $attributes = []) { $this->attributes = $attributes; $this->value = $value; }
Constructs a node representing a string part of an interpolated string. @param string $value String value @param array<string, mixed> $attributes Additional attributes
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/InterpolatedStringPart.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/InterpolatedStringPart.php
MIT
public function __construct(array $types, array $attributes = []) { $this->attributes = $attributes; $this->types = $types; }
Constructs an intersection type. @param (Identifier|Name)[] $types Types @param array<string, mixed> $attributes Additional attributes
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/IntersectionType.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/IntersectionType.php
MIT
public function __construct(?array $conds, Node\Expr $body, array $attributes = []) { $this->conds = $conds; $this->body = $body; $this->attributes = $attributes; }
@param null|list<Node\Expr> $conds
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/MatchArm.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/MatchArm.php
MIT
public final function __construct($name, array $attributes = []) { $this->attributes = $attributes; $this->name = self::prepareName($name); }
Constructs a name node. @param string|string[]|self $name Name as string, part array or Name instance (copy ctor) @param array<string, mixed> $attributes Additional attributes
__construct
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/Name.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/Name.php
MIT
public function getParts() : array { return \explode('\\', $this->name); }
Get parts of name (split by the namespace separator). @psalm-return non-empty-list<string> @return string[] Parts of name
getParts
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/Name.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/Name.php
MIT
public function getFirst() : string { if (\false !== ($pos = \strpos($this->name, '\\'))) { return \substr($this->name, 0, $pos); } return $this->name; }
Gets the first part of the name, i.e. everything before the first namespace separator. @return string First part of the name
getFirst
php
deptrac/deptrac
vendor/nikic/php-parser/lib/PhpParser/Node/Name.php
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Node/Name.php
MIT