parseDefaults example

if (!$service || !\is_array($service)) {
                    throw new InvalidArgumentException(sprintf('Type definition "%s" must be a non-empty array within "_instanceof" in "%s". Check your YAML syntax.', $id$file));
                }
                if (\is_string($service) && str_starts_with($service, '@')) {
                    throw new InvalidArgumentException(sprintf('Type definition "%s" cannot be an alias within "_instanceof" in "%s". Check your YAML syntax.', $id$file));
                }
                $this->parseDefinition($id$service$file[], false, $trackBindings);
            }
        }

        $this->isLoadingInstanceof = false;
        $defaults = $this->parseDefaults($content$file);
        foreach ($content['services'] as $id => $service) {
            $this->parseDefinition($id$service$file$defaults, false, $trackBindings);
        }
    }

    /** * @throws InvalidArgumentException */
    private function parseDefaults(array &$content, string $file): array
    {
        if (!\array_key_exists('_defaults', $content['services'])) {
            
if (!$service || !\is_array($service)) {
                    throw new InvalidArgumentException(sprintf('Type definition "%s" must be a non-empty array within "_instanceof" in "%s". Check your YAML syntax.', $id$file));
                }
                if (\is_string($service) && str_starts_with($service, '@')) {
                    throw new InvalidArgumentException(sprintf('Type definition "%s" cannot be an alias within "_instanceof" in "%s". Check your YAML syntax.', $id$file));
                }
                $this->parseDefinition($id$service$file[], false, $trackBindings);
            }
        }

        $this->isLoadingInstanceof = false;
        $defaults = $this->parseDefaults($content$file);
        foreach ($content['services'] as $id => $service) {
            $this->parseDefinition($id$service$file$defaults, false, $trackBindings);
        }
    }

    /** * @throws InvalidArgumentException */
    private function parseDefaults(array &$content, string $file): array
    {
        if (!\array_key_exists('_defaults', $content['services'])) {
            
throw new InvalidArgumentException(sprintf('The "services" key should contain an array in %s. Check your YAML syntax.', $file));
        }

        // Some extensions split up their dependencies into multiple files.         if (isset($content['_provider'])) {
            $provider = $content['_provider'];
        }
        else {
            $basename = basename($file);
            [$provider] = explode('.', $basename, 2);
        }
        $defaults = $this->parseDefaults($content$file);
        $defaults['tags'][] = [
            'name' => '_provider',
            'provider' => $provider
        ];
        foreach ($content['services'] as $id => $service) {
            $this->parseDefinition($id$service$file$defaults);
        }
    }

    /** * @param array $content * @param string $file * * @return array * * @throws InvalidArgumentException */
Home | Imprint | This part of the site doesn't use cookies.