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 __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = \false, ?OutputFormatterInterface $formatter = null) { $this->verbosity = $verbosity ?? self::VERBOSITY_NORMAL; $this->formatter = $formatter ?? new OutputFormatter(); $this->formatter->setDecorated($decorated); }
@param int|null $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) @param bool $decorated Whether to decorate messages @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
__construct
php
deptrac/deptrac
vendor/symfony/console/Output/Output.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/Output.php
MIT
public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, ?bool $decorated = null, ?OutputFormatterInterface $formatter = null) { if (!\is_resource($stream) || 'stream' !== \get_resource_type($stream)) { throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); } $this->stream = $stream; $decorated ??= $this->hasColorSupport(); parent::__construct($verbosity, $decorated, $formatter); }
@param resource $stream A stream resource @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) @param bool|null $decorated Whether to decorate messages (null for auto-guessing) @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) @throws InvalidArgumentException When first argument is not a real stream
__construct
php
deptrac/deptrac
vendor/symfony/console/Output/StreamOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/StreamOutput.php
MIT
public function getStream() { return $this->stream; }
Gets the stream attached to this StreamOutput instance. @return resource
getStream
php
deptrac/deptrac
vendor/symfony/console/Output/StreamOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/StreamOutput.php
MIT
protected function hasColorSupport() : bool { // Follow https://no-color.org/ if ('' !== (($_SERVER['NO_COLOR'] ?? \getenv('NO_COLOR'))[0] ?? '')) { return \false; } // Detect msysgit/mingw and assume this is a tty because detection // does not work correctly, see https://github.com/composer/composer/issues/9690 if (!@\stream_isatty($this->stream) && !\in_array(\strtoupper((string) \getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], \true)) { return \false; } if ('\\' === \DIRECTORY_SEPARATOR && @\sapi_windows_vt100_support($this->stream)) { return \true; } if ('Hyper' === \getenv('TERM_PROGRAM') || \false !== \getenv('COLORTERM') || \false !== \getenv('ANSICON') || 'ON' === \getenv('ConEmuANSI')) { return \true; } if ('dumb' === ($term = (string) \getenv('TERM'))) { return \false; } // See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157 return \preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term); }
Returns true if the stream supports colorization. Colorization is disabled if not supported by the stream: This is tricky on Windows, because Cygwin, Msys2 etc emulate pseudo terminals via named pipes, so we can only check the environment. Reference: Composer\XdebugHandler\Process::supportsColor https://github.com/composer/xdebug-handler @return bool true if the stream supports colorization, false otherwise
hasColorSupport
php
deptrac/deptrac
vendor/symfony/console/Output/StreamOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/StreamOutput.php
MIT
public function fetch() : string { $content = $this->buffer; $this->buffer = ''; return $content; }
Empties buffer and returns its content.
fetch
php
deptrac/deptrac
vendor/symfony/console/Output/TrimmedBufferOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/TrimmedBufferOutput.php
MIT
public function __construct(string $question, array $choices, string|bool|int|float|null $default = null) { if (!$choices) { throw new \LogicException('Choice question must have at least 1 choice available.'); } parent::__construct($question, $default); $this->choices = $choices; $this->setValidator($this->getDefaultValidator()); $this->setAutocompleterValues($choices); }
@param string $question The question to ask to the user @param array $choices The list of available choices @param string|bool|int|float|null $default The default answer to return
__construct
php
deptrac/deptrac
vendor/symfony/console/Question/ChoiceQuestion.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/ChoiceQuestion.php
MIT
public function setMultiselect(bool $multiselect) : static { $this->multiselect = $multiselect; $this->setValidator($this->getDefaultValidator()); return $this; }
Sets multiselect option. When multiselect is set to true, multiple choices can be answered. @return $this
setMultiselect
php
deptrac/deptrac
vendor/symfony/console/Question/ChoiceQuestion.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/ChoiceQuestion.php
MIT
public function isMultiselect() : bool { return $this->multiselect; }
Returns whether the choices are multiselect.
isMultiselect
php
deptrac/deptrac
vendor/symfony/console/Question/ChoiceQuestion.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/ChoiceQuestion.php
MIT
public function setPrompt(string $prompt) : static { $this->prompt = $prompt; return $this; }
Sets the prompt for choices. @return $this
setPrompt
php
deptrac/deptrac
vendor/symfony/console/Question/ChoiceQuestion.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/ChoiceQuestion.php
MIT
public function setErrorMessage(string $errorMessage) : static { $this->errorMessage = $errorMessage; $this->setValidator($this->getDefaultValidator()); return $this; }
Sets the error message for invalid values. The error message has a string placeholder (%s) for the invalid value. @return $this
setErrorMessage
php
deptrac/deptrac
vendor/symfony/console/Question/ChoiceQuestion.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/ChoiceQuestion.php
MIT
public function __construct(string $question, bool $default = \true, string $trueAnswerRegex = '/^y/i') { parent::__construct($question, $default); $this->trueAnswerRegex = $trueAnswerRegex; $this->setNormalizer($this->getDefaultNormalizer()); }
@param string $question The question to ask to the user @param bool $default The default answer to return, true or false @param string $trueAnswerRegex A regex to match the "yes" answer
__construct
php
deptrac/deptrac
vendor/symfony/console/Question/ConfirmationQuestion.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/ConfirmationQuestion.php
MIT
public function __construct(string $question, string|bool|int|float|null $default = null) { $this->question = $question; $this->default = $default; }
@param string $question The question to ask to the user @param string|bool|int|float|null $default The default answer to return if the user enters nothing
__construct
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function isMultiline() : bool { return $this->multiline; }
Returns whether the user response accepts newline characters.
isMultiline
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function setMultiline(bool $multiline) : static { $this->multiline = $multiline; return $this; }
Sets whether the user response should accept newline characters. @return $this
setMultiline
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function isHidden() : bool { return $this->hidden; }
Returns whether the user response must be hidden.
isHidden
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function setHidden(bool $hidden) : static { if ($this->autocompleterCallback) { throw new LogicException('A hidden question cannot use the autocompleter.'); } $this->hidden = $hidden; return $this; }
Sets whether the user response must be hidden or not. @return $this @throws LogicException In case the autocompleter is also used
setHidden
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function isHiddenFallback() : bool { return $this->hiddenFallback; }
In case the response cannot be hidden, whether to fallback on non-hidden question or not.
isHiddenFallback
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function setHiddenFallback(bool $fallback) : static { $this->hiddenFallback = $fallback; return $this; }
Sets whether to fallback on non-hidden question if the response cannot be hidden. @return $this
setHiddenFallback
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function setAutocompleterValues(?iterable $values) : static { if (\is_array($values)) { $values = $this->isAssoc($values) ? \array_merge(\array_keys($values), \array_values($values)) : \array_values($values); $callback = static fn() => $values; } elseif ($values instanceof \Traversable) { $callback = static function () use($values) { static $valueCache; return $valueCache ??= \iterator_to_array($values, \false); }; } else { $callback = null; } return $this->setAutocompleterCallback($callback); }
Sets values for the autocompleter. @return $this @throws LogicException
setAutocompleterValues
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function getAutocompleterCallback() : ?callable { return $this->autocompleterCallback; }
Gets the callback function used for the autocompleter.
getAutocompleterCallback
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function setAutocompleterCallback(?callable $callback = null) : static { if (1 > \func_num_args()) { \DEPTRAC_INTERNAL\trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); } if ($this->hidden && null !== $callback) { throw new LogicException('A hidden question cannot use the autocompleter.'); } $this->autocompleterCallback = null === $callback ? null : $callback(...); return $this; }
Sets the callback function used for the autocompleter. The callback is passed the user input as argument and should return an iterable of corresponding suggestions. @return $this
setAutocompleterCallback
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function setValidator(?callable $validator = null) : static { if (1 > \func_num_args()) { \DEPTRAC_INTERNAL\trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); } $this->validator = null === $validator ? null : $validator(...); return $this; }
Sets a validator for the question. @return $this
setValidator
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function getValidator() : ?callable { return $this->validator; }
Gets the validator for the question.
getValidator
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function setNormalizer(callable $normalizer) : static { $this->normalizer = $normalizer(...); return $this; }
Sets a normalizer for the response. The normalizer can be a callable (a string), a closure or a class implementing __invoke. @return $this
setNormalizer
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function getNormalizer() : ?callable { return $this->normalizer; }
Gets the normalizer for the response. The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
getNormalizer
php
deptrac/deptrac
vendor/symfony/console/Question/Question.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Question/Question.php
MIT
public function block(string|array $messages, ?string $type = null, ?string $style = null, string $prefix = ' ', bool $padding = \false, bool $escape = \true) { $messages = \is_array($messages) ? \array_values($messages) : [$messages]; $this->autoPrependBlock(); $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape)); $this->newLine(); }
Formats a message as a block of text. @return void
block
php
deptrac/deptrac
vendor/symfony/console/Style/SymfonyStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Style/SymfonyStyle.php
MIT
public function info(string|array $message) { $this->block($message, 'INFO', 'fg=green', ' ', \true); }
Formats an info message. @return void
info
php
deptrac/deptrac
vendor/symfony/console/Style/SymfonyStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Style/SymfonyStyle.php
MIT
public function definitionList(string|array|TableSeparator ...$list) { $headers = []; $row = []; foreach ($list as $value) { if ($value instanceof TableSeparator) { $headers[] = $value; $row[] = $value; continue; } if (\is_string($value)) { $headers[] = new TableCell($value, ['colspan' => 2]); $row[] = null; continue; } if (!\is_array($value)) { throw new InvalidArgumentException('Value should be an array, string, or an instance of TableSeparator.'); } $headers[] = \key($value); $row[] = \current($value); } $this->horizontalTable($headers, [$row]); }
Formats a list of key/value horizontally. Each row can be one of: * 'A title' * ['key' => 'value'] * new TableSeparator() @return void
definitionList
php
deptrac/deptrac
vendor/symfony/console/Style/SymfonyStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Style/SymfonyStyle.php
MIT
public function progressIterate(iterable $iterable, ?int $max = null) : iterable { yield from $this->createProgressBar()->iterate($iterable, $max); $this->newLine(2); }
@see ProgressBar::iterate() @template TKey @template TValue @param iterable<TKey, TValue> $iterable @param int|null $max Number of steps to complete the bar (0 if indeterminate), if null it will be inferred from $iterable @return iterable<TKey, TValue>
progressIterate
php
deptrac/deptrac
vendor/symfony/console/Style/SymfonyStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Style/SymfonyStyle.php
MIT
public function getErrorStyle() : self { return new self($this->input, $this->getErrorOutput()); }
Returns a new instance which makes use of stderr if available.
getErrorStyle
php
deptrac/deptrac
vendor/symfony/console/Style/SymfonyStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Style/SymfonyStyle.php
MIT
public function run(array $input, array $options = []) : int { $prevShellVerbosity = \getenv('SHELL_VERBOSITY'); try { $this->input = new ArrayInput($input); if (isset($options['interactive'])) { $this->input->setInteractive($options['interactive']); } if ($this->inputs) { $this->input->setStream(self::createStream($this->inputs)); } $this->initOutput($options); return $this->statusCode = $this->application->run($this->input, $this->output); } finally { // SHELL_VERBOSITY is set by Application::configureIO so we need to unset/reset it // to its previous value to avoid one test's verbosity to spread to the following tests if (\false === $prevShellVerbosity) { if (\function_exists('putenv')) { @\putenv('SHELL_VERBOSITY'); } unset($_ENV['SHELL_VERBOSITY']); unset($_SERVER['SHELL_VERBOSITY']); } else { if (\function_exists('putenv')) { @\putenv('SHELL_VERBOSITY=' . $prevShellVerbosity); } $_ENV['SHELL_VERBOSITY'] = $prevShellVerbosity; $_SERVER['SHELL_VERBOSITY'] = $prevShellVerbosity; } } }
Executes the application. Available options: * interactive: Sets the input interactive flag * decorated: Sets the output decorated flag * verbosity: Sets the output verbosity flag * capture_stderr_separately: Make output of stdOut and stdErr separately available @return int The command exit code
run
php
deptrac/deptrac
vendor/symfony/console/Tester/ApplicationTester.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Tester/ApplicationTester.php
MIT
public function complete(array $input) : array { $currentIndex = \count($input); if ('' === \end($input)) { \array_pop($input); } \array_unshift($input, $this->command->getName()); $completionInput = CompletionInput::fromTokens($input, $currentIndex); $completionInput->bind($this->command->getDefinition()); $suggestions = new CompletionSuggestions(); $this->command->complete($completionInput, $suggestions); $options = []; foreach ($suggestions->getOptionSuggestions() as $option) { $options[] = '--' . $option->getName(); } return \array_map('strval', \array_merge($options, $suggestions->getValueSuggestions())); }
Create completion suggestions from input tokens.
complete
php
deptrac/deptrac
vendor/symfony/console/Tester/CommandCompletionTester.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Tester/CommandCompletionTester.php
MIT
public function execute(array $input, array $options = []) : int { // set the command name automatically if the application requires // this argument and no command name was passed if (!isset($input['command']) && null !== ($application = $this->command->getApplication()) && $application->getDefinition()->hasArgument('command')) { $input = \array_merge(['command' => $this->command->getName()], $input); } $this->input = new ArrayInput($input); // Use an in-memory input stream even if no inputs are set so that QuestionHelper::ask() does not rely on the blocking STDIN. $this->input->setStream(self::createStream($this->inputs)); if (isset($options['interactive'])) { $this->input->setInteractive($options['interactive']); } if (!isset($options['decorated'])) { $options['decorated'] = \false; } $this->initOutput($options); return $this->statusCode = $this->command->run($this->input, $this->output); }
Executes the command. Available execution options: * interactive: Sets the input interactive flag * decorated: Sets the output decorated flag * verbosity: Sets the output verbosity flag * capture_stderr_separately: Make output of stdOut and stdErr separately available @param array $input An array of command arguments and options @param array $options An array of execution options @return int The command exit code
execute
php
deptrac/deptrac
vendor/symfony/console/Tester/CommandTester.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Tester/CommandTester.php
MIT
public function getDisplay(bool $normalize = \false) : string { if (!isset($this->output)) { throw new \RuntimeException('Output not initialized, did you execute the command before requesting the display?'); } \rewind($this->output->getStream()); $display = \stream_get_contents($this->output->getStream()); if ($normalize) { $display = \str_replace(\PHP_EOL, "\n", $display); } return $display; }
Gets the display returned by the last execution of the command or application. @throws \RuntimeException If it's called before the execute method
getDisplay
php
deptrac/deptrac
vendor/symfony/console/Tester/TesterTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Tester/TesterTrait.php
MIT
public function getErrorOutput(bool $normalize = \false) : string { if (!$this->captureStreamsIndependently) { throw new \LogicException('The error output is not available when the tester is run without "capture_stderr_separately" option set.'); } \rewind($this->output->getErrorOutput()->getStream()); $display = \stream_get_contents($this->output->getErrorOutput()->getStream()); if ($normalize) { $display = \str_replace(\PHP_EOL, "\n", $display); } return $display; }
Gets the output written to STDERR by the application. @param bool $normalize Whether to normalize end of lines to \n or not
getErrorOutput
php
deptrac/deptrac
vendor/symfony/console/Tester/TesterTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Tester/TesterTrait.php
MIT
public function getInput() : InputInterface { return $this->input; }
Gets the input instance used by the last execution of the command or application.
getInput
php
deptrac/deptrac
vendor/symfony/console/Tester/TesterTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Tester/TesterTrait.php
MIT
public function getOutput() : OutputInterface { return $this->output; }
Gets the output instance used by the last execution of the command or application.
getOutput
php
deptrac/deptrac
vendor/symfony/console/Tester/TesterTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Tester/TesterTrait.php
MIT
public function getStatusCode() : int { return $this->statusCode ?? throw new \RuntimeException('Status code not initialized, did you execute the command before requesting the status code?'); }
Gets the status code returned by the last execution of the command or application. @throws \RuntimeException If it's called before the execute method
getStatusCode
php
deptrac/deptrac
vendor/symfony/console/Tester/TesterTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Tester/TesterTrait.php
MIT
public function setInputs(array $inputs) : static { $this->inputs = $inputs; return $this; }
Sets the user inputs. @param array $inputs An array of strings representing each input passed to the command input stream @return $this
setInputs
php
deptrac/deptrac
vendor/symfony/console/Tester/TesterTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Tester/TesterTrait.php
MIT
private function initOutput(array $options) : void { $this->captureStreamsIndependently = $options['capture_stderr_separately'] ?? \false; if (!$this->captureStreamsIndependently) { $this->output = new StreamOutput(\fopen('php://memory', 'w', \false)); if (isset($options['decorated'])) { $this->output->setDecorated($options['decorated']); } if (isset($options['verbosity'])) { $this->output->setVerbosity($options['verbosity']); } } else { $this->output = new ConsoleOutput($options['verbosity'] ?? ConsoleOutput::VERBOSITY_NORMAL, $options['decorated'] ?? null); $errorOutput = new StreamOutput(\fopen('php://memory', 'w', \false)); $errorOutput->setFormatter($this->output->getFormatter()); $errorOutput->setVerbosity($this->output->getVerbosity()); $errorOutput->setDecorated($this->output->isDecorated()); $reflectedOutput = new \ReflectionObject($this->output); $strErrProperty = $reflectedOutput->getProperty('stderr'); $strErrProperty->setValue($this->output, $errorOutput); $reflectedParent = $reflectedOutput->getParentClass(); $streamProperty = $reflectedParent->getProperty('stream'); $streamProperty->setValue($this->output, \fopen('php://memory', 'w', \false)); } }
Initializes the output property. Available options: * decorated: Sets the output decorated flag * verbosity: Sets the output verbosity flag * capture_stderr_separately: Make output of stdOut and stdErr separately available
initOutput
php
deptrac/deptrac
vendor/symfony/console/Tester/TesterTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Tester/TesterTrait.php
MIT
public function isPublic() : bool { return $this->public; }
Checks if this DI Alias should be public or not.
isPublic
php
deptrac/deptrac
vendor/symfony/dependency-injection/Alias.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Alias.php
MIT
public function setPublic(bool $boolean) : static { $this->public = $boolean; return $this; }
Sets if this Alias is public. @return $this
setPublic
php
deptrac/deptrac
vendor/symfony/dependency-injection/Alias.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Alias.php
MIT
public function setDeprecated(string $package, string $version, string $message) : static { if ('' !== $message) { if (\preg_match('#[\\r\\n]|\\*/#', $message)) { throw new InvalidArgumentException('Invalid characters found in deprecation template.'); } if (!\str_contains($message, '%alias_id%')) { throw new InvalidArgumentException('The deprecation template must contain the "%alias_id%" placeholder.'); } } $this->deprecation = ['package' => $package, 'version' => $version, 'message' => $message ?: self::DEFAULT_DEPRECATION_TEMPLATE]; return $this; }
Whether this alias is deprecated, that means it should not be referenced anymore. @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 $this @throws InvalidArgumentException when the message template is invalid
setDeprecated
php
deptrac/deptrac
vendor/symfony/dependency-injection/Alias.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Alias.php
MIT
public function getDeprecation(string $id) : array { return ['package' => $this->deprecation['package'], 'version' => $this->deprecation['version'], 'message' => \str_replace('%alias_id%', $id, $this->deprecation['message'])]; }
@param string $id Service id relying on this definition
getDeprecation
php
deptrac/deptrac
vendor/symfony/dependency-injection/Alias.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Alias.php
MIT
public function __construct(string $parent) { $this->parent = $parent; }
@param string $parent The id of Definition instance to decorate
__construct
php
deptrac/deptrac
vendor/symfony/dependency-injection/ChildDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ChildDefinition.php
MIT
public function getParent() : string { return $this->parent; }
Returns the Definition to inherit from.
getParent
php
deptrac/deptrac
vendor/symfony/dependency-injection/ChildDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ChildDefinition.php
MIT
public function setParent(string $parent) : static { $this->parent = $parent; return $this; }
Sets the Definition to inherit from. @return $this
setParent
php
deptrac/deptrac
vendor/symfony/dependency-injection/ChildDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ChildDefinition.php
MIT
public function getArgument(int|string $index) : mixed { if (\array_key_exists('index_' . $index, $this->arguments)) { return $this->arguments['index_' . $index]; } return parent::getArgument($index); }
Gets an argument to pass to the service constructor/factory method. If replaceArgument() has been used to replace an argument, this method will return the replacement value. @throws OutOfBoundsException When the argument does not exist
getArgument
php
deptrac/deptrac
vendor/symfony/dependency-injection/ChildDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ChildDefinition.php
MIT
public function replaceArgument(int|string $index, mixed $value) : static { if (\is_int($index)) { $this->arguments['index_' . $index] = $value; } elseif (\str_starts_with($index, '$')) { $this->arguments[$index] = $value; } else { throw new InvalidArgumentException('The argument must be an existing index or the name of a constructor\'s parameter.'); } return $this; }
You should always use this method when overwriting existing arguments of the parent definition. If you directly call setArguments() keep in mind that you must follow certain conventions when you want to overwrite the arguments of the parent definition, otherwise your arguments will only be appended. @return $this @throws InvalidArgumentException when $index isn't an integer
replaceArgument
php
deptrac/deptrac
vendor/symfony/dependency-injection/ChildDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ChildDefinition.php
MIT
public function compile() { $this->parameterBag->resolve(); $this->parameterBag = new FrozenParameterBag($this->parameterBag->all(), $this->parameterBag instanceof ParameterBag ? $this->parameterBag->allDeprecated() : []); $this->compiled = \true; }
Compiles the container. This method does two things: * Parameter values are resolved; * The parameter bag is frozen. @return void
compile
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
public function isCompiled() : bool { return $this->compiled; }
Returns true if the container is compiled.
isCompiled
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
public function getParameterBag() : ParameterBagInterface { return $this->parameterBag; }
Gets the service container parameter bag.
getParameterBag
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
public function getParameter(string $name) { return $this->parameterBag->get($name); }
Gets a parameter. @return array|bool|string|int|float|\UnitEnum|null @throws ParameterNotFoundException if the parameter is not defined
getParameter
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
public function set(string $id, ?object $service) { // Runs the internal initializer; used by the dumped container to include always-needed files if (isset($this->privates['service_container']) && $this->privates['service_container'] instanceof \Closure) { $initialize = $this->privates['service_container']; unset($this->privates['service_container']); $initialize($this); } if ('service_container' === $id) { throw new InvalidArgumentException('You cannot set service "service_container".'); } if (!(isset($this->fileMap[$id]) || isset($this->methodMap[$id]))) { if (isset($this->syntheticIds[$id]) || !isset($this->getRemovedIds()[$id])) { // no-op } elseif (null === $service) { throw new InvalidArgumentException(\sprintf('The "%s" service is private, you cannot unset it.', $id)); } else { throw new InvalidArgumentException(\sprintf('The "%s" service is private, you cannot replace it.', $id)); } } elseif (isset($this->services[$id])) { throw new InvalidArgumentException(\sprintf('The "%s" service is already initialized, you cannot replace it.', $id)); } if (isset($this->aliases[$id])) { unset($this->aliases[$id]); } if (null === $service) { unset($this->services[$id]); return; } $this->services[$id] = $service; }
Sets a service. Setting a synthetic service to null resets it: has() returns false and get() behaves in the same way as if the service was never created. @return void
set
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) : ?object { return $this->services[$id] ?? $this->services[$id = $this->aliases[$id] ?? $id] ?? ('service_container' === $id ? $this : ($this->factories[$id] ?? (self::$make ??= self::make(...)))($this, $id, $invalidBehavior)); }
Gets a service. @throws ServiceCircularReferenceException When a circular reference is detected @throws ServiceNotFoundException When the service is not defined @see Reference
get
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
private static function make(self $container, string $id, int $invalidBehavior) : ?object { if (isset($container->loading[$id])) { throw new ServiceCircularReferenceException($id, \array_merge(\array_keys($container->loading), [$id])); } $container->loading[$id] = \true; try { if (isset($container->fileMap[$id])) { return 4 === $invalidBehavior ? null : $container->load($container->fileMap[$id]); } elseif (isset($container->methodMap[$id])) { return 4 === $invalidBehavior ? null : $container->{$container->methodMap[$id]}($container); } } catch (\Exception $e) { unset($container->services[$id]); throw $e; } finally { unset($container->loading[$id]); } if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) { if (!$id) { throw new ServiceNotFoundException($id); } if (isset($container->syntheticIds[$id])) { throw new ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service is synthetic, it needs to be set at boot time before it can be used.', $id)); } if (isset($container->getRemovedIds()[$id])) { throw new ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.', $id)); } $alternatives = []; foreach ($container->getServiceIds() as $knownId) { if ('' === $knownId || '.' === $knownId[0]) { continue; } $lev = \levenshtein($id, $knownId); if ($lev <= \strlen($id) / 3 || \str_contains($knownId, $id)) { $alternatives[] = $knownId; } } throw new ServiceNotFoundException($id, null, null, $alternatives); } return null; }
Creates a service. As a separate method to allow "get()" to use the really fast `??` operator.
make
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
public function initialized(string $id) : bool { if (isset($this->aliases[$id])) { $id = $this->aliases[$id]; } if ('service_container' === $id) { return \false; } return isset($this->services[$id]); }
Returns true if the given service has actually been initialized.
initialized
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
public function getServiceIds() : array { return \array_map('strval', \array_unique(\array_merge(['service_container'], \array_keys($this->fileMap), \array_keys($this->methodMap), \array_keys($this->aliases), \array_keys($this->services)))); }
Gets all service ids. @return string[]
getServiceIds
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
public function getRemovedIds() : array { return []; }
Gets service ids that existed at compile time.
getRemovedIds
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
protected function load(string $file) { return require $file; }
Creates a service by requiring its factory file. @return mixed
load
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
protected function getEnv(string $name) : mixed { if (isset($this->resolving[$envName = "env({$name})"])) { throw new ParameterCircularReferenceException(\array_keys($this->resolving)); } if (isset($this->envCache[$name]) || \array_key_exists($name, $this->envCache)) { return $this->envCache[$name]; } if (!$this->has($id = 'container.env_var_processors_locator')) { $this->set($id, new ServiceLocator([])); } $this->getEnv ??= $this->getEnv(...); $processors = $this->get($id); if (\false !== ($i = \strpos($name, ':'))) { $prefix = \substr($name, 0, $i); $localName = \substr($name, 1 + $i); } else { $prefix = 'string'; $localName = $name; } $processor = $processors->has($prefix) ? $processors->get($prefix) : new EnvVarProcessor($this); if (\false === $i) { $prefix = ''; } $this->resolving[$envName] = \true; try { return $this->envCache[$name] = $processor->getEnv($prefix, $localName, $this->getEnv); } finally { unset($this->resolving[$envName]); } }
Fetches a variable from the environment. @throws EnvNotFoundException When the environment variable is not found and has no default value
getEnv
php
deptrac/deptrac
vendor/symfony/dependency-injection/Container.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Container.php
MIT
public function setResourceTracking(bool $track) { $this->trackResources = $track; }
Sets the track resources flag. If you are not using the loaders and therefore don't want to depend on the Config component, set this flag to false. @return void
setResourceTracking
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function setProxyInstantiator(InstantiatorInterface $proxyInstantiator) { $this->proxyInstantiator = $proxyInstantiator; }
Sets the instantiator to be used when fetching proxies. @return void
setProxyInstantiator
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function getExtension(string $name) : ExtensionInterface { if (isset($this->extensions[$name])) { return $this->extensions[$name]; } if (isset($this->extensionsByNs[$name])) { return $this->extensionsByNs[$name]; } throw new LogicException(\sprintf('Container extension "%s" is not registered.', $name)); }
Returns an extension by alias or namespace. @throws LogicException if the extension is not registered
getExtension
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function getExtensions() : array { return $this->extensions; }
Returns all registered extensions. @return array<string, ExtensionInterface>
getExtensions
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function hasExtension(string $name) : bool { return isset($this->extensions[$name]) || isset($this->extensionsByNs[$name]); }
Checks if we have an extension.
hasExtension
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function getResources() : array { return \array_values($this->resources); }
Returns an array of resources loaded to build this configuration. @return ResourceInterface[]
getResources
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function setResources(array $resources) : static { if (!$this->trackResources) { return $this; } $this->resources = $resources; return $this; }
Sets the resources for this configuration. @param array<string, ResourceInterface> $resources @return $this
setResources
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function addObjectResource(object|string $object) : static { if ($this->trackResources) { if (\is_object($object)) { $object = $object::class; } if (!isset($this->classReflectors[$object])) { $this->classReflectors[$object] = new \ReflectionClass($object); } $class = $this->classReflectors[$object]; foreach ($class->getInterfaceNames() as $name) { if (null === ($interface =& $this->classReflectors[$name])) { $interface = new \ReflectionClass($name); } $file = $interface->getFileName(); if (\false !== $file && \file_exists($file)) { $this->fileExists($file); } } do { $file = $class->getFileName(); if (\false !== $file && \file_exists($file)) { $this->fileExists($file); } foreach ($class->getTraitNames() as $name) { $this->addObjectResource($name); } } while ($class = $class->getParentClass()); } return $this; }
Adds the object class hierarchy as resources. @param object|string $object An object instance or class name @return $this
addObjectResource
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function getReflectionClass(?string $class, bool $throw = \true) : ?\ReflectionClass { if (!($class = $this->getParameterBag()->resolveValue($class))) { return null; } if (isset(self::INTERNAL_TYPES[$class])) { return null; } $resource = $classReflector = null; try { if (isset($this->classReflectors[$class])) { $classReflector = $this->classReflectors[$class]; } elseif (\class_exists(ClassExistenceResource::class)) { $resource = new ClassExistenceResource($class, \false); $classReflector = $resource->isFresh(0) ? \false : new \ReflectionClass($class); } else { $classReflector = \class_exists($class) || \interface_exists($class, \false) ? new \ReflectionClass($class) : \false; } } catch (\ReflectionException $e) { if ($throw) { throw $e; } } if ($this->trackResources) { if (!$classReflector) { $this->addResource($resource ?? new ClassExistenceResource($class, \false)); } elseif (!$classReflector->isInternal()) { $path = $classReflector->getFileName(); if (!$this->inVendors($path)) { $this->addResource(new ReflectionClassResource($classReflector, $this->vendors)); } } $this->classReflectors[$class] = $classReflector; } return $classReflector ?: null; }
Retrieves the requested reflection class and registers it for resource tracking. @throws \ReflectionException when a parent class/interface/trait is not found and $throw is true @final
getReflectionClass
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function fileExists(string $path, bool|string $trackContents = \true) : bool { $exists = \file_exists($path); if (!$this->trackResources || $this->inVendors($path)) { return $exists; } if (!$exists) { $this->addResource(new FileExistenceResource($path)); return $exists; } if (\is_dir($path)) { if ($trackContents) { $this->addResource(new DirectoryResource($path, \is_string($trackContents) ? $trackContents : null)); } else { $this->addResource(new GlobResource($path, '/*', \false)); } } elseif ($trackContents) { $this->addResource(new FileResource($path)); } return $exists; }
Checks whether the requested file or directory exists and registers the result for resource tracking. @param string $path The file or directory path for which to check the existence @param bool|string $trackContents Whether to track contents of the given resource. If a string is passed, it will be used as pattern for tracking contents of the requested directory @final
fileExists
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function loadFromExtension(string $extension, ?array $values = null) : static { if ($this->isCompiled()) { throw new BadMethodCallException('Cannot load from an extension on a compiled container.'); } $namespace = $this->getExtension($extension)->getAlias(); $this->extensionConfigs[$namespace][] = $values ?? []; return $this; }
Loads the configuration for an extension. @param string $extension The extension alias or namespace @param array<string, mixed>|null $values An array of values that customizes the extension @return $this @throws BadMethodCallException When this ContainerBuilder is compiled @throws \LogicException if the extension is not registered
loadFromExtension
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) : static { $this->getCompiler()->addPass($pass, $type, $priority); $this->addObjectResource($pass); return $this; }
Adds a compiler pass. @param string $type The type of compiler pass @param int $priority Used to sort the passes @return $this
addCompilerPass
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function getCompilerPassConfig() : PassConfig { return $this->getCompiler()->getPassConfig(); }
Returns the compiler pass config which can then be modified.
getCompilerPassConfig
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function set(string $id, ?object $service) { if ($this->isCompiled() && (isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic())) { // setting a synthetic service on a compiled container is alright throw new BadMethodCallException(\sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id)); } unset($this->definitions[$id], $this->aliasDefinitions[$id], $this->removedIds[$id]); parent::set($id, $service); }
Sets a service. @return void @throws BadMethodCallException When this ContainerBuilder is compiled
set
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function get(string $id, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) : ?object { if ($this->isCompiled() && isset($this->removedIds[$id])) { return ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $invalidBehavior ? parent::get($id) : null; } return $this->doGet($id, $invalidBehavior); }
@throws InvalidArgumentException when no definitions are available @throws ServiceCircularReferenceException When a circular reference is detected @throws ServiceNotFoundException When the service is not defined @throws \Exception @see Reference
get
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function merge(self $container) { if ($this->isCompiled()) { throw new BadMethodCallException('Cannot merge on a compiled container.'); } foreach ($container->getDefinitions() as $id => $definition) { if (!$definition->hasTag('container.excluded') || !$this->has($id)) { $this->setDefinition($id, $definition); } } $this->addAliases($container->getAliases()); $parameterBag = $this->getParameterBag(); $otherBag = $container->getParameterBag(); $parameterBag->add($otherBag->all()); if ($parameterBag instanceof ParameterBag && $otherBag instanceof ParameterBag) { foreach ($otherBag->allDeprecated() as $name => $deprecated) { $parameterBag->deprecate($name, ...$deprecated); } } if ($this->trackResources) { foreach ($container->getResources() as $resource) { $this->addResource($resource); } } foreach ($this->extensions as $name => $extension) { if (!isset($this->extensionConfigs[$name])) { $this->extensionConfigs[$name] = []; } $this->extensionConfigs[$name] = \array_merge($this->extensionConfigs[$name], $container->getExtensionConfig($name)); } if ($parameterBag instanceof EnvPlaceholderParameterBag && $otherBag instanceof EnvPlaceholderParameterBag) { $envPlaceholders = $otherBag->getEnvPlaceholders(); $parameterBag->mergeEnvPlaceholders($otherBag); } else { $envPlaceholders = []; } foreach ($container->envCounters as $env => $count) { if (!$count && !isset($envPlaceholders[$env])) { continue; } if (!isset($this->envCounters[$env])) { $this->envCounters[$env] = $count; } else { $this->envCounters[$env] += $count; } } foreach ($container->getAutoconfiguredInstanceof() as $interface => $childDefinition) { if (isset($this->autoconfiguredInstanceof[$interface])) { throw new InvalidArgumentException(\sprintf('"%s" has already been autoconfigured and merge() does not support merging autoconfiguration for the same class/interface.', $interface)); } $this->autoconfiguredInstanceof[$interface] = $childDefinition; } foreach ($container->getAutoconfiguredAttributes() as $attribute => $configurator) { if (isset($this->autoconfiguredAttributes[$attribute])) { throw new InvalidArgumentException(\sprintf('"%s" has already been autoconfigured and merge() does not support merging autoconfiguration for the same attribute.', $attribute)); } $this->autoconfiguredAttributes[$attribute] = $configurator; } }
Merges a ContainerBuilder with the current ContainerBuilder configuration. Service definitions overrides the current defined ones. But for parameters, they are overridden by the current ones. It allows the parameters passed to the container constructor to have precedence over the loaded ones. $container = new ContainerBuilder(new ParameterBag(['foo' => 'bar'])); $loader = new LoaderXXX($container); $loader->load('resource_name'); $container->register('foo', 'stdClass'); In the above example, even if the loaded resource defines a foo parameter, the value will still be 'bar' as defined in the ContainerBuilder constructor. @return void @throws BadMethodCallException When this ContainerBuilder is compiled
merge
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function getExtensionConfig(string $name) : array { if (!isset($this->extensionConfigs[$name])) { $this->extensionConfigs[$name] = []; } return $this->extensionConfigs[$name]; }
Returns the configuration array for the given extension. @return array<array<string, mixed>>
getExtensionConfig
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function prependExtensionConfig(string $name, array $config) { if (!isset($this->extensionConfigs[$name])) { $this->extensionConfigs[$name] = []; } \array_unshift($this->extensionConfigs[$name], $config); }
Prepends a config array to the configs of the given extension. @param array<string, mixed> $config @return void
prependExtensionConfig
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function deprecateParameter(string $name, string $package, string $version, string $message = 'The parameter "%s" is deprecated.') : void { if (!$this->parameterBag instanceof ParameterBag) { throw new BadMethodCallException(\sprintf('The parameter bag must be an instance of "%s" to call "%s".', ParameterBag::class, __METHOD__)); } $this->parameterBag->deprecate($name, $package, $version, $message); }
Deprecates a service container parameter. @throws ParameterNotFoundException if the parameter is not defined
deprecateParameter
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function compile(bool $resolveEnvPlaceholders = \false) { $compiler = $this->getCompiler(); if ($this->trackResources) { foreach ($compiler->getPassConfig()->getPasses() as $pass) { $this->addObjectResource($pass); } } $bag = $this->getParameterBag(); if ($resolveEnvPlaceholders && $bag instanceof EnvPlaceholderParameterBag) { $compiler->addPass(new ResolveEnvPlaceholdersPass(), PassConfig::TYPE_AFTER_REMOVING, -1000); } $compiler->compile($this); foreach ($this->definitions as $id => $definition) { if ($this->trackResources && $definition->isLazy()) { $this->getReflectionClass($definition->getClass()); } } $this->extensionConfigs = []; if ($bag instanceof EnvPlaceholderParameterBag) { if ($resolveEnvPlaceholders) { $this->parameterBag = new ParameterBag($this->resolveEnvPlaceholders($bag->all(), \true)); } $this->envPlaceholders = $bag->getEnvPlaceholders(); } parent::compile(); foreach ($this->definitions + $this->aliasDefinitions as $id => $definition) { if (!$definition->isPublic() || $definition->isPrivate()) { $this->removedIds[$id] = \true; } } }
Compiles the container. This method passes the container to compiler passes whose job is to manipulate and optimize the container. The main compiler passes roughly do four things: * The extension configurations are merged; * Parameter values are resolved; * The parameter bag is frozen; * Extension loading is disabled. @param bool $resolveEnvPlaceholders Whether %env()% parameters should be resolved using the current env vars or be replaced by uniquely identifiable placeholders. Set to "true" when you want to use the current ContainerBuilder directly, keep to "false" when the container is dumped instead. @return void
compile
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function getRemovedIds() : array { return $this->removedIds; }
Gets removed service or alias ids. @return array<string, bool>
getRemovedIds
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function addAliases(array $aliases) { foreach ($aliases as $alias => $id) { $this->setAlias($alias, $id); } }
Adds the service aliases. @param array<string, string|Alias> $aliases @return void
addAliases
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function setAliases(array $aliases) { $this->aliasDefinitions = []; $this->addAliases($aliases); }
Sets the service aliases. @param array<string, string|Alias> $aliases @return void
setAliases
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function setAlias(string $alias, string|Alias $id) : Alias { if ('' === $alias || '\\' === $alias[-1] || \strlen($alias) !== \strcspn($alias, "\x00\r\n'")) { throw new InvalidArgumentException(\sprintf('Invalid alias id: "%s".', $alias)); } if (\is_string($id)) { $id = new Alias($id); } if ($alias === (string) $id) { throw new InvalidArgumentException(\sprintf('An alias cannot reference itself, got a circular reference on "%s".', $alias)); } unset($this->definitions[$alias], $this->removedIds[$alias]); return $this->aliasDefinitions[$alias] = $id; }
Sets an alias for an existing service. @throws InvalidArgumentException if the id is not a string or an Alias @throws InvalidArgumentException if the alias is for itself
setAlias
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function getAlias(string $id) : Alias { if (!isset($this->aliasDefinitions[$id])) { throw new InvalidArgumentException(\sprintf('The service alias "%s" does not exist.', $id)); } return $this->aliasDefinitions[$id]; }
@throws InvalidArgumentException if the alias does not exist
getAlias
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function register(string $id, ?string $class = null) : Definition { return $this->setDefinition($id, new Definition($class)); }
Registers a service definition. This methods allows for simple registration of service definition with a fluid interface.
register
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function autowire(string $id, ?string $class = null) : Definition { return $this->setDefinition($id, (new Definition($class))->setAutowired(\true)); }
Registers an autowired service definition. This method implements a shortcut for using setDefinition() with an autowired definition.
autowire
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function addDefinitions(array $definitions) { foreach ($definitions as $id => $definition) { $this->setDefinition($id, $definition); } }
Adds the service definitions. @param array<string, Definition> $definitions @return void
addDefinitions
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function setDefinitions(array $definitions) { $this->definitions = []; $this->addDefinitions($definitions); }
Sets the service definitions. @param array<string, Definition> $definitions @return void
setDefinitions
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function getDefinitions() : array { return $this->definitions; }
Gets all service definitions. @return array<string, Definition>
getDefinitions
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function setDefinition(string $id, Definition $definition) : Definition { if ($this->isCompiled()) { throw new BadMethodCallException('Adding definition to a compiled container is not allowed.'); } if ('' === $id || '\\' === $id[-1] || \strlen($id) !== \strcspn($id, "\x00\r\n'")) { throw new InvalidArgumentException(\sprintf('Invalid service id: "%s".', $id)); } unset($this->aliasDefinitions[$id], $this->removedIds[$id]); return $this->definitions[$id] = $definition; }
Sets a service definition. @throws BadMethodCallException When this ContainerBuilder is compiled
setDefinition
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function hasDefinition(string $id) : bool { return isset($this->definitions[$id]); }
Returns true if a service definition exists under the given identifier.
hasDefinition
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function getDefinition(string $id) : Definition { if (!isset($this->definitions[$id])) { throw new ServiceNotFoundException($id); } return $this->definitions[$id]; }
Gets a service definition. @throws ServiceNotFoundException if the service definition does not exist
getDefinition
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function findDefinition(string $id) : Definition { $seen = []; while (isset($this->aliasDefinitions[$id])) { $id = (string) $this->aliasDefinitions[$id]; if (isset($seen[$id])) { $seen = \array_values($seen); $seen = \array_slice($seen, \array_search($id, $seen)); $seen[] = $id; throw new ServiceCircularReferenceException($id, $seen); } $seen[$id] = $id; } return $this->getDefinition($id); }
Gets a service definition by id or alias. The method "unaliases" recursively to return a Definition instance. @throws ServiceNotFoundException if the service definition does not exist
findDefinition
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
private function createService(Definition $definition, array &$inlineServices, bool $isConstructorArgument = \false, ?string $id = null, bool|object $tryProxy = \true) : mixed { if (null === $id && isset($inlineServices[$h = \spl_object_hash($definition)])) { return $inlineServices[$h]; } if ($definition instanceof ChildDefinition) { throw new RuntimeException(\sprintf('Constructing service "%s" from a parent definition is not supported at build time.', $id)); } if ($definition->isSynthetic()) { throw new RuntimeException(\sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id)); } if ($definition->isDeprecated()) { $deprecation = $definition->getDeprecation($id); \DEPTRAC_INTERNAL\trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']); } $parameterBag = $this->getParameterBag(); $class = $parameterBag->resolveValue($definition->getClass()) ?: (['Closure', 'fromCallable'] === $definition->getFactory() ? 'Closure' : null); if (['Closure', 'fromCallable'] === $definition->getFactory() && ('Closure' !== $class || $definition->isLazy())) { $callable = $parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArgument(0))); if ($callable instanceof Reference || $callable instanceof Definition) { $callable = [$callable, '__invoke']; } if (\is_array($callable) && ($callable[0] instanceof Reference || $callable[0] instanceof Definition && !isset($inlineServices[\spl_object_hash($callable[0])]))) { $initializer = function () use($callable, &$inlineServices) { return $this->doResolveServices($callable[0], $inlineServices); }; $proxy = eval('return ' . LazyClosure::getCode('$initializer', $callable, $definition, $this, $id) . ';'); $this->shareService($definition, $proxy, $id, $inlineServices); return $proxy; } } if (\true === $tryProxy && $definition->isLazy() && ['Closure', 'fromCallable'] !== $definition->getFactory() && !($tryProxy = !($proxy = $this->proxyInstantiator ??= new LazyServiceInstantiator()) || $proxy instanceof RealServiceInstantiator)) { $proxy = $proxy->instantiateProxy($this, (clone $definition)->setClass($class)->setTags(($definition->hasTag('proxy') ? ['proxy' => $parameterBag->resolveValue($definition->getTag('proxy'))] : []) + $definition->getTags()), $id, function ($proxy = \false) use($definition, &$inlineServices, $id) { return $this->createService($definition, $inlineServices, \true, $id, $proxy); }); $this->shareService($definition, $proxy, $id, $inlineServices); return $proxy; } if (null !== $definition->getFile()) { require_once $parameterBag->resolveValue($definition->getFile()); } $arguments = $definition->getArguments(); if (null !== ($factory = $definition->getFactory())) { if (\is_array($factory)) { $factory = [$this->doResolveServices($parameterBag->resolveValue($factory[0]), $inlineServices, $isConstructorArgument), $factory[1]]; } elseif (!\is_string($factory)) { throw new RuntimeException(\sprintf('Cannot create service "%s" because of invalid factory.', $id)); } elseif (\str_starts_with($factory, '@=')) { $factory = fn(ServiceLocator $arguments) => $this->getExpressionLanguage()->evaluate(\substr($factory, 2), ['container' => $this, 'args' => $arguments]); $arguments = [new ServiceLocatorArgument($arguments)]; } } $arguments = $this->doResolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($arguments)), $inlineServices, $isConstructorArgument); if (null !== $id && $definition->isShared() && (isset($this->services[$id]) || isset($this->privates[$id])) && (\true === $tryProxy || !$definition->isLazy())) { return $this->services[$id] ?? $this->privates[$id]; } if (!\array_is_list($arguments)) { $arguments = \array_combine(\array_map(fn($k) => \preg_replace('/^.*\\$/', '', $k), \array_keys($arguments)), $arguments); } if (null !== $factory) { $service = $factory(...$arguments); if (!$definition->isDeprecated() && \is_array($factory) && \is_string($factory[0])) { $r = new \ReflectionClass($factory[0]); if (0 < \strpos($r->getDocComment(), "\n * @deprecated ")) { \DEPTRAC_INTERNAL\trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" factory class. It should either be deprecated or its factory upgraded.', $id, $r->name); } } } else { $r = new \ReflectionClass($class); if (\is_object($tryProxy)) { if ($r->getConstructor()) { $tryProxy->__construct(...$arguments); } $service = $tryProxy; } else { $service = $r->getConstructor() ? $r->newInstanceArgs($arguments) : $r->newInstance(); } if (!$definition->isDeprecated() && 0 < \strpos($r->getDocComment(), "\n * @deprecated ")) { \DEPTRAC_INTERNAL\trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name); } } $lastWitherIndex = null; foreach ($definition->getMethodCalls() as $k => $call) { if ($call[2] ?? \false) { $lastWitherIndex = $k; } } if (null === $lastWitherIndex && (\true === $tryProxy || !$definition->isLazy())) { // share only if proxying failed, or if not a proxy, and if no withers are found $this->shareService($definition, $service, $id, $inlineServices); } $properties = $this->doResolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getProperties())), $inlineServices); foreach ($properties as $name => $value) { $service->{$name} = $value; } foreach ($definition->getMethodCalls() as $k => $call) { $service = $this->callMethod($service, $call, $inlineServices); if ($lastWitherIndex === $k && (\true === $tryProxy || !$definition->isLazy())) { // share only if proxying failed, or if not a proxy, and this is the last wither $this->shareService($definition, $service, $id, $inlineServices); } } if ($callable = $definition->getConfigurator()) { if (\is_array($callable)) { $callable[0] = $parameterBag->resolveValue($callable[0]); if ($callable[0] instanceof Reference) { $callable[0] = $this->doGet((string) $callable[0], $callable[0]->getInvalidBehavior(), $inlineServices); } elseif ($callable[0] instanceof Definition) { $callable[0] = $this->createService($callable[0], $inlineServices); } } if (!\is_callable($callable)) { throw new InvalidArgumentException(\sprintf('The configure callable for class "%s" is not a callable.', \get_debug_type($service))); } $callable($service); } return $service; }
Creates a service for a service definition. @throws RuntimeException When the factory definition is incomplete @throws RuntimeException When the service is a synthetic service @throws InvalidArgumentException When configure callable is not callable
createService
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function resolveServices(mixed $value) : mixed { return $this->doResolveServices($value); }
Replaces service references by the real service instance and evaluates expressions. @return mixed The same value with all service references replaced by the real service instances and all expressions evaluated
resolveServices
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function findTaggedServiceIds(string $name, bool $throwOnAbstract = \false) : array { $this->usedTags[] = $name; $tags = []; foreach ($this->getDefinitions() as $id => $definition) { if ($definition->hasTag($name) && !$definition->hasTag('container.excluded')) { if ($throwOnAbstract && $definition->isAbstract()) { throw new InvalidArgumentException(\sprintf('The service "%s" tagged "%s" must not be abstract.', $id, $name)); } $tags[$id] = $definition->getTag($name); } } return $tags; }
Returns service ids for a given tag. Example: $container->register('foo')->addTag('my.tag', ['hello' => 'world']); $serviceIds = $container->findTaggedServiceIds('my.tag'); foreach ($serviceIds as $serviceId => $tags) { foreach ($tags as $tag) { echo $tag['hello']; } } @return array<string, array> An array of tags with the tagged service as key, holding a list of attribute arrays
findTaggedServiceIds
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function findTags() : array { $tags = []; foreach ($this->getDefinitions() as $id => $definition) { $tags[] = \array_keys($definition->getTags()); } return \array_unique(\array_merge([], ...$tags)); }
Returns all tags the defined services use. @return string[]
findTags
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT
public function findUnusedTags() : array { return \array_values(\array_diff($this->findTags(), $this->usedTags)); }
Returns all tags not queried by findTaggedServiceIds. @return string[]
findUnusedTags
php
deptrac/deptrac
vendor/symfony/dependency-injection/ContainerBuilder.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
MIT