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 ifNull() : static { $this->ifPart = \is_null(...); $this->allowedTypes = self::TYPE_NULL; return $this; }
Tests if the value is null. @return $this
ifNull
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 ifEmpty() : static { $this->ifPart = static fn($v) => empty($v); $this->allowedTypes = self::TYPE_ANY; return $this; }
Tests if the value is empty. @return $this
ifEmpty
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 ifArray() : static { $this->ifPart = \is_array(...); $this->allowedTypes = self::TYPE_ARRAY; return $this; }
Tests if the value is an array. @return $this
ifArray
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 ifInArray(array $array) : static { $this->ifPart = static fn($v) => \in_array($v, $array, \true); $this->allowedTypes = self::TYPE_ANY; return $this; }
Tests if the value is in an array. @return $this
ifInArray
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 ifNotInArray(array $array) : static { $this->ifPart = static fn($v) => !\in_array($v, $array, \true); $this->allowedTypes = self::TYPE_ANY; return $this; }
Tests if the value is not in an array. @return $this
ifNotInArray
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 castToArray() : static { $this->ifPart = static fn($v) => !\is_array($v); $this->allowedTypes = self::TYPE_ANY; $this->thenPart = static fn($v) => [$v]; return $this; }
Transforms variables of any type into an array. @return $this
castToArray
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 then(\Closure $closure) : static { $this->thenPart = $closure; return $this; }
Sets the closure to run if the test pass. @return $this
then
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 thenEmptyArray() : static { $this->thenPart = static fn() => []; return $this; }
Sets a closure returning an empty array. @return $this
thenEmptyArray
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 thenInvalid(string $message) : static { $this->thenPart = static fn($v) => throw new \InvalidArgumentException(\sprintf($message, \json_encode($v))); return $this; }
Sets a closure marking the value as invalid at processing time. if you want to add the value of the node in your message just use a %s placeholder. @return $this @throws \InvalidArgumentException
thenInvalid
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 thenUnset() : static { $this->thenPart = static fn() => throw new UnsetKeyException('Unsetting key.'); return $this; }
Sets a closure unsetting this key of the array at processing time. @return $this @throws UnsetKeyException
thenUnset
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 end() : NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition { if (null === $this->ifPart) { throw new \RuntimeException('You must specify an if part.'); } if (null === $this->thenPart) { throw new \RuntimeException('You must specify a then part.'); } return $this->node; }
Returns the related node. @throws \RuntimeException
end
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 static function buildExpressions(array $expressions) : array { foreach ($expressions as $k => $expr) { if ($expr instanceof self) { $if = $expr->ifPart; $then = $expr->thenPart; $expressions[$k] = static fn($v) => $if($v) ? $then($v) : $v; } } return $expressions; }
Builds the expressions. @param ExprBuilder[] $expressions An array of ExprBuilder instances to build
buildExpressions
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 allowUnset(bool $allow = \true) : static { $this->allowFalse = $allow; return $this; }
Sets whether the node can be unset. @return $this
allowUnset
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/MergeBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/MergeBuilder.php
MIT
public function denyOverwrite(bool $deny = \true) : static { $this->allowOverwrite = !$deny; return $this; }
Sets whether the node can be overwritten. @return $this
denyOverwrite
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/MergeBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/MergeBuilder.php
MIT
public function setParent(?ParentNodeDefinitionInterface $parent = null) : static { if (1 > \func_num_args()) { \DEPTRAC_INTERNAL\trigger_deprecation('symfony/form', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); } $this->parent = $parent; return $this; }
Set the parent node. @return $this
setParent
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeBuilder.php
MIT
public function end() { return $this->parent; }
Returns the parent node. @return NodeDefinition&ParentNodeDefinitionInterface
end
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeBuilder.php
MIT
public function node(?string $name, string $type) : NodeDefinition { $class = $this->getNodeClass($type); $node = new $class($name); $this->append($node); return $node; }
Creates a child node. @throws \RuntimeException When the node type is not registered @throws \RuntimeException When the node class is not found
node
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeBuilder.php
MIT
public function append(NodeDefinition $node) : static { if ($node instanceof BuilderAwareInterface) { $builder = clone $this; $builder->setParent(null); $node->setBuilder($builder); } if (null !== $this->parent) { $this->parent->append($node); // Make this builder the node parent to allow for a fluid interface $node->setParent($this); } return $this; }
Appends a node definition. Usage: $node = new ArrayNodeDefinition('name') ->children() ->scalarNode('foo')->end() ->scalarNode('baz')->end() ->append($this->getBarNodeDefinition()) ->end() ; @return $this
append
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeBuilder.php
MIT
public function setNodeClass(string $type, string $class) : static { $this->nodeMapping[\strtolower($type)] = $class; return $this; }
Adds or overrides a node Type. @param string $type The name of the type @param string $class The fully qualified name the node definition class @return $this
setNodeClass
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeBuilder.php
MIT
protected function getNodeClass(string $type) : string { $type = \strtolower($type); if (!isset($this->nodeMapping[$type])) { throw new \RuntimeException(\sprintf('The node type "%s" is not registered.', $type)); } $class = $this->nodeMapping[$type]; if (!\class_exists($class)) { throw new \RuntimeException(\sprintf('The node class "%s" does not exist.', $class)); } return $class; }
Returns the class name of the node definition. @throws \RuntimeException When the node type is not registered @throws \RuntimeException When the node class is not found
getNodeClass
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeBuilder.php
MIT
public function setParent(NodeParentInterface $parent) : static { $this->parent = $parent; return $this; }
Sets the parent node. @return $this
setParent
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function attribute(string $key, mixed $value) : static { $this->attributes[$key] = $value; return $this; }
Sets an attribute on the node. @return $this
attribute
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function defaultValue(mixed $value) : static { $this->default = \true; $this->defaultValue = $value; return $this; }
Sets the default value. @return $this
defaultValue
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function isRequired() : static { $this->required = \true; return $this; }
Sets the node as required. @return $this
isRequired
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function setDeprecated(string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.') : static { $this->deprecation = ['package' => $package, 'version' => $version, 'message' => $message]; return $this; }
Sets the node as deprecated. @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 You can use %node% and %path% placeholders in your message to display, respectively, the node name and its complete path @return $this
setDeprecated
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function treatNullLike(mixed $value) : static { $this->nullEquivalent = $value; return $this; }
Sets the equivalent value used when the node contains null. @return $this
treatNullLike
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function treatTrueLike(mixed $value) : static { $this->trueEquivalent = $value; return $this; }
Sets the equivalent value used when the node contains true. @return $this
treatTrueLike
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function treatFalseLike(mixed $value) : static { $this->falseEquivalent = $value; return $this; }
Sets the equivalent value used when the node contains false. @return $this
treatFalseLike
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function defaultNull() : static { return $this->defaultValue(null); }
Sets null as the default value. @return $this
defaultNull
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function defaultTrue() : static { return $this->defaultValue(\true); }
Sets true as the default value. @return $this
defaultTrue
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function defaultFalse() : static { return $this->defaultValue(\false); }
Sets false as the default value. @return $this
defaultFalse
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function beforeNormalization() : ExprBuilder { return $this->normalization()->before(); }
Sets an expression to run before the normalization.
beforeNormalization
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function cannotBeEmpty() : static { $this->allowEmptyValue = \false; return $this; }
Denies the node value being empty. @return $this
cannotBeEmpty
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function validate() : ExprBuilder { return $this->validation()->rule(); }
Sets an expression to run for the validation. The expression receives the value of the node and must return it. It can modify it. An exception should be thrown when the node is not valid.
validate
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function cannotBeOverwritten(bool $deny = \true) : static { $this->merge()->denyOverwrite($deny); return $this; }
Sets whether the node can be overwritten. @return $this
cannotBeOverwritten
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
protected function validation() : ValidationBuilder { return $this->validation ??= new ValidationBuilder($this); }
Gets the builder for validation rules.
validation
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
protected function merge() : MergeBuilder { return $this->merge ??= new MergeBuilder($this); }
Gets the builder for merging rules.
merge
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
protected function normalization() : NormalizationBuilder { return $this->normalization ??= new NormalizationBuilder($this); }
Gets the builder for normalization rules.
normalization
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function setPathSeparator(string $separator) : static { if ($this instanceof ParentNodeDefinitionInterface) { foreach ($this->getChildNodeDefinitions() as $child) { $child->setPathSeparator($separator); } } $this->pathSeparator = $separator; return $this; }
Set PathSeparator to use. @return $this
setPathSeparator
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NodeDefinition.php
MIT
public function remap(string $key, ?string $plural = null) : static { $this->remappings[] = [$key, null === $plural ? $key . 's' : $plural]; return $this; }
Registers a key to remap to its plural form. @param string $key The key to remap @param string|null $plural The plural of the key in case of irregular plural @return $this
remap
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NormalizationBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NormalizationBuilder.php
MIT
public function before(?\Closure $closure = null) : ExprBuilder|static { if (null !== $closure) { $this->before[] = $closure; return $this; } return $this->before[] = new ExprBuilder($this->node); }
Registers a closure to run before the normalization or an expression builder to build it if null is provided. @return ExprBuilder|$this
before
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NormalizationBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NormalizationBuilder.php
MIT
public function max(int|float $max) : static { if (isset($this->min) && $this->min > $max) { throw new \InvalidArgumentException(\sprintf('You cannot define a max(%s) as you already have a min(%s).', $max, $this->min)); } $this->max = $max; return $this; }
Ensures that the value is smaller than the given reference. @return $this @throws \InvalidArgumentException when the constraint is inconsistent
max
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php
MIT
public function min(int|float $min) : static { if (isset($this->max) && $this->max < $min) { throw new \InvalidArgumentException(\sprintf('You cannot define a min(%s) as you already have a max(%s).', $min, $this->max)); } $this->min = $min; return $this; }
Ensures that the value is bigger than the given reference. @return $this @throws \InvalidArgumentException when the constraint is inconsistent
min
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php
MIT
public function getRootNode() : NodeDefinition|ArrayNodeDefinition { return $this->root; }
@return NodeDefinition|ArrayNodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array')
getRootNode
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/TreeBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/TreeBuilder.php
MIT
public function rule(?\Closure $closure = null) : ExprBuilder|static { if (null !== $closure) { $this->rules[] = $closure; return $this; } return $this->rules[] = new ExprBuilder($this->node); }
Registers a closure to run as normalization or an expression builder to build it if null is provided. @return ExprBuilder|$this
rule
php
deptrac/deptrac
vendor/symfony/config/Definition/Builder/ValidationBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Builder/ValidationBuilder.php
MIT
private function writeValue(mixed $value) : string { if ('%%%%not_defined%%%%' === $value) { return ''; } if (\is_string($value) || \is_numeric($value)) { return $value; } if (\false === $value) { return 'false'; } if (\true === $value) { return 'true'; } if (null === $value) { return 'null'; } if (empty($value)) { return ''; } if (\is_array($value)) { return \implode(',', $value); } return ''; }
Renders the string conversion of the value.
writeValue
php
deptrac/deptrac
vendor/symfony/config/Definition/Dumper/XmlReferenceDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Dumper/XmlReferenceDumper.php
MIT
public function addHint(string $hint) { if (!$this->containsHints) { $this->message .= "\nHint: " . $hint; $this->containsHints = \true; } else { $this->message .= ', ' . $hint; } }
Adds extra information that is suffixed to the original exception message. @return void
addHint
php
deptrac/deptrac
vendor/symfony/config/Definition/Exception/InvalidConfigurationException.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Definition/Exception/InvalidConfigurationException.php
MIT
public function __construct(mixed $resource, ?string $sourceResource = null, int $code = 0, ?\Throwable $previous = null, ?string $type = null) { if (!\is_string($resource)) { try { $resource = \json_encode($resource, \JSON_THROW_ON_ERROR); } catch (\JsonException) { $resource = \sprintf('resource of type "%s"', \get_debug_type($resource)); } } $message = ''; if ($previous) { // Include the previous exception, to help the user see what might be the underlying cause // Trim the trailing period of the previous message. We only want 1 period remove so no rtrim... if (\str_ends_with($previous->getMessage(), '.')) { $trimmedMessage = \substr($previous->getMessage(), 0, -1); $message .= \sprintf('%s', $trimmedMessage) . ' in '; } else { $message .= \sprintf('%s', $previous->getMessage()) . ' in '; } $message .= $resource . ' '; // show tweaked trace to complete the human readable sentence if (null === $sourceResource) { $message .= \sprintf('(which is loaded in resource "%s")', $resource); } else { $message .= \sprintf('(which is being imported from "%s")', $sourceResource); } $message .= '.'; // if there's no previous message, present it the default way } elseif (null === $sourceResource) { $message .= \sprintf('Cannot load resource "%s".', $resource); } else { $message .= \sprintf('Cannot import resource "%s" from "%s".', $resource, $sourceResource); } // Is the resource located inside a bundle? if ('@' === $resource[0]) { $parts = \explode(\DIRECTORY_SEPARATOR, $resource); $bundle = \substr($parts[0], 1); $message .= \sprintf(' Make sure the "%s" bundle is correctly registered and loaded in the application kernel class.', $bundle); $message .= \sprintf(' If the bundle is registered, make sure the bundle path "%s" is not empty.', $resource); } elseif (null !== $type) { $message .= \sprintf(' Make sure there is a loader supporting the "%s" type.', $type); } parent::__construct($message, $code, $previous); }
@param mixed $resource The resource that could not be imported @param string|null $sourceResource The original resource importing the new resource @param int $code The error code @param \Throwable|null $previous A previous exception @param string|null $type The type of resource
__construct
php
deptrac/deptrac
vendor/symfony/config/Exception/LoaderLoadException.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Exception/LoaderLoadException.php
MIT
public function setCurrentDir(string $dir) { $this->currentDir = $dir; }
Sets the current directory. @return void
setCurrentDir
php
deptrac/deptrac
vendor/symfony/config/Loader/FileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Loader/FileLoader.php
MIT
public function getLocator() : FileLocatorInterface { return $this->locator; }
Returns the file locator used by this loader.
getLocator
php
deptrac/deptrac
vendor/symfony/config/Loader/FileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Loader/FileLoader.php
MIT
public function import(mixed $resource, ?string $type = null, bool $ignoreErrors = \false, ?string $sourceResource = null, string|array|null $exclude = null) { if (\is_string($resource) && \strlen($resource) !== ($i = \strcspn($resource, '*?{[')) && !\str_contains($resource, "\n")) { $excluded = []; foreach ((array) $exclude as $pattern) { foreach ($this->glob($pattern, \true, $_, \false, \true) as $path => $info) { // normalize Windows slashes and remove trailing slashes $excluded[\rtrim(\str_replace('\\', '/', $path), '/')] = \true; } } $ret = []; $isSubpath = 0 !== $i && \str_contains(\substr($resource, 0, $i), '/'); foreach ($this->glob($resource, \false, $_, $ignoreErrors || !$isSubpath, \false, $excluded) as $path => $info) { if (null !== ($res = $this->doImport($path, 'glob' === $type ? null : $type, $ignoreErrors, $sourceResource))) { $ret[] = $res; } $isSubpath = \true; } if ($isSubpath) { return isset($ret[1]) ? $ret : $ret[0] ?? null; } } return $this->doImport($resource, $type, $ignoreErrors, $sourceResource); }
Imports a resource. @param mixed $resource A Resource @param string|null $type The resource type or null if unknown @param bool $ignoreErrors Whether to ignore import errors or not @param string|null $sourceResource The original resource importing the new resource @param string|string[]|null $exclude Glob patterns to exclude from the import @return mixed @throws LoaderLoadException @throws FileLoaderImportCircularReferenceException @throws FileLocatorFileNotFoundException
import
php
deptrac/deptrac
vendor/symfony/config/Loader/FileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Loader/FileLoader.php
MIT
public function resolve(mixed $resource, ?string $type = null) : LoaderInterface { if ($this->supports($resource, $type)) { return $this; } $loader = null === $this->resolver ? \false : $this->resolver->resolve($resource, $type); if (\false === $loader) { throw new LoaderLoadException($resource, null, 0, null, $type); } return $loader; }
Finds a loader able to load an imported resource. @throws LoaderLoadException If no loader is found
resolve
php
deptrac/deptrac
vendor/symfony/config/Loader/Loader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Loader/Loader.php
MIT
public function __construct(array $loaders = []) { foreach ($loaders as $loader) { $this->addLoader($loader); } }
@param LoaderInterface[] $loaders An array of loaders
__construct
php
deptrac/deptrac
vendor/symfony/config/Loader/LoaderResolver.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Loader/LoaderResolver.php
MIT
public function getLoaders() : array { return $this->loaders; }
Returns the registered loaders. @return LoaderInterface[]
getLoaders
php
deptrac/deptrac
vendor/symfony/config/Loader/LoaderResolver.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Loader/LoaderResolver.php
MIT
public function __construct(string $resource, ?bool $exists = null) { $this->resource = $resource; if (null !== $exists) { $this->exists = [$exists, null]; } }
@param string $resource The fully-qualified class name @param bool|null $exists Boolean when the existence check has already been done
__construct
php
deptrac/deptrac
vendor/symfony/config/Resource/ClassExistenceResource.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Resource/ClassExistenceResource.php
MIT
public function isFresh(int $timestamp) : bool { $loaded = \class_exists($this->resource, \false) || \interface_exists($this->resource, \false) || \trait_exists($this->resource, \false); if (null !== ($exists =& self::$existsCache[$this->resource])) { if ($loaded) { $exists = [\true, null]; } elseif (0 >= $timestamp && !$exists[0] && null !== $exists[1]) { throw new \ReflectionException($exists[1]); } } elseif ([\false, null] === ($exists = [$loaded, null])) { if (!self::$autoloadLevel++) { \spl_autoload_register(__CLASS__ . '::throwOnRequiredClass'); } $autoloadedClass = self::$autoloadedClass; self::$autoloadedClass = \ltrim($this->resource, '\\'); try { $exists[0] = \class_exists($this->resource) || \interface_exists($this->resource, \false) || \trait_exists($this->resource, \false); } catch (\Exception $e) { $exists[1] = $e->getMessage(); try { self::throwOnRequiredClass($this->resource, $e); } catch (\ReflectionException $e) { if (0 >= $timestamp) { throw $e; } } } catch (\Throwable $e) { $exists[1] = $e->getMessage(); throw $e; } finally { self::$autoloadedClass = $autoloadedClass; if (!--self::$autoloadLevel) { \spl_autoload_unregister(__CLASS__ . '::throwOnRequiredClass'); } } } $this->exists ??= $exists; return $this->exists[0] xor !$exists[0]; }
@throws \ReflectionException when a parent class/interface/trait is not found
isFresh
php
deptrac/deptrac
vendor/symfony/config/Resource/ClassExistenceResource.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Resource/ClassExistenceResource.php
MIT
public static function throwOnRequiredClass(string $class, ?\Exception $previous = null) : void { // If the passed class is the resource being checked, we shouldn't throw. if (null === $previous && self::$autoloadedClass === $class) { return; } if (\class_exists($class, \false) || \interface_exists($class, \false) || \trait_exists($class, \false)) { if (null !== $previous) { throw $previous; } return; } if ($previous instanceof \ReflectionException) { throw $previous; } $message = \sprintf('Class "%s" not found.', $class); if ($class !== (self::$autoloadedClass ?? $class)) { $message = \substr_replace($message, \sprintf(' while loading "%s"', self::$autoloadedClass), -1, 0); } if (null !== $previous) { $message = $previous->getMessage(); } $e = new \ReflectionException($message, 0, $previous); if (null !== $previous) { throw $e; } $trace = \debug_backtrace(); $autoloadFrame = ['function' => 'spl_autoload_call', 'args' => [$class]]; if (isset($trace[1])) { $callerFrame = $trace[1]; $i = 2; } elseif (\false !== ($i = \array_search($autoloadFrame, $trace, \true))) { $callerFrame = $trace[++$i]; } else { throw $e; } if (isset($callerFrame['function']) && !isset($callerFrame['class'])) { switch ($callerFrame['function']) { case 'get_class_methods': case 'get_class_vars': case 'get_parent_class': case 'is_a': case 'is_subclass_of': case 'class_exists': case 'class_implements': case 'class_parents': case 'trait_exists': case 'defined': case 'interface_exists': case 'method_exists': case 'property_exists': case 'is_callable': return; } $props = ['file' => $callerFrame['file'] ?? null, 'line' => $callerFrame['line'] ?? null, 'trace' => \array_slice($trace, 1 + $i)]; foreach ($props as $p => $v) { if (null !== $v) { $r = new \ReflectionProperty(\Exception::class, $p); $r->setValue($e, $v); } } } throw $e; }
Throws a reflection exception when the passed class does not exist but is required. A class is considered "not required" when it's loaded as part of a "class_exists" or similar check. This function can be used as an autoload function to throw a reflection exception if the class was not found by previous autoload functions. A previous exception can be passed. In this case, the class is considered as being required totally, so if it doesn't exist, a reflection exception is always thrown. If it exists, the previous exception is rethrown. @throws \ReflectionException @internal
throwOnRequiredClass
php
deptrac/deptrac
vendor/symfony/config/Resource/ClassExistenceResource.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Resource/ClassExistenceResource.php
MIT
public function __construct(string $resource, ?string $pattern = null) { $resolvedResource = \realpath($resource) ?: (\file_exists($resource) ? $resource : \false); $this->pattern = $pattern; if (\false === $resolvedResource || !\is_dir($resolvedResource)) { throw new \InvalidArgumentException(\sprintf('The directory "%s" does not exist.', $resource)); } $this->resource = $resolvedResource; }
@param string $resource The file path to the resource @param string|null $pattern A pattern to restrict monitored files @throws \InvalidArgumentException
__construct
php
deptrac/deptrac
vendor/symfony/config/Resource/DirectoryResource.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Resource/DirectoryResource.php
MIT
public function __construct(string $resource) { $this->resource = $resource; $this->exists = \file_exists($resource); }
@param string $resource The file path to the resource
__construct
php
deptrac/deptrac
vendor/symfony/config/Resource/FileExistenceResource.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Resource/FileExistenceResource.php
MIT
public function __construct(string $resource) { $resolvedResource = \realpath($resource) ?: (\file_exists($resource) ? $resource : \false); if (\false === $resolvedResource) { throw new \InvalidArgumentException(\sprintf('The file "%s" does not exist.', $resource)); } $this->resource = $resolvedResource; }
@param string $resource The file path to the resource @throws \InvalidArgumentException
__construct
php
deptrac/deptrac
vendor/symfony/config/Resource/FileResource.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Resource/FileResource.php
MIT
public function getResource() : string { return $this->resource; }
Returns the canonicalized, absolute path to the resource.
getResource
php
deptrac/deptrac
vendor/symfony/config/Resource/FileResource.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Resource/FileResource.php
MIT
public function __construct(string $prefix, string $pattern, bool $recursive, bool $forExclusion = \false, array $excludedPrefixes = []) { \ksort($excludedPrefixes); $resolvedPrefix = \realpath($prefix) ?: (\file_exists($prefix) ? $prefix : \false); $this->pattern = $pattern; $this->recursive = $recursive; $this->forExclusion = $forExclusion; $this->excludedPrefixes = $excludedPrefixes; $this->globBrace = \defined('GLOB_BRACE') ? \GLOB_BRACE : 0; if (\false === $resolvedPrefix) { throw new \InvalidArgumentException(\sprintf('The path "%s" does not exist.', $prefix)); } $this->prefix = $resolvedPrefix; }
@param string $prefix A directory prefix @param string $pattern A glob pattern @param bool $recursive Whether directories should be scanned recursively or not @throws \InvalidArgumentException
__construct
php
deptrac/deptrac
vendor/symfony/config/Resource/GlobResource.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Resource/GlobResource.php
MIT
public static function parse(string $content, string|callable|null $schemaOrCallable = null) : \DOMDocument { if (!\extension_loaded('dom')) { throw new \LogicException('Extension DOM is required.'); } $internalErrors = \libxml_use_internal_errors(\true); \libxml_clear_errors(); $dom = new \DOMDocument(); $dom->validateOnParse = \true; if (!$dom->loadXML($content, \LIBXML_NONET | \LIBXML_COMPACT)) { throw new XmlParsingException(\implode("\n", static::getXmlErrors($internalErrors))); } $dom->normalizeDocument(); \libxml_use_internal_errors($internalErrors); foreach ($dom->childNodes as $child) { if (\XML_DOCUMENT_TYPE_NODE === $child->nodeType) { throw new XmlParsingException('Document types are not allowed.'); } } if (null !== $schemaOrCallable) { $internalErrors = \libxml_use_internal_errors(\true); \libxml_clear_errors(); $e = null; if (\is_callable($schemaOrCallable)) { try { $valid = $schemaOrCallable($dom, $internalErrors); } catch (\Exception $e) { $valid = \false; } } elseif (\is_file($schemaOrCallable)) { $schemaSource = \file_get_contents((string) $schemaOrCallable); $valid = @$dom->schemaValidateSource($schemaSource); } else { \libxml_use_internal_errors($internalErrors); throw new XmlParsingException(\sprintf('Invalid XSD file: "%s".', $schemaOrCallable)); } if (!$valid) { $messages = static::getXmlErrors($internalErrors); if (!$messages) { throw new InvalidXmlException('The XML is not valid.', 0, $e); } throw new XmlParsingException(\implode("\n", $messages), 0, $e); } } \libxml_clear_errors(); \libxml_use_internal_errors($internalErrors); return $dom; }
Parses an XML string. @param string $content An XML string @param string|callable|null $schemaOrCallable An XSD schema file path, a callable, or null to disable validation @throws XmlParsingException When parsing of XML file returns error @throws InvalidXmlException When parsing of XML with schema or callable produces any errors unrelated to the XML parsing itself @throws \RuntimeException When DOM extension is missing
parse
php
deptrac/deptrac
vendor/symfony/config/Util/XmlUtils.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Util/XmlUtils.php
MIT
public static function loadFile(string $file, string|callable|null $schemaOrCallable = null) : \DOMDocument { if (!\is_file($file)) { throw new \InvalidArgumentException(\sprintf('Resource "%s" is not a file.', $file)); } if (!\is_readable($file)) { throw new \InvalidArgumentException(\sprintf('File "%s" is not readable.', $file)); } $content = @\file_get_contents($file); if ('' === \trim($content)) { throw new \InvalidArgumentException(\sprintf('File "%s" does not contain valid XML, it is empty.', $file)); } try { return static::parse($content, $schemaOrCallable); } catch (InvalidXmlException $e) { throw new XmlParsingException(\sprintf('The XML file "%s" is not valid.', $file), 0, $e->getPrevious()); } }
Loads an XML file. @param string $file An XML file path @param string|callable|null $schemaOrCallable An XSD schema file path, a callable, or null to disable validation @throws \InvalidArgumentException When loading of XML file returns error @throws XmlParsingException When XML parsing returns any errors @throws \RuntimeException When DOM extension is missing
loadFile
php
deptrac/deptrac
vendor/symfony/config/Util/XmlUtils.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Util/XmlUtils.php
MIT
public static function convertDomElementToArray(\DOMElement $element, bool $checkPrefix = \true) : mixed { $prefix = (string) $element->prefix; $empty = \true; $config = []; foreach ($element->attributes as $name => $node) { if ($checkPrefix && !\in_array((string) $node->prefix, ['', $prefix], \true)) { continue; } $config[$name] = static::phpize($node->value); $empty = \false; } $nodeValue = \false; foreach ($element->childNodes as $node) { if ($node instanceof \DOMText) { if ('' !== \trim($node->nodeValue)) { $nodeValue = \trim($node->nodeValue); $empty = \false; } } elseif ($checkPrefix && $prefix != (string) $node->prefix) { continue; } elseif (!$node instanceof \DOMComment) { $value = static::convertDomElementToArray($node, $checkPrefix); $key = $node->localName; if (isset($config[$key])) { if (!\is_array($config[$key]) || !\is_int(\key($config[$key]))) { $config[$key] = [$config[$key]]; } $config[$key][] = $value; } else { $config[$key] = $value; } $empty = \false; } } if (\false !== $nodeValue) { $value = static::phpize($nodeValue); if (\count($config)) { $config['value'] = $value; } else { $config = $value; } } return !$empty ? $config : null; }
Converts a \DOMElement object to a PHP array. The following rules applies during the conversion: * Each tag is converted to a key value or an array if there is more than one "value" * The content of a tag is set under a "value" key (<foo>bar</foo>) if the tag also has some nested tags * The attributes are converted to keys (<foo foo="bar"/>) * The nested-tags are converted to keys (<foo><foo>bar</foo></foo>) @param \DOMElement $element A \DOMElement instance @param bool $checkPrefix Check prefix in an element or an attribute name
convertDomElementToArray
php
deptrac/deptrac
vendor/symfony/config/Util/XmlUtils.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Util/XmlUtils.php
MIT
public static function phpize(string|\Stringable $value) : mixed { $value = (string) $value; $lowercaseValue = \strtolower($value); switch (\true) { case 'null' === $lowercaseValue: return null; case \ctype_digit($value): case isset($value[1]) && '-' === $value[0] && \ctype_digit(\substr($value, 1)): $raw = $value; $cast = (int) $value; return self::isOctal($value) ? \intval($value, 8) : ($raw === (string) $cast ? $cast : $raw); case 'true' === $lowercaseValue: return \true; case 'false' === $lowercaseValue: return \false; case isset($value[1]) && '0b' == $value[0] . $value[1] && \preg_match('/^0b[01]*$/', $value): return \bindec($value); case \is_numeric($value): return '0x' === $value[0] . $value[1] ? \hexdec($value) : (float) $value; case \preg_match('/^0x[0-9a-f]++$/i', $value): return \hexdec($value); case \preg_match('/^[+-]?[0-9]+(\\.[0-9]+)?$/', $value): return (float) $value; default: return $value; } }
Converts an xml value to a PHP type.
phpize
php
deptrac/deptrac
vendor/symfony/config/Util/XmlUtils.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/config/Util/XmlUtils.php
MIT
public function run(?InputInterface $input = null, ?OutputInterface $output = null) : int { if (\function_exists('putenv')) { @\putenv('LINES=' . $this->terminal->getHeight()); @\putenv('COLUMNS=' . $this->terminal->getWidth()); } $input ??= new ArgvInput(); $output ??= new ConsoleOutput(); $renderException = function (\Throwable $e) use($output) { if ($output instanceof ConsoleOutputInterface) { $this->renderThrowable($e, $output->getErrorOutput()); } else { $this->renderThrowable($e, $output); } }; if ($phpHandler = \set_exception_handler($renderException)) { \restore_exception_handler(); if (!\is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) { $errorHandler = \true; } elseif ($errorHandler = $phpHandler[0]->setExceptionHandler($renderException)) { $phpHandler[0]->setExceptionHandler($errorHandler); } } try { $this->configureIO($input, $output); $exitCode = $this->doRun($input, $output); } catch (\Throwable $e) { if ($e instanceof \Exception && !$this->catchExceptions) { throw $e; } if (!$e instanceof \Exception && !$this->catchErrors) { throw $e; } $renderException($e); $exitCode = $e->getCode(); if (\is_numeric($exitCode)) { $exitCode = (int) $exitCode; if ($exitCode <= 0) { $exitCode = 1; } } else { $exitCode = 1; } } finally { // if the exception handler changed, keep it // otherwise, unregister $renderException if (!$phpHandler) { if (\set_exception_handler($renderException) === $renderException) { \restore_exception_handler(); } \restore_exception_handler(); } elseif (!$errorHandler) { $finalHandler = $phpHandler[0]->setExceptionHandler(null); if ($finalHandler !== $renderException) { $phpHandler[0]->setExceptionHandler($finalHandler); } } } if ($this->autoExit) { if ($exitCode > 255) { $exitCode = 255; } exit($exitCode); } return $exitCode; }
Runs the current application. @return int 0 if everything went fine, or an error code @throws \Exception When running fails. Bypass this when {@link setCatchExceptions()}.
run
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function doRun(InputInterface $input, OutputInterface $output) { if (\true === $input->hasParameterOption(['--version', '-V'], \true)) { $output->writeln($this->getLongVersion()); return 0; } try { // Makes ArgvInput::getFirstArgument() able to distinguish an option from an argument. $input->bind($this->getDefinition()); } catch (ExceptionInterface) { // Errors must be ignored, full binding/validation happens later when the command is known. } $name = $this->getCommandName($input); if (\true === $input->hasParameterOption(['--help', '-h'], \true)) { if (!$name) { $name = 'help'; $input = new ArrayInput(['command_name' => $this->defaultCommand]); } else { $this->wantHelps = \true; } } if (!$name) { $name = $this->defaultCommand; $definition = $this->getDefinition(); $definition->setArguments(\array_merge($definition->getArguments(), ['command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name)])); } try { $this->runningCommand = null; // the command name MUST be the first element of the input $command = $this->find($name); } catch (\Throwable $e) { if ($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException && 1 === \count($alternatives = $e->getAlternatives()) && $input->isInteractive()) { $alternative = $alternatives[0]; $style = new SymfonyStyle($input, $output); $output->writeln(''); $formattedBlock = (new FormatterHelper())->formatBlock(\sprintf('Command "%s" is not defined.', $name), 'error', \true); $output->writeln($formattedBlock); if (!$style->confirm(\sprintf('Do you want to run "%s" instead? ', $alternative), \false)) { if (null !== $this->dispatcher) { $event = new ConsoleErrorEvent($input, $output, $e); $this->dispatcher->dispatch($event, ConsoleEvents::ERROR); return $event->getExitCode(); } return 1; } $command = $this->find($alternative); } else { if (null !== $this->dispatcher) { $event = new ConsoleErrorEvent($input, $output, $e); $this->dispatcher->dispatch($event, ConsoleEvents::ERROR); if (0 === $event->getExitCode()) { return 0; } $e = $event->getError(); } try { if ($e instanceof CommandNotFoundException && ($namespace = $this->findNamespace($name))) { $helper = new DescriptorHelper(); $helper->describe($output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output, $this, ['format' => 'txt', 'raw_text' => \false, 'namespace' => $namespace, 'short' => \false]); return isset($event) ? $event->getExitCode() : 1; } throw $e; } catch (NamespaceNotFoundException) { throw $e; } } } if ($command instanceof LazyCommand) { $command = $command->getCommand(); } $this->runningCommand = $command; $exitCode = $this->doRunCommand($command, $input, $output); $this->runningCommand = null; return $exitCode; }
Runs the current application. @return int 0 if everything went fine, or an error code
doRun
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function getHelperSet() : HelperSet { return $this->helperSet ??= $this->getDefaultHelperSet(); }
Get the helper set associated with the command.
getHelperSet
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function getDefinition() : InputDefinition { $this->definition ??= $this->getDefaultInputDefinition(); if ($this->singleCommand) { $inputDefinition = $this->definition; $inputDefinition->setArguments(); return $inputDefinition; } return $this->definition; }
Gets the InputDefinition related to this Application.
getDefinition
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function complete(CompletionInput $input, CompletionSuggestions $suggestions) : void { if (CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType() && 'command' === $input->getCompletionName()) { foreach ($this->all() as $name => $command) { // skip hidden commands and aliased commands as they already get added below if ($command->isHidden() || $command->getName() !== $name) { continue; } $suggestions->suggestValue(new Suggestion($command->getName(), $command->getDescription())); foreach ($command->getAliases() as $name) { $suggestions->suggestValue(new Suggestion($name, $command->getDescription())); } } return; } if (CompletionInput::TYPE_OPTION_NAME === $input->getCompletionType()) { $suggestions->suggestOptions($this->getDefinition()->getOptions()); return; } }
Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
complete
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function areExceptionsCaught() : bool { return $this->catchExceptions; }
Gets whether to catch exceptions or not during commands execution.
areExceptionsCaught
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function setCatchExceptions(bool $boolean) { $this->catchExceptions = $boolean; }
Sets whether to catch exceptions or not during commands execution. @return void
setCatchExceptions
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function setCatchErrors(bool $catchErrors = \true) : void { $this->catchErrors = $catchErrors; }
Sets whether to catch errors or not during commands execution.
setCatchErrors
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function isAutoExitEnabled() : bool { return $this->autoExit; }
Gets whether to automatically exit after a command execution or not.
isAutoExitEnabled
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function setAutoExit(bool $boolean) { $this->autoExit = $boolean; }
Sets whether to automatically exit after a command execution or not. @return void
setAutoExit
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function getName() : string { return $this->name; }
Gets the name of the application.
getName
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function setName(string $name) { $this->name = $name; }
Sets the application name. @return void
setName
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function setVersion(string $version) { $this->version = $version; }
Sets the application version. @return void
setVersion
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function getLongVersion() { if ('UNKNOWN' !== $this->getName()) { if ('UNKNOWN' !== $this->getVersion()) { return \sprintf('%s <info>%s</info>', $this->getName(), $this->getVersion()); } return $this->getName(); } return 'Console Tool'; }
Returns the long version of the application. @return string
getLongVersion
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function addCommands(array $commands) { foreach ($commands as $command) { $this->add($command); } }
Adds an array of command objects. If a Command is not enabled it will not be added. @param Command[] $commands An array of commands @return void
addCommands
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function add(Command $command) { $this->init(); $command->setApplication($this); if (!$command->isEnabled()) { $command->setApplication(null); return null; } if (!$command instanceof LazyCommand) { // Will throw if the command is not correctly initialized. $command->getDefinition(); } if (!$command->getName()) { throw new LogicException(\sprintf('The command defined in "%s" cannot have an empty name.', \get_debug_type($command))); } $this->commands[$command->getName()] = $command; foreach ($command->getAliases() as $alias) { $this->commands[$alias] = $command; } return $command; }
Adds a command object. If a command with the same name already exists, it will be overridden. If the command is not enabled it will not be added. @return Command|null
add
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function get(string $name) { $this->init(); if (!$this->has($name)) { throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name)); } // When the command has a different name than the one used at the command loader level if (!isset($this->commands[$name])) { throw new CommandNotFoundException(\sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name)); } $command = $this->commands[$name]; if ($this->wantHelps) { $this->wantHelps = \false; $helpCommand = $this->get('help'); $helpCommand->setCommand($command); return $helpCommand; } return $command; }
Returns a registered command by name or alias. @return Command @throws CommandNotFoundException When given command name does not exist
get
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function has(string $name) : bool { $this->init(); return isset($this->commands[$name]) || $this->commandLoader?->has($name) && $this->add($this->commandLoader->get($name)); }
Returns true if the command exists, false otherwise.
has
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function getNamespaces() : array { $namespaces = []; foreach ($this->all() as $command) { if ($command->isHidden()) { continue; } $namespaces[] = $this->extractAllNamespaces($command->getName()); foreach ($command->getAliases() as $alias) { $namespaces[] = $this->extractAllNamespaces($alias); } } return \array_values(\array_unique(\array_filter(\array_merge([], ...$namespaces)))); }
Returns an array of all unique namespaces used by currently registered commands. It does not return the global namespace which always exists. @return string[]
getNamespaces
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function findNamespace(string $namespace) : string { $allNamespaces = $this->getNamespaces(); $expr = \implode('[^:]*:', \array_map('preg_quote', \explode(':', $namespace))) . '[^:]*'; $namespaces = \preg_grep('{^' . $expr . '}', $allNamespaces); if (empty($namespaces)) { $message = \sprintf('There are no commands defined in the "%s" namespace.', $namespace); if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) { if (1 == \count($alternatives)) { $message .= "\n\nDid you mean this?\n "; } else { $message .= "\n\nDid you mean one of these?\n "; } $message .= \implode("\n ", $alternatives); } throw new NamespaceNotFoundException($message, $alternatives); } $exact = \in_array($namespace, $namespaces, \true); if (\count($namespaces) > 1 && !$exact) { throw new NamespaceNotFoundException(\sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $namespace, $this->getAbbreviationSuggestions(\array_values($namespaces))), \array_values($namespaces)); } return $exact ? $namespace : \reset($namespaces); }
Finds a registered namespace by a name or an abbreviation. @throws NamespaceNotFoundException When namespace is incorrect or ambiguous
findNamespace
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function find(string $name) { $this->init(); $aliases = []; foreach ($this->commands as $command) { foreach ($command->getAliases() as $alias) { if (!$this->has($alias)) { $this->commands[$alias] = $command; } } } if ($this->has($name)) { return $this->get($name); } $allCommands = $this->commandLoader ? \array_merge($this->commandLoader->getNames(), \array_keys($this->commands)) : \array_keys($this->commands); $expr = \implode('[^:]*:', \array_map('preg_quote', \explode(':', $name))) . '[^:]*'; $commands = \preg_grep('{^' . $expr . '}', $allCommands); if (empty($commands)) { $commands = \preg_grep('{^' . $expr . '}i', $allCommands); } // if no commands matched or we just matched namespaces if (empty($commands) || \count(\preg_grep('{^' . $expr . '$}i', $commands)) < 1) { if (\false !== ($pos = \strrpos($name, ':'))) { // check if a namespace exists and contains commands $this->findNamespace(\substr($name, 0, $pos)); } $message = \sprintf('Command "%s" is not defined.', $name); if ($alternatives = $this->findAlternatives($name, $allCommands)) { // remove hidden commands $alternatives = \array_filter($alternatives, fn($name) => !$this->get($name)->isHidden()); if (1 == \count($alternatives)) { $message .= "\n\nDid you mean this?\n "; } else { $message .= "\n\nDid you mean one of these?\n "; } $message .= \implode("\n ", $alternatives); } throw new CommandNotFoundException($message, \array_values($alternatives)); } // filter out aliases for commands which are already on the list if (\count($commands) > 1) { $commandList = $this->commandLoader ? \array_merge(\array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands; $commands = \array_unique(\array_filter($commands, function ($nameOrAlias) use(&$commandList, $commands, &$aliases) { if (!$commandList[$nameOrAlias] instanceof Command) { $commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias); } $commandName = $commandList[$nameOrAlias]->getName(); $aliases[$nameOrAlias] = $commandName; return $commandName === $nameOrAlias || !\in_array($commandName, $commands); })); } if (\count($commands) > 1) { $usableWidth = $this->terminal->getWidth() - 10; $abbrevs = \array_values($commands); $maxLen = 0; foreach ($abbrevs as $abbrev) { $maxLen = \max(Helper::width($abbrev), $maxLen); } $abbrevs = \array_map(function ($cmd) use($commandList, $usableWidth, $maxLen, &$commands) { if ($commandList[$cmd]->isHidden()) { unset($commands[\array_search($cmd, $commands)]); return \false; } $abbrev = \str_pad($cmd, $maxLen, ' ') . ' ' . $commandList[$cmd]->getDescription(); return Helper::width($abbrev) > $usableWidth ? Helper::substr($abbrev, 0, $usableWidth - 3) . '...' : $abbrev; }, \array_values($commands)); if (\count($commands) > 1) { $suggestions = $this->getAbbreviationSuggestions(\array_filter($abbrevs)); throw new CommandNotFoundException(\sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $name, $suggestions), \array_values($commands)); } } $command = $this->get(\reset($commands)); if ($command->isHidden()) { throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name)); } return $command; }
Finds a command by name or alias. Contrary to get, this command tries to find the best match if you give it an abbreviation of a name or alias. @return Command @throws CommandNotFoundException When command name is incorrect or ambiguous
find
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function all(?string $namespace = null) { $this->init(); if (null === $namespace) { if (!$this->commandLoader) { return $this->commands; } $commands = $this->commands; foreach ($this->commandLoader->getNames() as $name) { if (!isset($commands[$name]) && $this->has($name)) { $commands[$name] = $this->get($name); } } return $commands; } $commands = []; foreach ($this->commands as $name => $command) { if ($namespace === $this->extractNamespace($name, \substr_count($namespace, ':') + 1)) { $commands[$name] = $command; } } if ($this->commandLoader) { foreach ($this->commandLoader->getNames() as $name) { if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, \substr_count($namespace, ':') + 1) && $this->has($name)) { $commands[$name] = $this->get($name); } } } return $commands; }
Gets the commands (registered in the given namespace if provided). The array keys are the full names and the values the command instances. @return Command[]
all
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public static function getAbbreviations(array $names) : array { $abbrevs = []; foreach ($names as $name) { for ($len = \strlen($name); $len > 0; --$len) { $abbrev = \substr($name, 0, $len); $abbrevs[$abbrev][] = $name; } } return $abbrevs; }
Returns an array of possible abbreviations given a set of names. @return string[][]
getAbbreviations
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
protected function configureIO(InputInterface $input, OutputInterface $output) { if (\true === $input->hasParameterOption(['--ansi'], \true)) { $output->setDecorated(\true); } elseif (\true === $input->hasParameterOption(['--no-ansi'], \true)) { $output->setDecorated(\false); } if (\true === $input->hasParameterOption(['--no-interaction', '-n'], \true)) { $input->setInteractive(\false); } switch ($shellVerbosity = (int) \getenv('SHELL_VERBOSITY')) { case -1: $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); break; case 1: $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); break; case 2: $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); break; case 3: $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); break; default: $shellVerbosity = 0; break; } if (\true === $input->hasParameterOption(['--quiet', '-q'], \true)) { $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); $shellVerbosity = -1; } else { if ($input->hasParameterOption('-vvv', \true) || $input->hasParameterOption('--verbose=3', \true) || 3 === $input->getParameterOption('--verbose', \false, \true)) { $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); $shellVerbosity = 3; } elseif ($input->hasParameterOption('-vv', \true) || $input->hasParameterOption('--verbose=2', \true) || 2 === $input->getParameterOption('--verbose', \false, \true)) { $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); $shellVerbosity = 2; } elseif ($input->hasParameterOption('-v', \true) || $input->hasParameterOption('--verbose=1', \true) || $input->hasParameterOption('--verbose', \true) || $input->getParameterOption('--verbose', \false, \true)) { $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); $shellVerbosity = 1; } } if (-1 === $shellVerbosity) { $input->setInteractive(\false); } if (\function_exists('putenv')) { @\putenv('SHELL_VERBOSITY=' . $shellVerbosity); } $_ENV['SHELL_VERBOSITY'] = $shellVerbosity; $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity; }
Configures the input and output instances based on the user arguments and options. @return void
configureIO
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { foreach ($command->getHelperSet() as $helper) { if ($helper instanceof InputAwareInterface) { $helper->setInput($input); } } $commandSignals = $command instanceof SignalableCommandInterface ? $command->getSubscribedSignals() : []; if ($commandSignals || $this->dispatcher && $this->signalsToDispatchEvent) { if (!$this->signalRegistry) { throw new RuntimeException('Unable to subscribe to signal events. Make sure that the "pcntl" extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.'); } if (Terminal::hasSttyAvailable()) { $sttyMode = \shell_exec('stty -g'); foreach ([\SIGINT, \SIGTERM] as $signal) { $this->signalRegistry->register($signal, static fn() => \shell_exec('stty ' . $sttyMode)); } } if ($this->dispatcher) { // We register application signals, so that we can dispatch the event foreach ($this->signalsToDispatchEvent as $signal) { $event = new ConsoleSignalEvent($command, $input, $output, $signal); $this->signalRegistry->register($signal, function ($signal) use($event, $command, $commandSignals) { $this->dispatcher->dispatch($event, ConsoleEvents::SIGNAL); $exitCode = $event->getExitCode(); // If the command is signalable, we call the handleSignal() method if (\in_array($signal, $commandSignals, \true)) { $exitCode = $command->handleSignal($signal, $exitCode); // BC layer for Symfony <= 5 if (null === $exitCode) { \DEPTRAC_INTERNAL\trigger_deprecation('symfony/console', '6.3', 'Not returning an exit code from "%s::handleSignal()" is deprecated, return "false" to keep the command running or "0" to exit successfully.', \get_debug_type($command)); $exitCode = 0; } } if (\false !== $exitCode) { $event = new ConsoleTerminateEvent($command, $event->getInput(), $event->getOutput(), $exitCode, $signal); $this->dispatcher->dispatch($event, ConsoleEvents::TERMINATE); exit($event->getExitCode()); } }); } // then we register command signals, but not if already handled after the dispatcher $commandSignals = \array_diff($commandSignals, $this->signalsToDispatchEvent); } foreach ($commandSignals as $signal) { $this->signalRegistry->register($signal, function (int $signal) use($command) : void { $exitCode = $command->handleSignal($signal); // BC layer for Symfony <= 5 if (null === $exitCode) { \DEPTRAC_INTERNAL\trigger_deprecation('symfony/console', '6.3', 'Not returning an exit code from "%s::handleSignal()" is deprecated, return "false" to keep the command running or "0" to exit successfully.', \get_debug_type($command)); $exitCode = 0; } if (\false !== $exitCode) { exit($exitCode); } }); } } if (null === $this->dispatcher) { return $command->run($input, $output); } // bind before the console.command event, so the listeners have access to input options/arguments try { $command->mergeApplicationDefinition(); $input->bind($command->getDefinition()); } catch (ExceptionInterface) { // ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition } $event = new ConsoleCommandEvent($command, $input, $output); $e = null; try { $this->dispatcher->dispatch($event, ConsoleEvents::COMMAND); if ($event->commandShouldRun()) { $exitCode = $command->run($input, $output); } else { $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED; } } catch (\Throwable $e) { $event = new ConsoleErrorEvent($input, $output, $e, $command); $this->dispatcher->dispatch($event, ConsoleEvents::ERROR); $e = $event->getError(); if (0 === ($exitCode = $event->getExitCode())) { $e = null; } } $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode); $this->dispatcher->dispatch($event, ConsoleEvents::TERMINATE); if (null !== $e) { throw $e; } return $event->getExitCode(); }
Runs the current command. If an event dispatcher has been attached to the application, events are also dispatched during the life-cycle of the command. @return int 0 if everything went fine, or an error code
doRunCommand
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
protected function getCommandName(InputInterface $input) : ?string { return $this->singleCommand ? $this->defaultCommand : $input->getFirstArgument(); }
Gets the name of the command based on input.
getCommandName
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
protected function getDefaultCommands() : array { return [new HelpCommand(), new ListCommand(), new CompleteCommand(), new DumpCompletionCommand()]; }
Gets the default commands that should always be available. @return Command[]
getDefaultCommands
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
protected function getDefaultHelperSet() : HelperSet { return new HelperSet([new FormatterHelper(), new DebugFormatterHelper(), new ProcessHelper(), new QuestionHelper()]); }
Gets the default helper set with the helpers that should always be available.
getDefaultHelperSet
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
private function getAbbreviationSuggestions(array $abbrevs) : string { return ' ' . \implode("\n ", $abbrevs); }
Returns abbreviated suggestions in string format.
getAbbreviationSuggestions
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function extractNamespace(string $name, ?int $limit = null) : string { $parts = \explode(':', $name, -1); return \implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit)); }
Returns the namespace part of the command name. This method is not part of public API and should not be used directly.
extractNamespace
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
private function findAlternatives(string $name, iterable $collection) : array { $threshold = 1000.0; $alternatives = []; $collectionParts = []; foreach ($collection as $item) { $collectionParts[$item] = \explode(':', $item); } foreach (\explode(':', $name) as $i => $subname) { foreach ($collectionParts as $collectionName => $parts) { $exists = isset($alternatives[$collectionName]); if (!isset($parts[$i]) && $exists) { $alternatives[$collectionName] += $threshold; continue; } elseif (!isset($parts[$i])) { continue; } $lev = \levenshtein($subname, $parts[$i]); if ($lev <= \strlen($subname) / 3 || '' !== $subname && \str_contains($parts[$i], $subname)) { $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev; } elseif ($exists) { $alternatives[$collectionName] += $threshold; } } } foreach ($collection as $item) { $lev = \levenshtein($name, $item); if ($lev <= \strlen($name) / 3 || \str_contains($item, $name)) { $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev; } } $alternatives = \array_filter($alternatives, fn($lev) => $lev < 2 * $threshold); \ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE); return \array_keys($alternatives); }
Finds alternative of $name among $collection, if nothing is found in $collection, try in $abbrevs. @return string[]
findAlternatives
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function setDefaultCommand(string $commandName, bool $isSingleCommand = \false) : static { $this->defaultCommand = \explode('|', \ltrim($commandName, '|'))[0]; if ($isSingleCommand) { // Ensure the command exist $this->find($commandName); $this->singleCommand = \true; } return $this; }
Sets the default Command name. @return $this
setDefaultCommand
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
private function extractAllNamespaces(string $name) : array { // -1 as third argument is needed to skip the command short name when exploding $parts = \explode(':', $name, -1); $namespaces = []; foreach ($parts as $part) { if (\count($namespaces)) { $namespaces[] = \end($namespaces) . ':' . $part; } else { $namespaces[] = $part; } } return $namespaces; }
Returns all namespaces of the command name. @return string[]
extractAllNamespaces
php
deptrac/deptrac
vendor/symfony/console/Application.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Application.php
MIT
public function clearLine() : static { $this->output->write("\x1b[2K"); return $this; }
Clears all the output from the current line. @return $this
clearLine
php
deptrac/deptrac
vendor/symfony/console/Cursor.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Cursor.php
MIT