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 enrichWithAttributes(TokenIterator $tokens, Ast\Node $type, int $startLine, int $startIndex) : Ast\Node
{
if ($this->useLinesAttributes) {
$type->setAttribute(Ast\Attribute::START_LINE, $startLine);
$type->setAttribute(Ast\Attribute::END_LINE, $tokens->currentTokenLine());
}
if ($this->useIndexAttributes) {
$type->setAttribute(Ast\Attribute::START_INDEX, $startIndex);
$type->setAttribute(Ast\Attribute::END_INDEX, $tokens->endIndexOfLastRelevantToken());
}
return $type;
}
|
@internal
@template T of Ast\Node
@param T $type
@return T
|
enrichWithAttributes
|
php
|
deptrac/deptrac
|
vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
MIT
|
public function parseGenericTypeArgument(TokenIterator $tokens) : array
{
$startLine = $tokens->currentTokenLine();
$startIndex = $tokens->currentTokenIndex();
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_WILDCARD)) {
return [$this->enrichWithAttributes($tokens, new Ast\Type\IdentifierTypeNode('mixed'), $startLine, $startIndex), Ast\Type\GenericTypeNode::VARIANCE_BIVARIANT];
}
if ($tokens->tryConsumeTokenValue('contravariant')) {
$variance = Ast\Type\GenericTypeNode::VARIANCE_CONTRAVARIANT;
} elseif ($tokens->tryConsumeTokenValue('covariant')) {
$variance = Ast\Type\GenericTypeNode::VARIANCE_COVARIANT;
} else {
$variance = Ast\Type\GenericTypeNode::VARIANCE_INVARIANT;
}
$type = $this->parse($tokens);
return [$type, $variance];
}
|
@phpstan-impure
@return array{Ast\Type\TypeNode, Ast\Type\GenericTypeNode::VARIANCE_*}
|
parseGenericTypeArgument
|
php
|
deptrac/deptrac
|
vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
MIT
|
public function parseTemplateTagValue(TokenIterator $tokens, ?callable $parseDescription = null) : TemplateTagValueNode
{
$name = $tokens->currentTokenValue();
$tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER);
$upperBound = $lowerBound = null;
if ($tokens->tryConsumeTokenValue('of') || $tokens->tryConsumeTokenValue('as')) {
$upperBound = $this->parse($tokens);
}
if ($tokens->tryConsumeTokenValue('super')) {
$lowerBound = $this->parse($tokens);
}
if ($tokens->tryConsumeTokenValue('=')) {
$default = $this->parse($tokens);
} else {
$default = null;
}
if ($parseDescription !== null) {
$description = $parseDescription($tokens);
} else {
$description = '';
}
if ($name === '') {
throw new LogicException('Template tag name cannot be empty.');
}
return new Ast\PhpDoc\TemplateTagValueNode($name, $upperBound, $description, $default, $lowerBound);
}
|
@throws ParserException
@param ?callable(TokenIterator): string $parseDescription
|
parseTemplateTagValue
|
php
|
deptrac/deptrac
|
vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
MIT
|
private function parseCallableTemplates(TokenIterator $tokens) : array
{
$tokens->consumeTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET);
$templates = [];
$isFirst = \true;
while ($isFirst || $tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) {
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
// trailing comma case
if (!$isFirst && $tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET)) {
break;
}
$isFirst = \false;
$templates[] = $this->parseCallableTemplateArgument($tokens);
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
}
$tokens->consumeTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET);
return $templates;
}
|
@return Ast\PhpDoc\TemplateTagValueNode[]
@phpstan-impure
|
parseCallableTemplates
|
php
|
deptrac/deptrac
|
vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
MIT
|
private function parseArrayShape(TokenIterator $tokens, Ast\Type\TypeNode $type, string $kind) : Ast\Type\ArrayShapeNode
{
$tokens->consumeTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET);
$items = [];
$sealed = \true;
$unsealedType = null;
do {
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) {
return new Ast\Type\ArrayShapeNode($items, \true, $kind);
}
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_VARIADIC)) {
$sealed = \false;
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET)) {
if ($kind === Ast\Type\ArrayShapeNode::KIND_ARRAY) {
$unsealedType = $this->parseArrayShapeUnsealedType($tokens);
} else {
$unsealedType = $this->parseListShapeUnsealedType($tokens);
}
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
}
$tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA);
break;
}
$items[] = $this->parseArrayShapeItem($tokens);
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
} while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA));
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
$tokens->consumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET);
return new Ast\Type\ArrayShapeNode($items, $sealed, $kind, $unsealedType);
}
|
@phpstan-impure
@param Ast\Type\ArrayShapeNode::KIND_* $kind
|
parseArrayShape
|
php
|
deptrac/deptrac
|
vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
MIT
|
private function parseArrayShapeKey(TokenIterator $tokens)
{
$startIndex = $tokens->currentTokenIndex();
$startLine = $tokens->currentTokenLine();
if ($tokens->isCurrentTokenType(Lexer::TOKEN_INTEGER)) {
$key = new Ast\ConstExpr\ConstExprIntegerNode(str_replace('_', '', $tokens->currentTokenValue()));
$tokens->next();
} elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_SINGLE_QUOTED_STRING)) {
if ($this->quoteAwareConstExprString) {
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(StringUnescaper::unescapeString($tokens->currentTokenValue()), Ast\ConstExpr\QuoteAwareConstExprStringNode::SINGLE_QUOTED);
} else {
$key = new Ast\ConstExpr\ConstExprStringNode(trim($tokens->currentTokenValue(), "'"));
}
$tokens->next();
} elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_DOUBLE_QUOTED_STRING)) {
if ($this->quoteAwareConstExprString) {
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(StringUnescaper::unescapeString($tokens->currentTokenValue()), Ast\ConstExpr\QuoteAwareConstExprStringNode::DOUBLE_QUOTED);
} else {
$key = new Ast\ConstExpr\ConstExprStringNode(trim($tokens->currentTokenValue(), '"'));
}
$tokens->next();
} else {
$key = new Ast\Type\IdentifierTypeNode($tokens->currentTokenValue());
$tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER);
}
return $this->enrichWithAttributes($tokens, $key, $startLine, $startIndex);
}
|
@phpstan-impure
@return Ast\ConstExpr\ConstExprIntegerNode|Ast\ConstExpr\ConstExprStringNode|Ast\Type\IdentifierTypeNode
|
parseArrayShapeKey
|
php
|
deptrac/deptrac
|
vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
MIT
|
private function parseObjectShapeKey(TokenIterator $tokens)
{
$startLine = $tokens->currentTokenLine();
$startIndex = $tokens->currentTokenIndex();
if ($tokens->isCurrentTokenType(Lexer::TOKEN_SINGLE_QUOTED_STRING)) {
if ($this->quoteAwareConstExprString) {
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(StringUnescaper::unescapeString($tokens->currentTokenValue()), Ast\ConstExpr\QuoteAwareConstExprStringNode::SINGLE_QUOTED);
} else {
$key = new Ast\ConstExpr\ConstExprStringNode(trim($tokens->currentTokenValue(), "'"));
}
$tokens->next();
} elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_DOUBLE_QUOTED_STRING)) {
if ($this->quoteAwareConstExprString) {
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(StringUnescaper::unescapeString($tokens->currentTokenValue()), Ast\ConstExpr\QuoteAwareConstExprStringNode::DOUBLE_QUOTED);
} else {
$key = new Ast\ConstExpr\ConstExprStringNode(trim($tokens->currentTokenValue(), '"'));
}
$tokens->next();
} else {
$key = new Ast\Type\IdentifierTypeNode($tokens->currentTokenValue());
$tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER);
}
return $this->enrichWithAttributes($tokens, $key, $startLine, $startIndex);
}
|
@phpstan-impure
@return Ast\ConstExpr\ConstExprStringNode|Ast\Type\IdentifierTypeNode
|
parseObjectShapeKey
|
php
|
deptrac/deptrac
|
vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php
|
MIT
|
public function __construct(int $type, $old, $new)
{
$this->type = $type;
$this->old = $old;
$this->new = $new;
}
|
@param self::TYPE_* $type
@param mixed $old Is null for add operations
@param mixed $new Is null for remove operations
|
__construct
|
php
|
deptrac/deptrac
|
vendor/phpstan/phpdoc-parser/src/Printer/DiffElem.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Printer/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/phpstan/phpdoc-parser/src/Printer/Differ.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Printer/Differ.php
|
MIT
|
public function diff(array $old, array $new) : array
{
[$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/phpstan/phpdoc-parser/src/Printer/Differ.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Printer/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/phpstan/phpdoc-parser/src/Printer/Differ.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Printer/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/phpstan/phpdoc-parser/src/Printer/Differ.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Printer/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/phpstan/phpdoc-parser/src/Printer/Differ.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Printer/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/phpstan/phpdoc-parser/src/Printer/Differ.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Printer/Differ.php
|
MIT
|
private function printArrayFormatPreserving(array $nodes, array $originalNodes, TokenIterator $originalTokens, int &$tokenIndex, string $parentNodeClass, string $subNodeName) : ?string
{
$diff = $this->differ->diffWithReplacements($originalNodes, $nodes);
$mapKey = $parentNodeClass . '->' . $subNodeName;
$insertStr = $this->listInsertionMap[$mapKey] ?? null;
$result = '';
$beforeFirstKeepOrReplace = \true;
$delayedAdd = [];
$insertNewline = \false;
[$isMultiline, $beforeAsteriskIndent, $afterAsteriskIndent] = $this->isMultiline($tokenIndex, $originalNodes, $originalTokens);
if ($insertStr === "\n * ") {
$insertStr = sprintf('%s%s*%s', $originalTokens->getDetectedNewline() ?? "\n", $beforeAsteriskIndent, $afterAsteriskIndent);
}
foreach ($diff as $i => $diffElem) {
$diffType = $diffElem->type;
$newNode = $diffElem->new;
$originalNode = $diffElem->old;
if ($diffType === DiffElem::TYPE_KEEP || $diffType === DiffElem::TYPE_REPLACE) {
$beforeFirstKeepOrReplace = \false;
if (!$newNode instanceof Node || !$originalNode instanceof Node) {
return null;
}
$itemStartPos = $originalNode->getAttribute(Attribute::START_INDEX);
$itemEndPos = $originalNode->getAttribute(Attribute::END_INDEX);
if ($itemStartPos < 0 || $itemEndPos < 0 || $itemStartPos < $tokenIndex) {
throw new LogicException();
}
$result .= $originalTokens->getContentBetween($tokenIndex, $itemStartPos);
if (count($delayedAdd) > 0) {
foreach ($delayedAdd as $delayedAddNode) {
$parenthesesNeeded = isset($this->parenthesesListMap[$mapKey]) && in_array(get_class($delayedAddNode), $this->parenthesesListMap[$mapKey], \true);
if ($parenthesesNeeded) {
$result .= '(';
}
$result .= $this->printNodeFormatPreserving($delayedAddNode, $originalTokens);
if ($parenthesesNeeded) {
$result .= ')';
}
if ($insertNewline) {
$result .= $insertStr . sprintf('%s%s*%s', $originalTokens->getDetectedNewline() ?? "\n", $beforeAsteriskIndent, $afterAsteriskIndent);
} else {
$result .= $insertStr;
}
}
$delayedAdd = [];
}
$parenthesesNeeded = isset($this->parenthesesListMap[$mapKey]) && in_array(get_class($newNode), $this->parenthesesListMap[$mapKey], \true) && !in_array(get_class($originalNode), $this->parenthesesListMap[$mapKey], \true);
$addParentheses = $parenthesesNeeded && !$originalTokens->hasParentheses($itemStartPos, $itemEndPos);
if ($addParentheses) {
$result .= '(';
}
$result .= $this->printNodeFormatPreserving($newNode, $originalTokens);
if ($addParentheses) {
$result .= ')';
}
$tokenIndex = $itemEndPos + 1;
} elseif ($diffType === DiffElem::TYPE_ADD) {
if ($insertStr === null) {
return null;
}
if (!$newNode instanceof Node) {
return null;
}
if ($insertStr === ', ' && $isMultiline) {
$insertStr = ',';
$insertNewline = \true;
}
if ($beforeFirstKeepOrReplace) {
// Will be inserted at the next "replace" or "keep" element
$delayedAdd[] = $newNode;
continue;
}
$itemEndPos = $tokenIndex - 1;
if ($insertNewline) {
$result .= $insertStr . sprintf('%s%s*%s', $originalTokens->getDetectedNewline() ?? "\n", $beforeAsteriskIndent, $afterAsteriskIndent);
} else {
$result .= $insertStr;
}
$parenthesesNeeded = isset($this->parenthesesListMap[$mapKey]) && in_array(get_class($newNode), $this->parenthesesListMap[$mapKey], \true);
if ($parenthesesNeeded) {
$result .= '(';
}
$result .= $this->printNodeFormatPreserving($newNode, $originalTokens);
if ($parenthesesNeeded) {
$result .= ')';
}
$tokenIndex = $itemEndPos + 1;
} elseif ($diffType === DiffElem::TYPE_REMOVE) {
if (!$originalNode instanceof Node) {
return null;
}
$itemStartPos = $originalNode->getAttribute(Attribute::START_INDEX);
$itemEndPos = $originalNode->getAttribute(Attribute::END_INDEX);
if ($itemStartPos < 0 || $itemEndPos < 0) {
throw new LogicException();
}
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.
$originalTokensArray = $originalTokens->getTokens();
for ($j = $tokenIndex; $j < $itemStartPos; $j++) {
if ($originalTokensArray[$j][Lexer::TYPE_OFFSET] === Lexer::TOKEN_PHPDOC_EOL) {
break;
}
$result .= $originalTokensArray[$j][Lexer::VALUE_OFFSET];
}
}
$tokenIndex = $itemEndPos + 1;
}
}
if (count($delayedAdd) > 0) {
if (!isset($this->emptyListInsertionMap[$mapKey])) {
return null;
}
[$findToken, $extraLeft, $extraRight] = $this->emptyListInsertionMap[$mapKey];
if ($findToken !== null) {
$originalTokensArray = $originalTokens->getTokens();
for (; $tokenIndex < count($originalTokensArray); $tokenIndex++) {
$result .= $originalTokensArray[$tokenIndex][Lexer::VALUE_OFFSET];
if ($originalTokensArray[$tokenIndex][Lexer::VALUE_OFFSET] !== $findToken) {
continue;
}
$tokenIndex++;
break;
}
}
$first = \true;
$result .= $extraLeft;
foreach ($delayedAdd as $delayedAddNode) {
if (!$first) {
$result .= $insertStr;
if ($insertNewline) {
$result .= sprintf('%s%s*%s', $originalTokens->getDetectedNewline() ?? "\n", $beforeAsteriskIndent, $afterAsteriskIndent);
}
}
$result .= $this->printNodeFormatPreserving($delayedAddNode, $originalTokens);
$first = \false;
}
$result .= $extraRight;
}
return $result;
}
|
@param Node[] $nodes
@param Node[] $originalNodes
|
printArrayFormatPreserving
|
php
|
deptrac/deptrac
|
vendor/phpstan/phpdoc-parser/src/Printer/Printer.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Printer/Printer.php
|
MIT
|
private function isMultiline(int $initialIndex, array $nodes, TokenIterator $originalTokens) : array
{
$isMultiline = count($nodes) > 1;
$pos = $initialIndex;
$allText = '';
/** @var Node|null $node */
foreach ($nodes as $node) {
if (!$node instanceof Node) {
continue;
}
$endPos = $node->getAttribute(Attribute::END_INDEX) + 1;
$text = $originalTokens->getContentBetween($pos, $endPos);
$allText .= $text;
if (strpos($text, "\n") === \false) {
// 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
$isMultiline = \false;
}
$pos = $endPos;
}
$c = preg_match_all('~\\n(?<before>[\\x09\\x20]*)\\*(?<after>\\x20*)~', $allText, $matches, PREG_SET_ORDER);
if ($c === 0) {
return [$isMultiline, '', ''];
}
$before = '';
$after = '';
foreach ($matches as $match) {
if (strlen($match['before']) > strlen($before)) {
$before = $match['before'];
}
if (strlen($match['after']) <= strlen($after)) {
continue;
}
$after = $match['after'];
}
return [$isMultiline, $before, $after];
}
|
@param Node[] $nodes
@return array{bool, string, string}
|
isMultiline
|
php
|
deptrac/deptrac
|
vendor/phpstan/phpdoc-parser/src/Printer/Printer.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/phpstan/phpdoc-parser/src/Printer/Printer.php
|
MIT
|
public function alert(string|\Stringable $message, array $context = []) : void
{
$this->log(LogLevel::ALERT, $message, $context);
}
|
Action must be taken immediately.
Example: Entire website down, database unavailable, etc. This should
trigger the SMS alerts and wake you up.
|
alert
|
php
|
deptrac/deptrac
|
vendor/psr/log/src/LoggerTrait.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/psr/log/src/LoggerTrait.php
|
MIT
|
public function critical(string|\Stringable $message, array $context = []) : void
{
$this->log(LogLevel::CRITICAL, $message, $context);
}
|
Critical conditions.
Example: Application component unavailable, unexpected exception.
|
critical
|
php
|
deptrac/deptrac
|
vendor/psr/log/src/LoggerTrait.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/psr/log/src/LoggerTrait.php
|
MIT
|
public function error(string|\Stringable $message, array $context = []) : void
{
$this->log(LogLevel::ERROR, $message, $context);
}
|
Runtime errors that do not require immediate action but should typically
be logged and monitored.
|
error
|
php
|
deptrac/deptrac
|
vendor/psr/log/src/LoggerTrait.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/psr/log/src/LoggerTrait.php
|
MIT
|
public function warning(string|\Stringable $message, array $context = []) : void
{
$this->log(LogLevel::WARNING, $message, $context);
}
|
Exceptional occurrences that are not errors.
Example: Use of deprecated APIs, poor use of an API, undesirable things
that are not necessarily wrong.
|
warning
|
php
|
deptrac/deptrac
|
vendor/psr/log/src/LoggerTrait.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/psr/log/src/LoggerTrait.php
|
MIT
|
public function info(string|\Stringable $message, array $context = []) : void
{
$this->log(LogLevel::INFO, $message, $context);
}
|
Interesting events.
Example: User logs in, SQL logs.
|
info
|
php
|
deptrac/deptrac
|
vendor/psr/log/src/LoggerTrait.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/psr/log/src/LoggerTrait.php
|
MIT
|
public function log($level, string|\Stringable $message, array $context = []) : void
{
// noop
}
|
Logs with an arbitrary level.
@param mixed[] $context
@throws \Psr\Log\InvalidArgumentException
|
log
|
php
|
deptrac/deptrac
|
vendor/psr/log/src/NullLogger.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/psr/log/src/NullLogger.php
|
MIT
|
public function __construct(string $file, bool $debug)
{
$this->debug = $debug;
$checkers = [];
if (\true === $this->debug) {
$checkers = [new SelfCheckingResourceChecker()];
}
parent::__construct($file, $checkers);
}
|
@param string $file The absolute cache path
@param bool $debug Whether debugging is enabled or not
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/config/ConfigCache.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/ConfigCache.php
|
MIT
|
public function isFresh() : bool
{
if (!$this->debug && \is_file($this->getPath())) {
return \true;
}
return parent::isFresh();
}
|
Checks if the cache is still fresh.
This implementation always returns true when debug is off and the
cache file exists.
|
isFresh
|
php
|
deptrac/deptrac
|
vendor/symfony/config/ConfigCache.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/ConfigCache.php
|
MIT
|
public function __construct(bool $debug)
{
$this->debug = $debug;
}
|
@param bool $debug The debug flag to pass to ConfigCache
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/config/ConfigCacheFactory.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/ConfigCacheFactory.php
|
MIT
|
public function __construct(string|array $paths = [])
{
$this->paths = (array) $paths;
}
|
@param string|string[] $paths A path or an array of paths where to look for resources
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/config/FileLocator.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/FileLocator.php
|
MIT
|
public function locate(string $name, ?string $currentPath = null, bool $first = \true)
{
if ('' === $name) {
throw new \InvalidArgumentException('An empty file name is not valid to be located.');
}
if ($this->isAbsolutePath($name)) {
if (!\file_exists($name)) {
throw new FileLocatorFileNotFoundException(\sprintf('The file "%s" does not exist.', $name), 0, null, [$name]);
}
return $name;
}
$paths = $this->paths;
if (null !== $currentPath) {
\array_unshift($paths, $currentPath);
}
$paths = \array_unique($paths);
$filepaths = $notfound = [];
foreach ($paths as $path) {
if (@\file_exists($file = $path . \DIRECTORY_SEPARATOR . $name)) {
if (\true === $first) {
return $file;
}
$filepaths[] = $file;
} else {
$notfound[] = $file;
}
}
if (!$filepaths) {
throw new FileLocatorFileNotFoundException(\sprintf('The file "%s" does not exist (in: "%s").', $name, \implode('", "', $paths)), 0, null, $notfound);
}
return $filepaths;
}
|
@return string|string[]
@psalm-return ($first is true ? string : string[])
|
locate
|
php
|
deptrac/deptrac
|
vendor/symfony/config/FileLocator.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/FileLocator.php
|
MIT
|
private function isAbsolutePath(string $file) : bool
{
if ('/' === $file[0] || '\\' === $file[0] || \strlen($file) > 3 && \ctype_alpha($file[0]) && ':' === $file[1] && ('\\' === $file[2] || '/' === $file[2]) || \parse_url($file, \PHP_URL_SCHEME) || \str_starts_with($file, 'phar:///')) {
return \true;
}
return \false;
}
|
Returns whether the file path is an absolute path.
|
isAbsolutePath
|
php
|
deptrac/deptrac
|
vendor/symfony/config/FileLocator.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/FileLocator.php
|
MIT
|
public function __construct(string $file, iterable $resourceCheckers = [])
{
$this->file = $file;
$this->resourceCheckers = $resourceCheckers;
}
|
@param string $file The absolute cache path
@param iterable<mixed, ResourceCheckerInterface> $resourceCheckers The ResourceCheckers to use for the freshness check
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/config/ResourceCheckerConfigCache.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/ResourceCheckerConfigCache.php
|
MIT
|
public function isFresh() : bool
{
if (!\is_file($this->file)) {
return \false;
}
if ($this->resourceCheckers instanceof \Traversable && !$this->resourceCheckers instanceof \Countable) {
$this->resourceCheckers = \iterator_to_array($this->resourceCheckers);
}
if (!\count($this->resourceCheckers)) {
return \true;
// shortcut - if we don't have any checkers we don't need to bother with the meta file at all
}
$metadata = $this->getMetaFile();
if (!\is_file($metadata)) {
return \false;
}
$meta = $this->safelyUnserialize($metadata);
if (\false === $meta) {
return \false;
}
$time = \filemtime($this->file);
foreach ($meta as $resource) {
foreach ($this->resourceCheckers as $checker) {
if (!$checker->supports($resource)) {
continue;
// next checker
}
if ($checker->isFresh($resource, $time)) {
break;
// no need to further check this resource
}
return \false;
// cache is stale
}
// no suitable checker found, ignore this resource
}
return \true;
}
|
Checks if the cache is still fresh.
This implementation will make a decision solely based on the ResourceCheckers
passed in the constructor.
The first ResourceChecker that supports a given resource is considered authoritative.
Resources with no matching ResourceChecker will silently be ignored and considered fresh.
|
isFresh
|
php
|
deptrac/deptrac
|
vendor/symfony/config/ResourceCheckerConfigCache.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/ResourceCheckerConfigCache.php
|
MIT
|
public function write(string $content, ?array $metadata = null)
{
$mode = 0666;
$umask = \umask();
$filesystem = new Filesystem();
$filesystem->dumpFile($this->file, $content);
try {
$filesystem->chmod($this->file, $mode, $umask);
} catch (IOException) {
// discard chmod failure (some filesystem may not support it)
}
if (null !== $metadata) {
$filesystem->dumpFile($this->getMetaFile(), \serialize($metadata));
try {
$filesystem->chmod($this->getMetaFile(), $mode, $umask);
} catch (IOException) {
// discard chmod failure (some filesystem may not support it)
}
}
if (\function_exists('opcache_invalidate') && \filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL)) {
@\opcache_invalidate($this->file, \true);
}
}
|
Writes cache.
@param string $content The content to write in the cache
@param ResourceInterface[] $metadata An array of metadata
@return void
@throws \RuntimeException When cache file can't be written
|
write
|
php
|
deptrac/deptrac
|
vendor/symfony/config/ResourceCheckerConfigCache.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/ResourceCheckerConfigCache.php
|
MIT
|
public function build(ConfigurationInterface $configuration) : \Closure
{
$this->classes = [];
$rootNode = $configuration->getConfigTreeBuilder()->buildTree();
$rootClass = new ClassBuilder('DEPTRAC_INTERNAL\\Symfony\\Config', $rootNode->getName());
$path = $this->getFullPath($rootClass);
if (!\is_file($path)) {
// Generate the class if the file not exists
$this->classes[] = $rootClass;
$this->buildNode($rootNode, $rootClass, $this->getSubNamespace($rootClass));
$rootClass->addImplements(ConfigBuilderInterface::class);
$rootClass->addMethod('getExtensionAlias', '
public function NAME(): string
{
return \'ALIAS\';
}', ['ALIAS' => $rootNode->getPath()]);
$this->writeClasses();
}
return function () use($path, $rootClass) {
require_once $path;
$className = $rootClass->getFqcn();
return new $className();
};
}
|
@return \Closure that will return the root config class
|
build
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Builder/ConfigBuilderGenerator.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Builder/ConfigBuilderGenerator.php
|
MIT
|
protected function preNormalize(mixed $value) : mixed
{
if (!$this->normalizeKeys || !\is_array($value)) {
return $value;
}
$normalized = [];
foreach ($value as $k => $v) {
if (\str_contains($k, '-') && !\str_contains($k, '_') && !\array_key_exists($normalizedKey = \str_replace('-', '_', $k), $value)) {
$normalized[$normalizedKey] = $v;
} else {
$normalized[$k] = $v;
}
}
return $normalized;
}
|
Namely, you mostly have foo_bar in YAML while you have foo-bar in XML.
After running this method, all keys are normalized to foo_bar.
If you have a mixed key like foo-bar_moo, it will not be altered.
The key will also not be altered if the target key already exists.
|
preNormalize
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
public function getChildren() : array
{
return $this->children;
}
|
Retrieves the children of this node.
@return array<string, NodeInterface>
|
getChildren
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
public function setXmlRemappings(array $remappings)
{
$this->xmlRemappings = $remappings;
}
|
Sets the xml remappings that should be performed.
@param array $remappings An array of the form [[string, string]]
@return void
|
setXmlRemappings
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
public function getXmlRemappings() : array
{
return $this->xmlRemappings;
}
|
Gets the xml remappings that should be performed.
@return array an array of the form [[string, string]]
|
getXmlRemappings
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
public function setAddIfNotSet(bool $boolean)
{
$this->addIfNotSet = $boolean;
}
|
Sets whether to add default values for this array if it has not been
defined in any of the configuration files.
@return void
|
setAddIfNotSet
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
public function setAllowFalse(bool $allow)
{
$this->allowFalse = $allow;
}
|
Sets whether false is allowed as value indicating that the array should be unset.
@return void
|
setAllowFalse
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
public function setAllowNewKeys(bool $allow)
{
$this->allowNewKeys = $allow;
}
|
Sets whether new keys can be defined in subsequent configurations.
@return void
|
setAllowNewKeys
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
public function setPerformDeepMerging(bool $boolean)
{
$this->performDeepMerging = $boolean;
}
|
Sets if deep merging should occur.
@return void
|
setPerformDeepMerging
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
public function setIgnoreExtraKeys(bool $boolean, bool $remove = \true)
{
$this->ignoreExtraKeys = $boolean;
$this->removeExtraKeys = $this->ignoreExtraKeys && $remove;
}
|
Whether extra keys should just be ignored without an exception.
@param bool $boolean To allow extra keys
@param bool $remove To remove extra keys
@return void
|
setIgnoreExtraKeys
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
public function shouldIgnoreExtraKeys() : bool
{
return $this->ignoreExtraKeys;
}
|
Returns true when extra keys should be ignored without an exception.
|
shouldIgnoreExtraKeys
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
public function addChild(NodeInterface $node)
{
$name = $node->getName();
if ('' === $name) {
throw new \InvalidArgumentException('Child nodes must be named.');
}
if (isset($this->children[$name])) {
throw new \InvalidArgumentException(\sprintf('A child node named "%s" already exists.', $name));
}
$this->children[$name] = $node;
}
|
Adds a child node.
@return void
@throws \InvalidArgumentException when the child node has no name
@throws \InvalidArgumentException when the child node's name is not unique
|
addChild
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
protected function finalizeValue(mixed $value) : mixed
{
if (\false === $value) {
throw new UnsetKeyException(\sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), \json_encode($value)));
}
foreach ($this->children as $name => $child) {
if (!\array_key_exists($name, $value)) {
if ($child->isRequired()) {
$message = \sprintf('The child config "%s" under "%s" must be configured', $name, $this->getPath());
if ($child->getInfo()) {
$message .= \sprintf(': %s', $child->getInfo());
} else {
$message .= '.';
}
$ex = new InvalidConfigurationException($message);
$ex->setPath($this->getPath());
throw $ex;
}
if ($child->hasDefaultValue()) {
$value[$name] = $child->getDefaultValue();
}
continue;
}
if ($child->isDeprecated()) {
$deprecation = $child->getDeprecation($name, $this->getPath());
\DEPTRAC_INTERNAL\trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']);
}
try {
$value[$name] = $child->finalize($value[$name]);
} catch (UnsetKeyException) {
unset($value[$name]);
}
}
return $value;
}
|
@throws UnsetKeyException
@throws InvalidConfigurationException if the node doesn't have enough children
|
finalizeValue
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
protected function remapXml(array $value) : array
{
foreach ($this->xmlRemappings as [$singular, $plural]) {
if (!isset($value[$singular])) {
continue;
}
$value[$plural] = Processor::normalizeConfig($value, $singular, $plural);
unset($value[$singular]);
}
return $value;
}
|
Remaps multiple singular values to a single plural value.
|
remapXml
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/ArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/ArrayNode.php
|
MIT
|
public function __construct(?string $name, ?NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR)
{
if (\str_contains($name = (string) $name, $pathSeparator)) {
throw new \InvalidArgumentException('The name must not contain ".' . $pathSeparator . '".');
}
$this->name = $name;
$this->parent = $parent;
$this->pathSeparator = $pathSeparator;
}
|
@throws \InvalidArgumentException if the name contains a period
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public static function setPlaceholder(string $placeholder, array $values) : void
{
if (!$values) {
throw new \InvalidArgumentException('At least one value must be provided.');
}
self::$placeholders[$placeholder] = $values;
}
|
Register possible (dummy) values for a dynamic placeholder value.
Matching configuration values will be processed with a provided value, one by one. After a provided value is
successfully processed the configuration value is returned as is, thus preserving the placeholder.
@internal
|
setPlaceholder
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public static function setPlaceholderUniquePrefix(string $prefix) : void
{
self::$placeholderUniquePrefixes[] = $prefix;
}
|
Adds a common prefix for dynamic placeholder values.
Matching configuration values will be skipped from being processed and are returned as is, thus preserving the
placeholder. An exact match provided by {@see setPlaceholder()} might take precedence.
@internal
|
setPlaceholderUniquePrefix
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public static function resetPlaceholders() : void
{
self::$placeholderUniquePrefixes = [];
self::$placeholders = [];
}
|
Resets all current placeholders available.
@internal
|
resetPlaceholders
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function setInfo(string $info)
{
$this->setAttribute('info', $info);
}
|
Sets an info message.
@return void
|
setInfo
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function setExample(string|array $example)
{
$this->setAttribute('example', $example);
}
|
Sets the example configuration for this node.
@return void
|
setExample
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function getExample() : string|array|null
{
return $this->getAttribute('example');
}
|
Retrieves the example configuration for this node.
|
getExample
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function addEquivalentValue(mixed $originalValue, mixed $equivalentValue)
{
$this->equivalentValues[] = [$originalValue, $equivalentValue];
}
|
Adds an equivalent value.
@return void
|
addEquivalentValue
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function setRequired(bool $boolean)
{
$this->required = $boolean;
}
|
Set this node as required.
@return void
|
setRequired
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function setDeprecated(string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.')
{
$this->deprecation = ['package' => $package, 'version' => $version, 'message' => $message];
}
|
Sets this node as deprecated.
You can use %node% and %path% placeholders in your message to display,
respectively, the node name and its complete path.
@param string $package The name of the composer package that is triggering the deprecation
@param string $version The version of the package that introduced the deprecation
@param string $message the deprecation message to use
@return void
|
setDeprecated
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function setAllowOverwrite(bool $allow)
{
$this->allowOverwrite = $allow;
}
|
Sets if this node can be overridden.
@return void
|
setAllowOverwrite
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function setNormalizationClosures(array $closures)
{
$this->normalizationClosures = $closures;
}
|
Sets the closures used for normalization.
@param \Closure[] $closures An array of Closures used for normalization
@return void
|
setNormalizationClosures
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function setNormalizedTypes(array $types)
{
$this->normalizedTypes = $types;
}
|
Sets the list of types supported by normalization.
see ExprBuilder::TYPE_* constants.
@return void
|
setNormalizedTypes
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function getNormalizedTypes() : array
{
return $this->normalizedTypes;
}
|
Gets the list of types supported by normalization.
see ExprBuilder::TYPE_* constants.
|
getNormalizedTypes
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function setFinalValidationClosures(array $closures)
{
$this->finalValidationClosures = $closures;
}
|
Sets the closures used for final validation.
@param \Closure[] $closures An array of Closures used for final validation
@return void
|
setFinalValidationClosures
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function isDeprecated() : bool
{
return (bool) $this->deprecation;
}
|
Checks if this node is deprecated.
|
isDeprecated
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function getDeprecation(string $node, string $path) : array
{
return ['package' => $this->deprecation['package'], 'version' => $this->deprecation['version'], 'message' => \strtr($this->deprecation['message'], ['%node%' => $node, '%path%' => $path])];
}
|
@param string $node The configuration node name
@param string $path The path of the node
|
getDeprecation
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
protected function preNormalize(mixed $value) : mixed
{
return $value;
}
|
Normalizes the value before any other normalization is applied.
|
preNormalize
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function getParent() : ?NodeInterface
{
return $this->parent;
}
|
Returns parent node for this node.
|
getParent
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
protected function allowPlaceholders() : bool
{
return \true;
}
|
Tests if placeholder values are allowed for this node.
|
allowPlaceholders
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
protected function isHandlingPlaceholder() : bool
{
return null !== $this->handlingPlaceholder;
}
|
Tests if a placeholder is being handled currently.
|
isHandlingPlaceholder
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
protected function getValidPlaceholderTypes() : array
{
return [];
}
|
Gets allowed dynamic types for this node.
|
getValidPlaceholderTypes
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/BaseNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/BaseNode.php
|
MIT
|
public function process(NodeInterface $configTree, array $configs) : array
{
$currentConfig = [];
foreach ($configs as $config) {
$config = $configTree->normalize($config);
$currentConfig = $configTree->merge($currentConfig, $config);
}
return $configTree->finalize($currentConfig);
}
|
Processes an array of configurations.
@param array $configs An array of configuration items to process
|
process
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Processor.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Processor.php
|
MIT
|
public function processConfiguration(ConfigurationInterface $configuration, array $configs) : array
{
return $this->process($configuration->getConfigTreeBuilder()->buildTree(), $configs);
}
|
Processes an array of configurations.
@param array $configs An array of configuration items to process
|
processConfiguration
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Processor.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Processor.php
|
MIT
|
public static function normalizeConfig(array $config, string $key, ?string $plural = null) : array
{
$plural ??= $key . 's';
if (isset($config[$plural])) {
return $config[$plural];
}
if (isset($config[$key])) {
if (\is_string($config[$key]) || !\is_int(\key($config[$key]))) {
// only one
return [$config[$key]];
}
return $config[$key];
}
return [];
}
|
Normalizes a configuration entry.
This method returns a normalize configuration array for a given key
to remove the differences due to the original format (YAML and XML mainly).
Here is an example.
The configuration in XML:
<twig:extension>twig.extension.foo</twig:extension>
<twig:extension>twig.extension.bar</twig:extension>
And the same configuration in YAML:
extensions: ['twig.extension.foo', 'twig.extension.bar']
@param array $config A config array
@param string $key The key to normalize
@param string|null $plural The plural form of the key if it is irregular
|
normalizeConfig
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Processor.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Processor.php
|
MIT
|
public function setMinNumberOfElements(int $number)
{
$this->minNumberOfElements = $number;
}
|
Sets the minimum number of elements that a prototype based node must
contain. By default this is zero, meaning no elements.
@return void
|
setMinNumberOfElements
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/PrototypedArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/PrototypedArrayNode.php
|
MIT
|
public function setKeyAttribute(string $attribute, bool $remove = \true)
{
$this->keyAttribute = $attribute;
$this->removeKeyAttribute = $remove;
}
|
Sets the attribute which value is to be used as key.
This is useful when you have an indexed array that should be an
associative array. You can select an item from within the array
to be the key of the particular item. For example, if "id" is the
"key", then:
[
['id' => 'my_name', 'foo' => 'bar'],
];
becomes
[
'my_name' => ['foo' => 'bar'],
];
If you'd like "'id' => 'my_name'" to still be present in the resulting
array, then you can set the second argument of this method to false.
@param string $attribute The name of the attribute which value is to be used as a key
@param bool $remove Whether or not to remove the key
@return void
|
setKeyAttribute
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/PrototypedArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/PrototypedArrayNode.php
|
MIT
|
public function getKeyAttribute() : ?string
{
return $this->keyAttribute;
}
|
Retrieves the name of the attribute which value should be used as key.
|
getKeyAttribute
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/PrototypedArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/PrototypedArrayNode.php
|
MIT
|
public function setDefaultValue(array $value)
{
$this->defaultValue = $value;
}
|
Sets the default value of this node.
@return void
|
setDefaultValue
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/PrototypedArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/PrototypedArrayNode.php
|
MIT
|
public function setAddChildrenIfNoneSet(int|string|array|null $children = ['defaults'])
{
if (null === $children) {
$this->defaultChildren = ['defaults'];
} else {
$this->defaultChildren = \is_int($children) && $children > 0 ? \range(1, $children) : (array) $children;
}
}
|
Adds default children when none are set.
@param int|string|array|null $children The number of children|The child name|The children names to be added
@return void
|
setAddChildrenIfNoneSet
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/PrototypedArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/PrototypedArrayNode.php
|
MIT
|
public function getDefaultValue() : mixed
{
if (null !== $this->defaultChildren) {
$default = $this->prototype->hasDefaultValue() ? $this->prototype->getDefaultValue() : [];
$defaults = [];
foreach (\array_values($this->defaultChildren) as $i => $name) {
$defaults[null === $this->keyAttribute ? $i : $name] = $default;
}
return $defaults;
}
return $this->defaultValue;
}
|
The default value could be either explicited or derived from the prototype
default value.
|
getDefaultValue
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/PrototypedArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/PrototypedArrayNode.php
|
MIT
|
public function setPrototype(PrototypeNodeInterface $node)
{
$this->prototype = $node;
}
|
Sets the node prototype.
@return void
|
setPrototype
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/PrototypedArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/PrototypedArrayNode.php
|
MIT
|
public function addChild(NodeInterface $node)
{
throw new Exception('A prototyped array node cannot have concrete children.');
}
|
Disable adding concrete children for prototyped nodes.
@return never
@throws Exception
|
addChild
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/PrototypedArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/PrototypedArrayNode.php
|
MIT
|
private function getPrototypeForChild(string $key) : mixed
{
$prototype = $this->valuePrototypes[$key] ?? $this->prototype;
$prototype->setName($key);
return $prototype;
}
|
Returns a prototype for the child node that is associated to $key in the value array.
For general child nodes, this will be $this->prototype.
But if $this->removeKeyAttribute is true and there are only two keys in the child node:
one is same as this->keyAttribute and the other is 'value', then the prototype will be different.
For example, assume $this->keyAttribute is 'name' and the value array is as follows:
[
[
'name' => 'name001',
'value' => 'value001'
]
]
Now, the key is 0 and the child node is:
[
'name' => 'name001',
'value' => 'value001'
]
When normalizing the value array, the 'name' element will removed from the child node
and its value becomes the new key of the child node:
[
'name001' => ['value' => 'value001']
]
Now only 'value' element is left in the child node which can be further simplified into a string:
['name001' => 'value001']
Now, the key becomes 'name001' and the child node becomes 'value001' and
the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance.
|
getPrototypeForChild
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/PrototypedArrayNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/PrototypedArrayNode.php
|
MIT
|
public function setAllowEmptyValue(bool $boolean)
{
$this->allowEmptyValue = $boolean;
}
|
Sets if this node is allowed to have an empty value.
@param bool $boolean True if this entity will accept empty values
@return void
|
setAllowEmptyValue
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/VariableNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/VariableNode.php
|
MIT
|
protected function isValueEmpty(mixed $value) : bool
{
return empty($value);
}
|
Evaluates if the given value is to be treated as empty.
By default, PHP's empty() function is used to test for emptiness. This
method may be overridden by subtypes to better match their understanding
of empty data.
@see finalizeValue()
|
isValueEmpty
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/VariableNode.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/VariableNode.php
|
MIT
|
public function addDefaultsIfNotSet() : static
{
$this->addDefaults = \true;
return $this;
}
|
Adds the default value if the node is not set in the configuration.
This method is applicable to concrete nodes only (not to prototype nodes).
If this function has been called and the node is not set during the finalization
phase, it's default value will be derived from its children default values.
@return $this
|
addDefaultsIfNotSet
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function addDefaultChildrenIfNoneSet(int|string|array|null $children = null) : static
{
$this->addDefaultChildren = $children;
return $this;
}
|
Adds children with a default value when none are defined.
This method is applicable to prototype nodes only.
@param int|string|array|null $children The number of children|The child name|The children names to be added
@return $this
|
addDefaultChildrenIfNoneSet
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function requiresAtLeastOneElement() : static
{
$this->atLeastOne = \true;
return $this;
}
|
Requires the node to have at least one element.
This method is applicable to prototype nodes only.
@return $this
|
requiresAtLeastOneElement
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function disallowNewKeysInSubsequentConfigs() : static
{
$this->allowNewKeys = \false;
return $this;
}
|
Disallows adding news keys in a subsequent configuration.
If used all keys have to be defined in the same configuration file.
@return $this
|
disallowNewKeysInSubsequentConfigs
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function fixXmlConfig(string $singular, ?string $plural = null) : static
{
$this->normalization()->remap($singular, $plural);
return $this;
}
|
Sets a normalization rule for XML configurations.
@param string $singular The key to remap
@param string|null $plural The plural of the key for irregular plurals
@return $this
|
fixXmlConfig
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function useAttributeAsKey(string $name, bool $removeKeyItem = \true) : static
{
$this->key = $name;
$this->removeKeyItem = $removeKeyItem;
return $this;
}
|
Sets the attribute which value is to be used as key.
This is useful when you have an indexed array that should be an
associative array. You can select an item from within the array
to be the key of the particular item. For example, if "id" is the
"key", then:
[
['id' => 'my_name', 'foo' => 'bar'],
];
becomes
[
'my_name' => ['foo' => 'bar'],
];
If you'd like "'id' => 'my_name'" to still be present in the resulting
array, then you can set the second argument of this method to false.
This method is applicable to prototype nodes only.
@param string $name The name of the key
@param bool $removeKeyItem Whether or not the key item should be removed
@return $this
|
useAttributeAsKey
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function canBeUnset(bool $allow = \true) : static
{
$this->merge()->allowUnset($allow);
return $this;
}
|
Sets whether the node can be unset.
@return $this
|
canBeUnset
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function canBeEnabled() : static
{
$this->addDefaultsIfNotSet()->treatFalseLike(['enabled' => \false])->treatTrueLike(['enabled' => \true])->treatNullLike(['enabled' => \true])->beforeNormalization()->ifArray()->then(function (array $v) {
$v['enabled'] ??= \true;
return $v;
})->end()->children()->booleanNode('enabled')->defaultFalse();
return $this;
}
|
Adds an "enabled" boolean to enable the current section.
By default, the section is disabled. If any configuration is specified then
the node will be automatically enabled:
enableableArrayNode: {enabled: true, ...} # The config is enabled & default values get overridden
enableableArrayNode: ~ # The config is enabled & use the default values
enableableArrayNode: true # The config is enabled & use the default values
enableableArrayNode: {other: value, ...} # The config is enabled & default values get overridden
enableableArrayNode: {enabled: false, ...} # The config is disabled
enableableArrayNode: false # The config is disabled
@return $this
|
canBeEnabled
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function canBeDisabled() : static
{
$this->addDefaultsIfNotSet()->treatFalseLike(['enabled' => \false])->treatTrueLike(['enabled' => \true])->treatNullLike(['enabled' => \true])->children()->booleanNode('enabled')->defaultTrue();
return $this;
}
|
Adds an "enabled" boolean to enable the current section.
By default, the section is enabled.
@return $this
|
canBeDisabled
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function performNoDeepMerging() : static
{
$this->performDeepMerging = \false;
return $this;
}
|
Disables the deep merging of the node.
@return $this
|
performNoDeepMerging
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function ignoreExtraKeys(bool $remove = \true) : static
{
$this->ignoreExtraKeys = \true;
$this->removeExtraKeys = $remove;
return $this;
}
|
Allows extra config keys to be specified under an array without
throwing an exception.
Those config values are ignored and removed from the resulting
array. This should be used only in special cases where you want
to send an entire configuration array through a special tree that
processes only part of the array.
@param bool $remove Whether to remove the extra keys
@return $this
|
ignoreExtraKeys
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function normalizeKeys(bool $bool) : static
{
$this->normalizeKeys = $bool;
return $this;
}
|
Sets whether to enable key normalization.
@return $this
|
normalizeKeys
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
protected function getNodeBuilder() : NodeBuilder
{
$this->nodeBuilder ??= new NodeBuilder();
return $this->nodeBuilder->setParent($this);
}
|
Returns a node builder to be used to add children and prototype.
|
getNodeBuilder
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
protected function validateConcreteNode(ArrayNode $node)
{
$path = $node->getPath();
if (null !== $this->key) {
throw new InvalidDefinitionException(\sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s".', $path));
}
if (\false === $this->allowEmptyValue) {
throw new InvalidDefinitionException(\sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s".', $path));
}
if (\true === $this->atLeastOne) {
throw new InvalidDefinitionException(\sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s".', $path));
}
if ($this->default) {
throw new InvalidDefinitionException(\sprintf('->defaultValue() is not applicable to concrete nodes at path "%s".', $path));
}
if (\false !== $this->addDefaultChildren) {
throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s".', $path));
}
}
|
Validate the configuration of a concrete node.
@return void
@throws InvalidDefinitionException
|
validateConcreteNode
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
protected function validatePrototypeNode(PrototypedArrayNode $node)
{
$path = $node->getPath();
if ($this->addDefaults) {
throw new InvalidDefinitionException(\sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s".', $path));
}
if (\false !== $this->addDefaultChildren) {
if ($this->default) {
throw new InvalidDefinitionException(\sprintf('A default value and default children might not be used together at path "%s".', $path));
}
if (null !== $this->key && (null === $this->addDefaultChildren || \is_int($this->addDefaultChildren) && $this->addDefaultChildren > 0)) {
throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s".', $path));
}
if (null === $this->key && (\is_string($this->addDefaultChildren) || \is_array($this->addDefaultChildren))) {
throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s".', $path));
}
}
}
|
Validate the configuration of a prototype node.
@return void
@throws InvalidDefinitionException
|
validatePrototypeNode
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function find(string $nodePath) : NodeDefinition
{
$firstPathSegment = \false === ($pathSeparatorPos = \strpos($nodePath, $this->pathSeparator)) ? $nodePath : \substr($nodePath, 0, $pathSeparatorPos);
if (null === ($node = $this->children[$firstPathSegment] ?? null)) {
throw new \RuntimeException(\sprintf('Node with name "%s" does not exist in the current node "%s".', $firstPathSegment, $this->name));
}
if (\false === $pathSeparatorPos) {
return $node;
}
return $node->find(\substr($nodePath, $pathSeparatorPos + \strlen($this->pathSeparator)));
}
|
Finds a node defined by the given $nodePath.
@param string $nodePath The path of the node to find. e.g "doctrine.orm.mappings"
|
find
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
|
MIT
|
public function always(?\Closure $then = null) : static
{
$this->ifPart = static fn() => \true;
$this->allowedTypes = self::TYPE_ANY;
if (null !== $then) {
$this->thenPart = $then;
}
return $this;
}
|
Marks the expression as being always used.
@return $this
|
always
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ExprBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ExprBuilder.php
|
MIT
|
public function ifTrue(?\Closure $closure = null) : static
{
$this->ifPart = $closure ?? static fn($v) => \true === $v;
$this->allowedTypes = self::TYPE_ANY;
return $this;
}
|
Sets a closure to use as tests.
The default one tests if the value is true.
@return $this
|
ifTrue
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ExprBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ExprBuilder.php
|
MIT
|
public function ifString() : static
{
$this->ifPart = \is_string(...);
$this->allowedTypes = self::TYPE_STRING;
return $this;
}
|
Tests if the value is a string.
@return $this
|
ifString
|
php
|
deptrac/deptrac
|
vendor/symfony/config/Definition/Builder/ExprBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ExprBuilder.php
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.