Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PhpDumper.php

function PhpDumper::getDefinitionsFromArguments

2 calls to PhpDumper::getDefinitionsFromArguments()
PhpDumper::addInlineRequires in vendor/symfony/dependency-injection/Dumper/PhpDumper.php
PhpDumper::addService in vendor/symfony/dependency-injection/Dumper/PhpDumper.php

File

vendor/symfony/dependency-injection/Dumper/PhpDumper.php, line 1801

Class

PhpDumper
PhpDumper dumps a service container as a PHP class.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function getDefinitionsFromArguments(array $arguments, ?\SplObjectStorage $definitions = null, array &$calls = [], ?bool $byConstructor = null) : \SplObjectStorage {
    $definitions ??= new \SplObjectStorage();
    foreach ($arguments as $argument) {
        if (\is_array($argument)) {
            $this->getDefinitionsFromArguments($argument, $definitions, $calls, $byConstructor);
        }
        elseif ($argument instanceof Reference) {
            $id = (string) $argument;
            while ($this->container
                ->hasAlias($id)) {
                $id = (string) $this->container
                    ->getAlias($id);
            }
            if (!isset($calls[$id])) {
                $calls[$id] = [
                    0,
                    $argument->getInvalidBehavior(),
                    $byConstructor,
                ];
            }
            else {
                $calls[$id][1] = min($calls[$id][1], $argument->getInvalidBehavior());
            }
            ++$calls[$id][0];
        }
        elseif (!$argument instanceof Definition) {
            // no-op
        }
        elseif (isset($definitions[$argument])) {
            $definitions[$argument] = 1 + $definitions[$argument];
        }
        else {
            $definitions[$argument] = 1;
            $arguments = [
                $argument->getArguments(),
                $argument->getFactory(),
            ];
            $this->getDefinitionsFromArguments($arguments, $definitions, $calls, null === $byConstructor || $byConstructor);
            $arguments = [
                $argument->getProperties(),
                $argument->getMethodCalls(),
                $argument->getConfigurator(),
            ];
            $this->getDefinitionsFromArguments($arguments, $definitions, $calls, null !== $byConstructor && $byConstructor);
        }
    }
    return $definitions;
}
RSS feed
Powered by Drupal