getTextWithContext example

                return $this->dumpParameter($match[1]);
            } else {
                $replaceParameters = fn ($match) => "'.".$this->dumpParameter($match[2]).".'";

                $code = str_replace('%%', '%', preg_replace_callback('/(?<!%)(%)([^%]+)\1/', $replaceParameters$this->export($value)));

                return $code;
            }
        } elseif ($value instanceof \UnitEnum) {
            return sprintf('\%s::%s', $value::class$value->name);
        } elseif ($value instanceof AbstractArgument) {
            throw new RuntimeException($value->getTextWithContext());
        } elseif (\is_object($value) || \is_resource($value)) {
            throw new RuntimeException(sprintf('Unable to dump a service container if a parameter is an object or a resource, got "%s".', get_debug_type($value)));
        }

        return $this->export($value);
    }

    /** * Dumps a string to a literal (aka PHP Code) class value. * * @throws RuntimeException */
use Symfony\Component\VarExporter\ProxyHelper;

/** * Resolves named arguments to their corresponding numeric index. * * @author Kévin Dunglas <dunglas@gmail.com> */
class ResolveNamedArgumentsPass extends AbstractRecursivePass
{
    protected function processValue(mixed $value, bool $isRoot = false): mixed
    {
        if ($value instanceof AbstractArgument && $value->getText().'.' === $value->getTextWithContext()) {
            $value->setContext(sprintf('A value found in service "%s"', $this->currentId));
        }

        if (!$value instanceof Definition) {
            return parent::processValue($value$isRoot);
        }

        $calls = $value->getMethodCalls();
        $calls[] = ['__construct', $value->getArguments()];

        foreach ($calls as $i => $call) {
            [

            $value = new ServiceLocator($this->resolveServices(...)$refs$types);
        } elseif ($value instanceof Reference) {
            $value = $this->doGet((string) $value$value->getInvalidBehavior()$inlineServices$isConstructorArgument);
        } elseif ($value instanceof Definition) {
            $value = $this->createService($value$inlineServices$isConstructorArgument);
        } elseif ($value instanceof Parameter) {
            $value = $this->getParameter((string) $value);
        } elseif ($value instanceof Expression) {
            $value = $this->getExpressionLanguage()->evaluate($value['container' => $this]);
        } elseif ($value instanceof AbstractArgument) {
            throw new RuntimeException($value->getTextWithContext());
        }

        return $value;
    }

    /** * 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 */
/** * Resolves named arguments to their corresponding numeric index. * * @author Kévin Dunglas <dunglas@gmail.com> */
class ResolveNamedArgumentsPass extends AbstractRecursivePass
{
    protected bool $skipScalars = true;

    protected function processValue(mixed $value, bool $isRoot = false): mixed
    {
        if ($value instanceof AbstractArgument && $value->getText().'.' === $value->getTextWithContext()) {
            $value->setContext(sprintf('A value found in service "%s"', $this->currentId));
        }

        if (!$value instanceof Definition) {
            return parent::processValue($value$isRoot);
        }

        $calls = $value->getMethodCalls();
        $calls[] = ['__construct', $value->getArguments()];

        foreach ($calls as $i => $call) {
            [
                return $this->dumpParameter($match[1]);
            } else {
                $replaceParameters = fn ($match) => "'.".$this->dumpParameter($match[2]).".'";

                $code = str_replace('%%', '%', preg_replace_callback('/(?<!%)(%)([^%]+)\1/', $replaceParameters$this->export($value)));

                return $code;
            }
        } elseif ($value instanceof \UnitEnum) {
            return sprintf('\%s::%s', $value::class$value->name);
        } elseif ($value instanceof AbstractArgument) {
            throw new RuntimeException($value->getTextWithContext());
        } elseif (\is_object($value) || \is_resource($value)) {
            throw new RuntimeException(sprintf('Unable to dump a service container if a parameter is an object or a resource, got "%s".', get_debug_type($value)));
        }

        return $this->export($value);
    }

    /** * Dumps a string to a literal (aka PHP Code) class value. * * @throws RuntimeException */

            $value = new ServiceLocator($this->resolveServices(...)$refs$types);
        } elseif ($value instanceof Reference) {
            $value = $this->doGet((string) $value$value->getInvalidBehavior()$inlineServices$isConstructorArgument);
        } elseif ($value instanceof Definition) {
            $value = $this->createService($value$inlineServices$isConstructorArgument);
        } elseif ($value instanceof Parameter) {
            $value = $this->getParameter((string) $value);
        } elseif ($value instanceof Expression) {
            $value = $this->getExpressionLanguage()->evaluate($value['container' => $this]);
        } elseif ($value instanceof AbstractArgument) {
            throw new RuntimeException($value->getTextWithContext());
        }

        return $value;
    }

    /** * 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 */
Home | Imprint | This part of the site doesn't use cookies.