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 older(PhpVersion $other) : bool
{
return $this->id < $other->id;
}
|
Check whether this version is older than the argument.
|
older
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function isHostVersion() : bool
{
return $this->equals(self::getHostVersion());
}
|
Check whether this is the host PHP version.
|
isHostVersion
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function supportsBuiltinType(string $type) : bool
{
$minVersion = self::BUILTIN_TYPE_VERSIONS[$type] ?? null;
return $minVersion !== null && $this->id >= $minVersion;
}
|
Check whether this PHP version supports the given builtin type. Type name must be lowercase.
|
supportsBuiltinType
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function supportsShortArraySyntax() : bool
{
return $this->id >= 50400;
}
|
Whether this version supports [] array literals.
|
supportsShortArraySyntax
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function supportsShortArrayDestructuring() : bool
{
return $this->id >= 70100;
}
|
Whether this version supports [] for destructuring.
|
supportsShortArrayDestructuring
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function supportsFlexibleHeredoc() : bool
{
return $this->id >= 70300;
}
|
Whether this version supports flexible heredoc/nowdoc.
|
supportsFlexibleHeredoc
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function supportsTrailingCommaInParamList() : bool
{
return $this->id >= 80000;
}
|
Whether this version supports trailing commas in parameter lists.
|
supportsTrailingCommaInParamList
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function allowsAssignNewByReference() : bool
{
return $this->id < 70000;
}
|
Whether this version allows "$var =& new Obj".
|
allowsAssignNewByReference
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function allowsInvalidOctals() : bool
{
return $this->id < 70000;
}
|
Whether this version allows invalid octals like "08".
|
allowsInvalidOctals
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function allowsDelInIdentifiers() : bool
{
return $this->id < 70100;
}
|
Whether this version allows DEL (\x7f) to occur in identifiers.
|
allowsDelInIdentifiers
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function supportsYieldWithoutParentheses() : bool
{
return $this->id >= 70000;
}
|
Whether this version supports yield in expression context without parentheses.
|
supportsYieldWithoutParentheses
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function supportsUnicodeEscapes() : bool
{
return $this->id >= 70000;
}
|
Whether this version supports unicode escape sequences in strings.
|
supportsUnicodeEscapes
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php
|
MIT
|
public function __construct(array $options = [])
{
$this->phpVersion = $options['phpVersion'] ?? PhpVersion::fromComponents(7, 4);
$this->newline = $options['newline'] ?? "\n";
if ($this->newline !== "\n" && $this->newline != "\r\n") {
throw new \LogicException('Option "newline" must be one of "\\n" or "\\r\\n"');
}
$this->shortArraySyntax = $options['shortArraySyntax'] ?? $this->phpVersion->supportsShortArraySyntax();
$this->docStringEndToken = $this->phpVersion->supportsFlexibleHeredoc() ? null : '_DOC_STRING_END_' . \mt_rand();
$this->indent = $indent = $options['indent'] ?? ' ';
if ($indent === "\t") {
$this->useTabs = \true;
$this->indentWidth = $this->tabWidth;
} elseif ($indent === \str_repeat(' ', \strlen($indent))) {
$this->useTabs = \false;
$this->indentWidth = \strlen($indent);
} else {
throw new \LogicException('Option "indent" must either be all spaces or a single tab');
}
}
|
Creates a pretty printer instance using the given options.
Supported options:
* PhpVersion $phpVersion: The PHP version to target (default to PHP 7.4). This option
controls compatibility of the generated code with older PHP
versions in cases where a simple stylistic choice exists (e.g.
array() vs []). It is safe to pretty-print an AST for a newer
PHP version while specifying an older target (but the result will
of course not be compatible with the older version in that case).
* string $newline: The newline style to use. Should be "\n" (default) or "\r\n".
* string $indent: The indentation to use. Should either be all spaces or a single
tab. Defaults to four spaces (" ").
* bool $shortArraySyntax: Whether to use [] instead of array() as the default array
syntax, if the node does not specify a format. Defaults to whether
the phpVersion support short array syntax.
@param array{
phpVersion?: PhpVersion, newline?: string, indent?: string, shortArraySyntax?: bool
} $options Dictionary of formatting options
|
__construct
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function setIndentLevel(int $level) : void
{
$this->indentLevel = $level;
if ($this->useTabs) {
$tabs = \intdiv($level, $this->tabWidth);
$spaces = $level % $this->tabWidth;
$this->nl = $this->newline . \str_repeat("\t", $tabs) . \str_repeat(' ', $spaces);
} else {
$this->nl = $this->newline . \str_repeat(' ', $level);
}
}
|
Set indentation level
@param int $level Level in number of spaces
|
setIndentLevel
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
public function prettyPrint(array $stmts) : string
{
$this->resetState();
$this->preprocessNodes($stmts);
return \ltrim($this->handleMagicTokens($this->pStmts($stmts, \false)));
}
|
Pretty prints an array of statements.
@param Node[] $stmts Array of statements
@return string Pretty printed statements
|
prettyPrint
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
public function prettyPrintExpr(Expr $node) : string
{
$this->resetState();
return $this->handleMagicTokens($this->p($node));
}
|
Pretty prints an expression.
@param Expr $node Expression node
@return string Pretty printed node
|
prettyPrintExpr
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
public function prettyPrintFile(array $stmts) : string
{
if (!$stmts) {
return "<?php" . $this->newline . $this->newline;
}
$p = "<?php" . $this->newline . $this->newline . $this->prettyPrint($stmts);
if ($stmts[0] instanceof Stmt\InlineHTML) {
$p = \preg_replace('/^<\\?php\\s+\\?>\\r?\\n?/', '', $p);
}
if ($stmts[\count($stmts) - 1] instanceof Stmt\InlineHTML) {
$p = \preg_replace('/<\\?php$/', '', \rtrim($p));
}
return $p;
}
|
Pretty prints a file of statements (includes the opening <?php tag if it is required).
@param Node[] $stmts Array of statements
@return string Pretty printed statements
|
prettyPrintFile
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function preprocessNodes(array $nodes) : void
{
/* We can use semicolon-namespaces unless there is a global namespace declaration */
$this->canUseSemicolonNamespaces = \true;
foreach ($nodes as $node) {
if ($node instanceof Stmt\Namespace_ && null === $node->name) {
$this->canUseSemicolonNamespaces = \false;
break;
}
}
}
|
Preprocesses the top-level nodes to initialize pretty printer state.
@param Node[] $nodes Array of nodes
|
preprocessNodes
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function handleMagicTokens(string $str) : string
{
if ($this->docStringEndToken !== null) {
// Replace doc-string-end tokens with nothing or a newline
$str = \str_replace($this->docStringEndToken . ';' . $this->newline, ';' . $this->newline, $str);
$str = \str_replace($this->docStringEndToken, $this->newline, $str);
}
return $str;
}
|
Handles (and removes) doc-string-end tokens.
|
handleMagicTokens
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function pStmts(array $nodes, bool $indent = \true) : string
{
if ($indent) {
$this->indent();
}
$result = '';
foreach ($nodes as $node) {
$comments = $node->getComments();
if ($comments) {
$result .= $this->nl . $this->pComments($comments);
if ($node instanceof Stmt\Nop) {
continue;
}
}
$result .= $this->nl . $this->p($node);
}
if ($indent) {
$this->outdent();
}
return $result;
}
|
Pretty prints an array of nodes (statements) and indents them optionally.
@param Node[] $nodes Array of nodes
@param bool $indent Whether to indent the printed nodes
@return string Pretty printed statements
|
pStmts
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function pInfixOp(string $class, Node $leftNode, string $operatorString, Node $rightNode, int $precedence, int $lhsPrecedence) : string
{
list($opPrecedence, $newPrecedenceLHS, $newPrecedenceRHS) = $this->precedenceMap[$class];
$prefix = '';
$suffix = '';
if ($opPrecedence >= $precedence) {
$prefix = '(';
$suffix = ')';
$lhsPrecedence = self::MAX_PRECEDENCE;
}
return $prefix . $this->p($leftNode, $newPrecedenceLHS, $newPrecedenceLHS) . $operatorString . $this->p($rightNode, $newPrecedenceRHS, $lhsPrecedence) . $suffix;
}
|
Pretty-print an infix operation while taking precedence into account.
@param string $class Node class of operator
@param Node $leftNode Left-hand side node
@param string $operatorString String representation of the operator
@param Node $rightNode Right-hand side node
@param int $precedence Precedence of parent operator
@param int $lhsPrecedence Precedence for unary operator on LHS of binary operator
@return string Pretty printed infix operation
|
pInfixOp
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function pPrefixOp(string $class, string $operatorString, Node $node, int $precedence, int $lhsPrecedence) : string
{
$opPrecedence = $this->precedenceMap[$class][0];
$prefix = '';
$suffix = '';
if ($opPrecedence >= $lhsPrecedence) {
$prefix = '(';
$suffix = ')';
$lhsPrecedence = self::MAX_PRECEDENCE;
}
$printedArg = $this->p($node, $opPrecedence, $lhsPrecedence);
if ($operatorString === '+' && $printedArg[0] === '+' || $operatorString === '-' && $printedArg[0] === '-') {
// Avoid printing +(+$a) as ++$a and similar.
$printedArg = '(' . $printedArg . ')';
}
return $prefix . $operatorString . $printedArg . $suffix;
}
|
Pretty-print a prefix operation while taking precedence into account.
@param string $class Node class of operator
@param string $operatorString String representation of the operator
@param Node $node Node
@param int $precedence Precedence of parent operator
@param int $lhsPrecedence Precedence for unary operator on LHS of binary operator
@return string Pretty printed prefix operation
|
pPrefixOp
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function pPostfixOp(string $class, Node $node, string $operatorString, int $precedence, int $lhsPrecedence) : string
{
$opPrecedence = $this->precedenceMap[$class][0];
$prefix = '';
$suffix = '';
if ($opPrecedence >= $precedence) {
$prefix = '(';
$suffix = ')';
$lhsPrecedence = self::MAX_PRECEDENCE;
}
if ($opPrecedence < $lhsPrecedence) {
$lhsPrecedence = $opPrecedence;
}
return $prefix . $this->p($node, $opPrecedence, $lhsPrecedence) . $operatorString . $suffix;
}
|
Pretty-print a postfix operation while taking precedence into account.
@param string $class Node class of operator
@param string $operatorString String representation of the operator
@param Node $node Node
@param int $precedence Precedence of parent operator
@param int $lhsPrecedence Precedence for unary operator on LHS of binary operator
@return string Pretty printed postfix operation
|
pPostfixOp
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function pImplode(array $nodes, string $glue = '') : string
{
$pNodes = [];
foreach ($nodes as $node) {
if (null === $node) {
$pNodes[] = '';
} else {
$pNodes[] = $this->p($node);
}
}
return \implode($glue, $pNodes);
}
|
Pretty prints an array of nodes and implodes the printed values.
@param Node[] $nodes Array of Nodes to be printed
@param string $glue Character to implode with
@return string Imploded pretty printed nodes> $pre
|
pImplode
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function pCommaSeparated(array $nodes) : string
{
return $this->pImplode($nodes, ', ');
}
|
Pretty prints an array of nodes and implodes the printed values with commas.
@param Node[] $nodes Array of Nodes to be printed
@return string Comma separated pretty printed nodes
|
pCommaSeparated
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function pCommaSeparatedMultiline(array $nodes, bool $trailingComma) : string
{
$this->indent();
$result = '';
$lastIdx = \count($nodes) - 1;
foreach ($nodes as $idx => $node) {
if ($node !== null) {
$comments = $node->getComments();
if ($comments) {
$result .= $this->nl . $this->pComments($comments);
}
$result .= $this->nl . $this->p($node);
} else {
$result .= $this->nl;
}
if ($trailingComma || $idx !== $lastIdx) {
$result .= ',';
}
}
$this->outdent();
return $result;
}
|
Pretty prints a comma-separated list of nodes in multiline style, including comments.
The result includes a leading newline and one level of indentation (same as pStmts).
@param Node[] $nodes Array of Nodes to be printed
@param bool $trailingComma Whether to use a trailing comma
@return string Comma separated pretty printed nodes in multiline style
|
pCommaSeparatedMultiline
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function pComments(array $comments) : string
{
$formattedComments = [];
foreach ($comments as $comment) {
$formattedComments[] = \str_replace("\n", $this->nl, $comment->getReformattedText());
}
return \implode($this->nl, $formattedComments);
}
|
Prints reformatted text of the passed comments.
@param Comment[] $comments List of comments
@return string Reformatted text of comments
|
pComments
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens) : string
{
$this->initializeNodeListDiffer();
$this->initializeLabelCharMap();
$this->initializeFixupMap();
$this->initializeRemovalMap();
$this->initializeInsertionMap();
$this->initializeListInsertionMap();
$this->initializeEmptyListInsertionMap();
$this->initializeModifierChangeMap();
$this->resetState();
$this->origTokens = new TokenStream($origTokens, $this->tabWidth);
$this->preprocessNodes($stmts);
$pos = 0;
$result = $this->pArray($stmts, $origStmts, $pos, 0, 'File', 'stmts', null);
if (null !== $result) {
$result .= $this->origTokens->getTokenCode($pos, \count($origTokens) - 1, 0);
} else {
// Fallback
// TODO Add <?php properly
$result = "<?php" . $this->newline . $this->pStmts($stmts, \false);
}
return $this->handleMagicTokens($result);
}
|
Perform a format-preserving pretty print of an AST.
The format preservation is best effort. For some changes to the AST the formatting will not
be preserved (at least not locally).
In order to use this method a number of prerequisites must be satisfied:
* The startTokenPos and endTokenPos attributes in the lexer must be enabled.
* The CloningVisitor must be run on the AST prior to modification.
* The original tokens must be provided, using the getTokens() method on the lexer.
@param Node[] $stmts Modified AST with links to original AST
@param Node[] $origStmts Original AST with token offset information
@param Token[] $origTokens Tokens of the original code
|
printFormatPreserving
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function p(Node $node, int $precedence = self::MAX_PRECEDENCE, int $lhsPrecedence = self::MAX_PRECEDENCE, bool $parentFormatPreserved = \false) : string
{
// No orig tokens means this is a normal pretty print without preservation of formatting
if (!$this->origTokens) {
return $this->{'p' . $node->getType()}($node, $precedence, $lhsPrecedence);
}
/** @var Node|null $origNode */
$origNode = $node->getAttribute('origNode');
if (null === $origNode) {
return $this->pFallback($node, $precedence, $lhsPrecedence);
}
$class = \get_class($node);
\assert($class === \get_class($origNode));
$startPos = $origNode->getStartTokenPos();
$endPos = $origNode->getEndTokenPos();
\assert($startPos >= 0 && $endPos >= 0);
$fallbackNode = $node;
if ($node instanceof Expr\New_ && $node->class instanceof Stmt\Class_) {
// Normalize node structure of anonymous classes
\assert($origNode instanceof Expr\New_);
$node = PrintableNewAnonClassNode::fromNewNode($node);
$origNode = PrintableNewAnonClassNode::fromNewNode($origNode);
$class = PrintableNewAnonClassNode::class;
}
// InlineHTML node does not contain closing and opening PHP tags. If the parent formatting
// is not preserved, then we need to use the fallback code to make sure the tags are
// printed.
if ($node instanceof Stmt\InlineHTML && !$parentFormatPreserved) {
return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence);
}
$indentAdjustment = $this->indentLevel - $this->origTokens->getIndentationBefore($startPos);
$type = $node->getType();
$fixupInfo = $this->fixupMap[$class] ?? null;
$result = '';
$pos = $startPos;
foreach ($node->getSubNodeNames() as $subNodeName) {
$subNode = $node->{$subNodeName};
$origSubNode = $origNode->{$subNodeName};
if (!$subNode instanceof Node && $subNode !== null || !$origSubNode instanceof Node && $origSubNode !== null) {
if ($subNode === $origSubNode) {
// Unchanged, can reuse old code
continue;
}
if (\is_array($subNode) && \is_array($origSubNode)) {
// Array subnode changed, we might be able to reconstruct it
$listResult = $this->pArray($subNode, $origSubNode, $pos, $indentAdjustment, $class, $subNodeName, $fixupInfo[$subNodeName] ?? null);
if (null === $listResult) {
return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence);
}
$result .= $listResult;
continue;
}
// Check if this is a modifier change
$key = $class . '->' . $subNodeName;
if (!isset($this->modifierChangeMap[$key])) {
return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence);
}
[$printFn, $findToken] = $this->modifierChangeMap[$key];
$result .= $this->{$printFn}($subNode);
$pos = $this->origTokens->findRight($pos, $findToken);
continue;
}
$extraLeft = '';
$extraRight = '';
if ($origSubNode !== null) {
$subStartPos = $origSubNode->getStartTokenPos();
$subEndPos = $origSubNode->getEndTokenPos();
\assert($subStartPos >= 0 && $subEndPos >= 0);
} else {
if ($subNode === null) {
// Both null, nothing to do
continue;
}
// A node has been inserted, check if we have insertion information for it
$key = $type . '->' . $subNodeName;
if (!isset($this->insertionMap[$key])) {
return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence);
}
list($findToken, $beforeToken, $extraLeft, $extraRight) = $this->insertionMap[$key];
if (null !== $findToken) {
$subStartPos = $this->origTokens->findRight($pos, $findToken) + (int) (!$beforeToken);
} else {
$subStartPos = $pos;
}
if (null === $extraLeft && null !== $extraRight) {
// If inserting on the right only, skipping whitespace looks better
$subStartPos = $this->origTokens->skipRightWhitespace($subStartPos);
}
$subEndPos = $subStartPos - 1;
}
if (null === $subNode) {
// A node has been removed, check if we have removal information for it
$key = $type . '->' . $subNodeName;
if (!isset($this->removalMap[$key])) {
return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence);
}
// Adjust positions to account for additional tokens that must be skipped
$removalInfo = $this->removalMap[$key];
if (isset($removalInfo['left'])) {
$subStartPos = $this->origTokens->skipLeft($subStartPos - 1, $removalInfo['left']) + 1;
}
if (isset($removalInfo['right'])) {
$subEndPos = $this->origTokens->skipRight($subEndPos + 1, $removalInfo['right']) - 1;
}
}
$result .= $this->origTokens->getTokenCode($pos, $subStartPos, $indentAdjustment);
if (null !== $subNode) {
$result .= $extraLeft;
$origIndentLevel = $this->indentLevel;
$this->setIndentLevel(\max($this->origTokens->getIndentationBefore($subStartPos) + $indentAdjustment, 0));
// If it's the same node that was previously in this position, it certainly doesn't
// need fixup. It's important to check this here, because our fixup checks are more
// conservative than strictly necessary.
if (isset($fixupInfo[$subNodeName]) && $subNode->getAttribute('origNode') !== $origSubNode) {
$fixup = $fixupInfo[$subNodeName];
$res = $this->pFixup($fixup, $subNode, $class, $subStartPos, $subEndPos);
} else {
$res = $this->p($subNode, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, \true);
}
$this->safeAppend($result, $res);
$this->setIndentLevel($origIndentLevel);
$result .= $extraRight;
}
$pos = $subEndPos + 1;
}
$result .= $this->origTokens->getTokenCode($pos, $endPos + 1, $indentAdjustment);
return $result;
}
|
Pretty prints a node.
This method also handles formatting preservation for nodes.
@param Node $node Node to be pretty printed
@param int $precedence Precedence of parent operator
@param int $lhsPrecedence Precedence for unary operator on LHS of binary operator
@param bool $parentFormatPreserved Whether parent node has preserved formatting
@return string Pretty printed node
|
p
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function pArray(array $nodes, array $origNodes, int &$pos, int $indentAdjustment, string $parentNodeClass, string $subNodeName, ?int $fixup) : ?string
{
$diff = $this->nodeListDiffer->diffWithReplacements($origNodes, $nodes);
$mapKey = $parentNodeClass . '->' . $subNodeName;
$insertStr = $this->listInsertionMap[$mapKey] ?? null;
$isStmtList = $subNodeName === 'stmts';
$beforeFirstKeepOrReplace = \true;
$skipRemovedNode = \false;
$delayedAdd = [];
$lastElemIndentLevel = $this->indentLevel;
$insertNewline = \false;
if ($insertStr === "\n") {
$insertStr = '';
$insertNewline = \true;
}
if ($isStmtList && \count($origNodes) === 1 && \count($nodes) !== 1) {
$startPos = $origNodes[0]->getStartTokenPos();
$endPos = $origNodes[0]->getEndTokenPos();
\assert($startPos >= 0 && $endPos >= 0);
if (!$this->origTokens->haveBraces($startPos, $endPos)) {
// This was a single statement without braces, but either additional statements
// have been added, or the single statement has been removed. This requires the
// addition of braces. For now fall back.
// TODO: Try to preserve formatting
return null;
}
}
$result = '';
foreach ($diff as $i => $diffElem) {
$diffType = $diffElem->type;
/** @var Node|string|null $arrItem */
$arrItem = $diffElem->new;
/** @var Node|string|null $origArrItem */
$origArrItem = $diffElem->old;
if ($diffType === DiffElem::TYPE_KEEP || $diffType === DiffElem::TYPE_REPLACE) {
$beforeFirstKeepOrReplace = \false;
if ($origArrItem === null || $arrItem === null) {
// We can only handle the case where both are null
if ($origArrItem === $arrItem) {
continue;
}
return null;
}
if (!$arrItem instanceof Node || !$origArrItem instanceof Node) {
// We can only deal with nodes. This can occur for Names, which use string arrays.
return null;
}
$itemStartPos = $origArrItem->getStartTokenPos();
$itemEndPos = $origArrItem->getEndTokenPos();
\assert($itemStartPos >= 0 && $itemEndPos >= 0 && $itemStartPos >= $pos);
$origIndentLevel = $this->indentLevel;
$lastElemIndentLevel = \max($this->origTokens->getIndentationBefore($itemStartPos) + $indentAdjustment, 0);
$this->setIndentLevel($lastElemIndentLevel);
$comments = $arrItem->getComments();
$origComments = $origArrItem->getComments();
$commentStartPos = $origComments ? $origComments[0]->getStartTokenPos() : $itemStartPos;
\assert($commentStartPos >= 0);
if ($commentStartPos < $pos) {
// Comments may be assigned to multiple nodes if they start at the same position.
// Make sure we don't try to print them multiple times.
$commentStartPos = $itemStartPos;
}
if ($skipRemovedNode) {
if ($isStmtList && $this->origTokens->haveTagInRange($pos, $itemStartPos)) {
// We'd remove an opening/closing PHP tag.
// TODO: Preserve formatting.
$this->setIndentLevel($origIndentLevel);
return null;
}
} else {
$result .= $this->origTokens->getTokenCode($pos, $commentStartPos, $indentAdjustment);
}
if (!empty($delayedAdd)) {
/** @var Node $delayedAddNode */
foreach ($delayedAdd as $delayedAddNode) {
if ($insertNewline) {
$delayedAddComments = $delayedAddNode->getComments();
if ($delayedAddComments) {
$result .= $this->pComments($delayedAddComments) . $this->nl;
}
}
$this->safeAppend($result, $this->p($delayedAddNode, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, \true));
if ($insertNewline) {
$result .= $insertStr . $this->nl;
} else {
$result .= $insertStr;
}
}
$delayedAdd = [];
}
if ($comments !== $origComments) {
if ($comments) {
$result .= $this->pComments($comments) . $this->nl;
}
} else {
$result .= $this->origTokens->getTokenCode($commentStartPos, $itemStartPos, $indentAdjustment);
}
// If we had to remove anything, we have done so now.
$skipRemovedNode = \false;
} elseif ($diffType === DiffElem::TYPE_ADD) {
if (null === $insertStr) {
// We don't have insertion information for this list type
return null;
}
if (!$arrItem instanceof Node) {
// We only support list insertion of nodes.
return null;
}
// We go multiline if the original code was multiline,
// or if it's an array item with a comment above it.
// Match always uses multiline formatting.
if ($insertStr === ', ' && ($this->isMultiline($origNodes) || $arrItem->getComments() || $parentNodeClass === Expr\Match_::class)) {
$insertStr = ',';
$insertNewline = \true;
}
if ($beforeFirstKeepOrReplace) {
// Will be inserted at the next "replace" or "keep" element
$delayedAdd[] = $arrItem;
continue;
}
$itemStartPos = $pos;
$itemEndPos = $pos - 1;
$origIndentLevel = $this->indentLevel;
$this->setIndentLevel($lastElemIndentLevel);
if ($insertNewline) {
$result .= $insertStr . $this->nl;
$comments = $arrItem->getComments();
if ($comments) {
$result .= $this->pComments($comments) . $this->nl;
}
} else {
$result .= $insertStr;
}
} elseif ($diffType === DiffElem::TYPE_REMOVE) {
if (!$origArrItem instanceof Node) {
// We only support removal for nodes
return null;
}
$itemStartPos = $origArrItem->getStartTokenPos();
$itemEndPos = $origArrItem->getEndTokenPos();
\assert($itemStartPos >= 0 && $itemEndPos >= 0);
// Consider comments part of the node.
$origComments = $origArrItem->getComments();
if ($origComments) {
$itemStartPos = $origComments[0]->getStartTokenPos();
}
if ($i === 0) {
// If we're removing from the start, keep the tokens before the node and drop those after it,
// instead of the other way around.
$result .= $this->origTokens->getTokenCode($pos, $itemStartPos, $indentAdjustment);
$skipRemovedNode = \true;
} else {
if ($isStmtList && $this->origTokens->haveTagInRange($pos, $itemStartPos)) {
// We'd remove an opening/closing PHP tag.
// TODO: Preserve formatting.
return null;
}
}
$pos = $itemEndPos + 1;
continue;
} else {
throw new \Exception("Shouldn't happen");
}
if (null !== $fixup && $arrItem->getAttribute('origNode') !== $origArrItem) {
$res = $this->pFixup($fixup, $arrItem, null, $itemStartPos, $itemEndPos);
} else {
$res = $this->p($arrItem, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, \true);
}
$this->safeAppend($result, $res);
$this->setIndentLevel($origIndentLevel);
$pos = $itemEndPos + 1;
}
if ($skipRemovedNode) {
// TODO: Support removing single node.
return null;
}
if (!empty($delayedAdd)) {
if (!isset($this->emptyListInsertionMap[$mapKey])) {
return null;
}
list($findToken, $extraLeft, $extraRight) = $this->emptyListInsertionMap[$mapKey];
if (null !== $findToken) {
$insertPos = $this->origTokens->findRight($pos, $findToken) + 1;
$result .= $this->origTokens->getTokenCode($pos, $insertPos, $indentAdjustment);
$pos = $insertPos;
}
$first = \true;
$result .= $extraLeft;
foreach ($delayedAdd as $delayedAddNode) {
if (!$first) {
$result .= $insertStr;
if ($insertNewline) {
$result .= $this->nl;
}
}
$result .= $this->p($delayedAddNode, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, \true);
$first = \false;
}
$result .= $extraRight === "\n" ? $this->nl : $extraRight;
}
return $result;
}
|
Perform a format-preserving pretty print of an array.
@param Node[] $nodes New nodes
@param Node[] $origNodes Original nodes
@param int $pos Current token position (updated by reference)
@param int $indentAdjustment Adjustment for indentation
@param string $parentNodeClass Class of the containing node.
@param string $subNodeName Name of array subnode.
@param null|int $fixup Fixup information for array item nodes
@return null|string Result of pretty print or null if cannot preserve formatting
|
pArray
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function pFixup(int $fixup, Node $subNode, ?string $parentClass, int $subStartPos, int $subEndPos) : string
{
switch ($fixup) {
case self::FIXUP_PREC_LEFT:
// We use a conservative approximation where lhsPrecedence == precedence.
if (!$this->origTokens->haveParens($subStartPos, $subEndPos)) {
$precedence = $this->precedenceMap[$parentClass][1];
return $this->p($subNode, $precedence, $precedence);
}
break;
case self::FIXUP_PREC_RIGHT:
if (!$this->origTokens->haveParens($subStartPos, $subEndPos)) {
$precedence = $this->precedenceMap[$parentClass][2];
return $this->p($subNode, $precedence, $precedence);
}
break;
case self::FIXUP_PREC_UNARY:
if (!$this->origTokens->haveParens($subStartPos, $subEndPos)) {
$precedence = $this->precedenceMap[$parentClass][0];
return $this->p($subNode, $precedence, $precedence);
}
break;
case self::FIXUP_CALL_LHS:
if ($this->callLhsRequiresParens($subNode) && !$this->origTokens->haveParens($subStartPos, $subEndPos)) {
return '(' . $this->p($subNode) . ')';
}
break;
case self::FIXUP_DEREF_LHS:
if ($this->dereferenceLhsRequiresParens($subNode) && !$this->origTokens->haveParens($subStartPos, $subEndPos)) {
return '(' . $this->p($subNode) . ')';
}
break;
case self::FIXUP_STATIC_DEREF_LHS:
if ($this->staticDereferenceLhsRequiresParens($subNode) && !$this->origTokens->haveParens($subStartPos, $subEndPos)) {
return '(' . $this->p($subNode) . ')';
}
break;
case self::FIXUP_NEW:
if ($this->newOperandRequiresParens($subNode) && !$this->origTokens->haveParens($subStartPos, $subEndPos)) {
return '(' . $this->p($subNode) . ')';
}
break;
case self::FIXUP_BRACED_NAME:
case self::FIXUP_VAR_BRACED_NAME:
if ($subNode instanceof Expr && !$this->origTokens->haveBraces($subStartPos, $subEndPos)) {
return ($fixup === self::FIXUP_VAR_BRACED_NAME ? '$' : '') . '{' . $this->p($subNode) . '}';
}
break;
case self::FIXUP_ENCAPSED:
if (!$subNode instanceof Node\InterpolatedStringPart && !$this->origTokens->haveBraces($subStartPos, $subEndPos)) {
return '{' . $this->p($subNode) . '}';
}
break;
default:
throw new \Exception('Cannot happen');
}
// Nothing special to do
return $this->p($subNode);
}
|
Print node with fixups.
Fixups here refer to the addition of extra parentheses, braces or other characters, that
are required to preserve program semantics in a certain context (e.g. to maintain precedence
or because only certain expressions are allowed in certain places).
@param int $fixup Fixup type
@param Node $subNode Subnode to print
@param string|null $parentClass Class of parent node
@param int $subStartPos Original start pos of subnode
@param int $subEndPos Original end pos of subnode
@return string Result of fixed-up print of subnode
|
pFixup
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function safeAppend(string &$str, string $append) : void
{
if ($str === "") {
$str = $append;
return;
}
if ($append === "") {
return;
}
if (!$this->labelCharMap[$append[0]] || !$this->labelCharMap[$str[\strlen($str) - 1]]) {
$str .= $append;
} else {
$str .= " " . $append;
}
}
|
Appends to a string, ensuring whitespace between label characters.
Example: "echo" and "$x" result in "echo$x", but "echo" and "x" result in "echo x".
Without safeAppend the result would be "echox", which does not preserve semantics.
|
safeAppend
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function callLhsRequiresParens(Node $node) : bool
{
return !($node instanceof Node\Name || $node instanceof Expr\Variable || $node instanceof Expr\ArrayDimFetch || $node instanceof Expr\FuncCall || $node instanceof Expr\MethodCall || $node instanceof Expr\NullsafeMethodCall || $node instanceof Expr\StaticCall || $node instanceof Expr\Array_);
}
|
Determines whether the LHS of a call must be wrapped in parenthesis.
@param Node $node LHS of a call
@return bool Whether parentheses are required
|
callLhsRequiresParens
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function dereferenceLhsRequiresParens(Node $node) : bool
{
// A constant can occur on the LHS of an array/object deref, but not a static deref.
return $this->staticDereferenceLhsRequiresParens($node) && !$node instanceof Expr\ConstFetch;
}
|
Determines whether the LHS of an array/object operation must be wrapped in parentheses.
@param Node $node LHS of dereferencing operation
@return bool Whether parentheses are required
|
dereferenceLhsRequiresParens
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function staticDereferenceLhsRequiresParens(Node $node) : bool
{
return !($node instanceof Expr\Variable || $node instanceof Node\Name || $node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch || $node instanceof Expr\NullsafePropertyFetch || $node instanceof Expr\StaticPropertyFetch || $node instanceof Expr\FuncCall || $node instanceof Expr\MethodCall || $node instanceof Expr\NullsafeMethodCall || $node instanceof Expr\StaticCall || $node instanceof Expr\Array_ || $node instanceof Scalar\String_ || $node instanceof Expr\ClassConstFetch);
}
|
Determines whether the LHS of a static operation must be wrapped in parentheses.
@param Node $node LHS of dereferencing operation
@return bool Whether parentheses are required
|
staticDereferenceLhsRequiresParens
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function newOperandRequiresParens(Node $node) : bool
{
if ($node instanceof Node\Name || $node instanceof Expr\Variable) {
return \false;
}
if ($node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch || $node instanceof Expr\NullsafePropertyFetch) {
return $this->newOperandRequiresParens($node->var);
}
if ($node instanceof Expr\StaticPropertyFetch) {
return $this->newOperandRequiresParens($node->class);
}
return \true;
}
|
Determines whether an expression used in "new" or "instanceof" requires parentheses.
@param Node $node New or instanceof operand
@return bool Whether parentheses are required
|
newOperandRequiresParens
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function pModifiers(int $modifiers) : string
{
return ($modifiers & Modifiers::FINAL ? 'final ' : '') . ($modifiers & Modifiers::ABSTRACT ? 'abstract ' : '') . ($modifiers & Modifiers::PUBLIC ? 'public ' : '') . ($modifiers & Modifiers::PROTECTED ? 'protected ' : '') . ($modifiers & Modifiers::PRIVATE ? 'private ' : '') . ($modifiers & Modifiers::PUBLIC_SET ? 'public(set) ' : '') . ($modifiers & Modifiers::PROTECTED_SET ? 'protected(set) ' : '') . ($modifiers & Modifiers::PRIVATE_SET ? 'private(set) ' : '') . ($modifiers & Modifiers::STATIC ? 'static ' : '') . ($modifiers & Modifiers::READONLY ? 'readonly ' : '');
}
|
Print modifiers, including trailing whitespace.
@param int $modifiers Modifier mask to print
@return string Printed modifiers
|
pModifiers
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function isMultiline(array $nodes) : bool
{
if (\count($nodes) < 2) {
return \false;
}
$pos = -1;
foreach ($nodes as $node) {
if (null === $node) {
continue;
}
$endPos = $node->getEndTokenPos() + 1;
if ($pos >= 0) {
$text = $this->origTokens->getTokenCode($pos, $endPos, 0);
if (\false === \strpos($text, "\n")) {
// We require that a newline is present between *every* item. If the formatting
// is inconsistent, with only some items having newlines, we don't consider it
// as multiline
return \false;
}
}
$pos = $endPos;
}
return \true;
}
|
Determine whether a list of nodes uses multiline formatting.
@param (Node|null)[] $nodes Node list
@return bool Whether multiline formatting is used
|
isMultiline
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function initializeLabelCharMap() : void
{
if (isset($this->labelCharMap)) {
return;
}
$this->labelCharMap = [];
for ($i = 0; $i < 256; $i++) {
$chr = \chr($i);
$this->labelCharMap[$chr] = $i >= 0x80 || \ctype_alnum($chr);
}
if ($this->phpVersion->allowsDelInIdentifiers()) {
$this->labelCharMap[""] = \true;
}
}
|
Lazily initializes label char map.
The label char map determines whether a certain character may occur in a label.
|
initializeLabelCharMap
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function initializeNodeListDiffer() : void
{
if (isset($this->nodeListDiffer)) {
return;
}
$this->nodeListDiffer = new Internal\Differ(function ($a, $b) {
if ($a instanceof Node && $b instanceof Node) {
return $a === $b->getAttribute('origNode');
}
// Can happen for array destructuring
return $a === null && $b === null;
});
}
|
Lazily initializes node list differ.
The node list differ is used to determine differences between two array subnodes.
|
initializeNodeListDiffer
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function initializeFixupMap() : void
{
if (isset($this->fixupMap)) {
return;
}
$this->fixupMap = [Expr\Instanceof_::class => ['expr' => self::FIXUP_PREC_UNARY, 'class' => self::FIXUP_NEW], Expr\Ternary::class => ['cond' => self::FIXUP_PREC_LEFT, 'else' => self::FIXUP_PREC_RIGHT], Expr\Yield_::class => ['value' => self::FIXUP_PREC_UNARY], Expr\FuncCall::class => ['name' => self::FIXUP_CALL_LHS], Expr\StaticCall::class => ['class' => self::FIXUP_STATIC_DEREF_LHS], Expr\ArrayDimFetch::class => ['var' => self::FIXUP_DEREF_LHS], Expr\ClassConstFetch::class => ['class' => self::FIXUP_STATIC_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], Expr\New_::class => ['class' => self::FIXUP_NEW], Expr\MethodCall::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], Expr\NullsafeMethodCall::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], Expr\StaticPropertyFetch::class => ['class' => self::FIXUP_STATIC_DEREF_LHS, 'name' => self::FIXUP_VAR_BRACED_NAME], Expr\PropertyFetch::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], Expr\NullsafePropertyFetch::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], Scalar\InterpolatedString::class => ['parts' => self::FIXUP_ENCAPSED]];
$binaryOps = [BinaryOp\Pow::class, BinaryOp\Mul::class, BinaryOp\Div::class, BinaryOp\Mod::class, BinaryOp\Plus::class, BinaryOp\Minus::class, BinaryOp\Concat::class, BinaryOp\ShiftLeft::class, BinaryOp\ShiftRight::class, BinaryOp\Smaller::class, BinaryOp\SmallerOrEqual::class, BinaryOp\Greater::class, BinaryOp\GreaterOrEqual::class, BinaryOp\Equal::class, BinaryOp\NotEqual::class, BinaryOp\Identical::class, BinaryOp\NotIdentical::class, BinaryOp\Spaceship::class, BinaryOp\BitwiseAnd::class, BinaryOp\BitwiseXor::class, BinaryOp\BitwiseOr::class, BinaryOp\BooleanAnd::class, BinaryOp\BooleanOr::class, BinaryOp\Coalesce::class, BinaryOp\LogicalAnd::class, BinaryOp\LogicalXor::class, BinaryOp\LogicalOr::class];
foreach ($binaryOps as $binaryOp) {
$this->fixupMap[$binaryOp] = ['left' => self::FIXUP_PREC_LEFT, 'right' => self::FIXUP_PREC_RIGHT];
}
$prefixOps = [Expr\Clone_::class, Expr\BitwiseNot::class, Expr\BooleanNot::class, Expr\UnaryPlus::class, Expr\UnaryMinus::class, Cast\Int_::class, Cast\Double::class, Cast\String_::class, Cast\Array_::class, Cast\Object_::class, Cast\Bool_::class, Cast\Unset_::class, Expr\ErrorSuppress::class, Expr\YieldFrom::class, Expr\Print_::class, Expr\Include_::class, Expr\Assign::class, Expr\AssignRef::class, AssignOp\Plus::class, AssignOp\Minus::class, AssignOp\Mul::class, AssignOp\Div::class, AssignOp\Concat::class, AssignOp\Mod::class, AssignOp\BitwiseAnd::class, AssignOp\BitwiseOr::class, AssignOp\BitwiseXor::class, AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class, AssignOp\Coalesce::class, Expr\ArrowFunction::class, Expr\Throw_::class];
foreach ($prefixOps as $prefixOp) {
$this->fixupMap[$prefixOp] = ['expr' => self::FIXUP_PREC_UNARY];
}
}
|
Lazily initializes fixup map.
The fixup map is used to determine whether a certain subnode of a certain node may require
some kind of "fixup" operation, e.g. the addition of parenthesis or braces.
|
initializeFixupMap
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
protected function initializeRemovalMap() : void
{
if (isset($this->removalMap)) {
return;
}
$stripBoth = ['left' => \T_WHITESPACE, 'right' => \T_WHITESPACE];
$stripLeft = ['left' => \T_WHITESPACE];
$stripRight = ['right' => \T_WHITESPACE];
$stripDoubleArrow = ['right' => \T_DOUBLE_ARROW];
$stripColon = ['left' => ':'];
$stripEquals = ['left' => '='];
$this->removalMap = ['Expr_ArrayDimFetch->dim' => $stripBoth, 'ArrayItem->key' => $stripDoubleArrow, 'Expr_ArrowFunction->returnType' => $stripColon, 'Expr_Closure->returnType' => $stripColon, 'Expr_Exit->expr' => $stripBoth, 'Expr_Ternary->if' => $stripBoth, 'Expr_Yield->key' => $stripDoubleArrow, 'Expr_Yield->value' => $stripBoth, 'Param->type' => $stripRight, 'Param->default' => $stripEquals, 'Stmt_Break->num' => $stripBoth, 'Stmt_Catch->var' => $stripLeft, 'Stmt_ClassConst->type' => $stripRight, 'Stmt_ClassMethod->returnType' => $stripColon, 'Stmt_Class->extends' => ['left' => \T_EXTENDS], 'Stmt_Enum->scalarType' => $stripColon, 'Stmt_EnumCase->expr' => $stripEquals, 'Expr_PrintableNewAnonClass->extends' => ['left' => \T_EXTENDS], 'Stmt_Continue->num' => $stripBoth, 'Stmt_Foreach->keyVar' => $stripDoubleArrow, 'Stmt_Function->returnType' => $stripColon, 'Stmt_If->else' => $stripLeft, 'Stmt_Namespace->name' => $stripLeft, 'Stmt_Property->type' => $stripRight, 'PropertyItem->default' => $stripEquals, 'Stmt_Return->expr' => $stripBoth, 'Stmt_StaticVar->default' => $stripEquals, 'Stmt_TraitUseAdaptation_Alias->newName' => $stripLeft, 'Stmt_TryCatch->finally' => $stripLeft];
}
|
Lazily initializes the removal map.
The removal map is used to determine which additional tokens should be removed when a
certain node is replaced by null.
|
initializeRemovalMap
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
|
MIT
|
public function getEndPos() : int
{
return $this->pos + \strlen($this->text);
}
|
Get (exclusive) zero-based end position of the token.
|
getEndPos
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Token.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Token.php
|
MIT
|
public function getEndLine() : int
{
return $this->line + \substr_count($this->text, "\n");
}
|
Get 1-based end line number of the token.
|
getEndLine
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Token.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Token.php
|
MIT
|
public function __construct($name, $value)
{
$this->constants = [new Const_($name, BuilderHelpers::normalizeValue($value))];
}
|
Creates a class constant builder
@param string|Identifier $name Name
@param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value Value
|
__construct
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
MIT
|
public function addConst($name, $value)
{
$this->constants[] = new Const_($name, BuilderHelpers::normalizeValue($value));
return $this;
}
|
Add another constant to const group
@param string|Identifier $name Name
@param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value Value
@return $this The builder instance (for fluid interface)
|
addConst
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
MIT
|
public function makePublic()
{
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC);
return $this;
}
|
Makes the constant public.
@return $this The builder instance (for fluid interface)
|
makePublic
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
MIT
|
public function makeProtected()
{
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED);
return $this;
}
|
Makes the constant protected.
@return $this The builder instance (for fluid interface)
|
makeProtected
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
MIT
|
public function makePrivate()
{
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE);
return $this;
}
|
Makes the constant private.
@return $this The builder instance (for fluid interface)
|
makePrivate
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
MIT
|
public function makeFinal()
{
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::FINAL);
return $this;
}
|
Makes the constant final.
@return $this The builder instance (for fluid interface)
|
makeFinal
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
MIT
|
public function setDocComment($docComment)
{
$this->attributes = ['comments' => [BuilderHelpers::normalizeDocComment($docComment)]];
return $this;
}
|
Sets doc comment for the constant.
@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/ClassConst.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.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/ClassConst.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
MIT
|
public function setType($type)
{
$this->type = BuilderHelpers::normalizeType($type);
return $this;
}
|
Sets the constant type.
@param string|Node\Name|Identifier|Node\ComplexType $type
@return $this
|
setType
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
MIT
|
public function getNode() : PhpParser\Node
{
return new Stmt\ClassConst($this->constants, $this->flags, $this->attributes, $this->attributeGroups, $this->type);
}
|
Returns the built class node.
@return Stmt\ClassConst The built constant node
|
getNode
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
|
MIT
|
public function __construct(string $name)
{
$this->name = $name;
}
|
Creates a class builder.
@param string $name Name of the class
|
__construct
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
MIT
|
public function extend($class)
{
$this->extends = BuilderHelpers::normalizeName($class);
return $this;
}
|
Extends a class.
@param Name|string $class Name of class to extend
@return $this The builder instance (for fluid interface)
|
extend
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
MIT
|
public function implement(...$interfaces)
{
foreach ($interfaces as $interface) {
$this->implements[] = BuilderHelpers::normalizeName($interface);
}
return $this;
}
|
Implements one or more interfaces.
@param Name|string ...$interfaces Names of interfaces to implement
@return $this The builder instance (for fluid interface)
|
implement
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
MIT
|
public function makeAbstract()
{
$this->flags = BuilderHelpers::addClassModifier($this->flags, Modifiers::ABSTRACT);
return $this;
}
|
Makes the class abstract.
@return $this The builder instance (for fluid interface)
|
makeAbstract
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
MIT
|
public function makeFinal()
{
$this->flags = BuilderHelpers::addClassModifier($this->flags, Modifiers::FINAL);
return $this;
}
|
Makes the class final.
@return $this The builder instance (for fluid interface)
|
makeFinal
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
MIT
|
public function makeReadonly()
{
$this->flags = BuilderHelpers::addClassModifier($this->flags, Modifiers::READONLY);
return $this;
}
|
Makes the class readonly.
@return $this The builder instance (for fluid interface)
|
makeReadonly
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.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/Class_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.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/Class_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
MIT
|
public function getNode() : PhpParser\Node
{
return new Stmt\Class_($this->name, ['flags' => $this->flags, 'extends' => $this->extends, 'implements' => $this->implements, 'stmts' => \array_merge($this->uses, $this->constants, $this->properties, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes);
}
|
Returns the built class node.
@return Stmt\Class_ The built class node
|
getNode
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php
|
MIT
|
public function addStmts(array $stmts)
{
foreach ($stmts as $stmt) {
$this->addStmt($stmt);
}
return $this;
}
|
Adds multiple statements.
@param (PhpParser\Node\Stmt|PhpParser\Builder)[] $stmts The statements to add
@return $this The builder instance (for fluid interface)
|
addStmts
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Declaration.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Declaration.php
|
MIT
|
public function setDocComment($docComment)
{
$this->attributes['comments'] = [BuilderHelpers::normalizeDocComment($docComment)];
return $this;
}
|
Sets doc comment for the declaration.
@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/Declaration.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Declaration.php
|
MIT
|
public function __construct($name)
{
$this->name = $name;
}
|
Creates an enum case builder.
@param string|Identifier $name Name
|
__construct
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php
|
MIT
|
public function setValue($value)
{
$this->value = BuilderHelpers::normalizeValue($value);
return $this;
}
|
Sets the value.
@param Node\Expr|string|int $value
@return $this
|
setValue
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php
|
MIT
|
public function setDocComment($docComment)
{
$this->attributes = ['comments' => [BuilderHelpers::normalizeDocComment($docComment)]];
return $this;
}
|
Sets doc comment for the constant.
@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/EnumCase.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.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/EnumCase.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php
|
MIT
|
public function getNode() : PhpParser\Node
{
return new Stmt\EnumCase($this->name, $this->value, $this->attributeGroups, $this->attributes);
}
|
Returns the built enum case node.
@return Stmt\EnumCase The built constant node
|
getNode
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php
|
MIT
|
public function __construct(string $name)
{
$this->name = $name;
}
|
Creates an enum builder.
@param string $name Name of the enum
|
__construct
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php
|
MIT
|
public function setScalarType($scalarType)
{
$this->scalarType = BuilderHelpers::normalizeType($scalarType);
return $this;
}
|
Sets the scalar type.
@param string|Identifier $scalarType
@return $this
|
setScalarType
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php
|
MIT
|
public function implement(...$interfaces)
{
foreach ($interfaces as $interface) {
$this->implements[] = BuilderHelpers::normalizeName($interface);
}
return $this;
}
|
Implements one or more interfaces.
@param Name|string ...$interfaces Names of interfaces to implement
@return $this The builder instance (for fluid interface)
|
implement
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php
|
MIT
|
public function addStmt($stmt)
{
$stmt = BuilderHelpers::normalizeNode($stmt);
if ($stmt instanceof Stmt\EnumCase) {
$this->enumCases[] = $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/Enum_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.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/Enum_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php
|
MIT
|
public function getNode() : PhpParser\Node
{
return new Stmt\Enum_($this->name, ['scalarType' => $this->scalarType, 'implements' => $this->implements, 'stmts' => \array_merge($this->uses, $this->enumCases, $this->constants, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes);
}
|
Returns the built class node.
@return Stmt\Enum_ The built enum node
|
getNode
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php
|
MIT
|
public function makeReturnByRef()
{
$this->returnByRef = \true;
return $this;
}
|
Make the function return by reference.
@return $this The builder instance (for fluid interface)
|
makeReturnByRef
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php
|
MIT
|
public function addParam($param)
{
$param = BuilderHelpers::normalizeNode($param);
if (!$param instanceof Node\Param) {
throw new \LogicException(\sprintf('Expected parameter node, got "%s"', $param->getType()));
}
$this->params[] = $param;
return $this;
}
|
Adds a parameter.
@param Node\Param|Param $param The parameter to add
@return $this The builder instance (for fluid interface)
|
addParam
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php
|
MIT
|
public function addParams(array $params)
{
foreach ($params as $param) {
$this->addParam($param);
}
return $this;
}
|
Adds multiple parameters.
@param (Node\Param|Param)[] $params The parameters to add
@return $this The builder instance (for fluid interface)
|
addParams
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php
|
MIT
|
public function setReturnType($type)
{
$this->returnType = BuilderHelpers::normalizeType($type);
return $this;
}
|
Sets the return type for PHP 7.
@param string|Node\Name|Node\Identifier|Node\ComplexType $type
@return $this The builder instance (for fluid interface)
|
setReturnType
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php
|
MIT
|
public function __construct(string $name)
{
$this->name = $name;
}
|
Creates a function builder.
@param string $name Name of the function
|
__construct
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php
|
MIT
|
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/Function_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.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/Function_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php
|
MIT
|
public function getNode() : Node
{
return new Stmt\Function_($this->name, ['byRef' => $this->returnByRef, 'params' => $this->params, 'returnType' => $this->returnType, 'stmts' => $this->stmts, 'attrGroups' => $this->attributeGroups], $this->attributes);
}
|
Returns the built function node.
@return Stmt\Function_ The built function node
|
getNode
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.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/Interface_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php
|
MIT
|
public function extend(...$interfaces)
{
foreach ($interfaces as $interface) {
$this->extends[] = BuilderHelpers::normalizeName($interface);
}
return $this;
}
|
Extends one or more interfaces.
@param Name|string ...$interfaces Names of interfaces to extend
@return $this The builder instance (for fluid interface)
|
extend
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php
|
MIT
|
public function addStmt($stmt)
{
$stmt = BuilderHelpers::normalizeNode($stmt);
if ($stmt instanceof Stmt\ClassConst) {
$this->constants[] = $stmt;
} elseif ($stmt instanceof Stmt\ClassMethod) {
// we erase all statements in the body of an interface method
$stmt->stmts = null;
$this->methods[] = $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/Interface_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.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/Interface_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php
|
MIT
|
public function getNode() : PhpParser\Node
{
return new Stmt\Interface_($this->name, ['extends' => $this->extends, 'stmts' => \array_merge($this->constants, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes);
}
|
Returns the built interface node.
@return Stmt\Interface_ The built interface node
|
getNode
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php
|
MIT
|
public function __construct(string $name)
{
$this->name = $name;
}
|
Creates a method builder.
@param string $name Name of the method
|
__construct
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
MIT
|
public function makePublic()
{
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC);
return $this;
}
|
Makes the method public.
@return $this The builder instance (for fluid interface)
|
makePublic
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
MIT
|
public function makeProtected()
{
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED);
return $this;
}
|
Makes the method protected.
@return $this The builder instance (for fluid interface)
|
makeProtected
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
MIT
|
public function makePrivate()
{
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE);
return $this;
}
|
Makes the method private.
@return $this The builder instance (for fluid interface)
|
makePrivate
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
MIT
|
public function makeStatic()
{
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::STATIC);
return $this;
}
|
Makes the method static.
@return $this The builder instance (for fluid interface)
|
makeStatic
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
MIT
|
public function makeAbstract()
{
if (!empty($this->stmts)) {
throw new \LogicException('Cannot make method with statements abstract');
}
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::ABSTRACT);
$this->stmts = null;
// abstract methods don't have statements
return $this;
}
|
Makes the method abstract.
@return $this The builder instance (for fluid interface)
|
makeAbstract
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
MIT
|
public function makeFinal()
{
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::FINAL);
return $this;
}
|
Makes the method final.
@return $this The builder instance (for fluid interface)
|
makeFinal
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
MIT
|
public function addStmt($stmt)
{
if (null === $this->stmts) {
throw new \LogicException('Cannot add statements to an abstract method');
}
$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/Method.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.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/Method.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
MIT
|
public function getNode() : Node
{
return new Stmt\ClassMethod($this->name, ['flags' => $this->flags, 'byRef' => $this->returnByRef, 'params' => $this->params, 'returnType' => $this->returnType, 'stmts' => $this->stmts, 'attrGroups' => $this->attributeGroups], $this->attributes);
}
|
Returns the built method node.
@return Stmt\ClassMethod The built method node
|
getNode
|
php
|
deptrac/deptrac
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
|
MIT
|
public function __construct($name)
{
$this->name = null !== $name ? BuilderHelpers::normalizeName($name) : null;
}
|
Creates a namespace builder.
@param Node\Name|string|null $name Name of the namespace
|
__construct
|
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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.