dump example

$dumper = new MatcherDumper($connection$this->state, $this->logger, 'test_routes');

    $route = new Route('/test/{my}/path');
    $route->setOption('compiler_class', RouteCompiler::class);
    $collection = new RouteCollection();
    $collection->add('test_route', $route);

    $dumper->addRoutes($collection);

    $this->fixtures->createTables($connection);

    $dumper->dump(['provider' => 'test']);

    $record = $connection->select('test_routes', 'tr')
      ->fields('tr')
      ->condition('name', 'test_route')
      ->execute()
      ->fetchObject();

    $loaded_route = unserialize($record->route);

    $this->assertEquals('test_route', $record->name, 'Dumped route has correct name.');
    $this->assertEquals('/test/{my}/path', $record->path, 'Dumped route has correct pattern.');
    
'statusCode' => $statusCode,
            'logger' => DebugLoggerConfigurator::getDebugLogger($this->logger),
            'currentContent' => \is_string($this->outputBuffer) ? $this->outputBuffer : ($this->outputBuffer)(),
        ]);
    }

    private function dumpValue(Data $value): string
    {
        $dumper = new HtmlDumper();
        $dumper->setTheme('light');

        return $dumper->dump($value, true);
    }

    private function formatArgs(array $args): string
    {
        $result = [];
        foreach ($args as $key => $item) {
            if ('object' === $item[0]) {
                $formattedValue = sprintf('<em>object</em>(%s)', $this->abbrClass($item[1]));
            } elseif ('array' === $item[0]) {
                $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
            } elseif ('null' === $item[0]) {
                
public function getFunctions(): array
    {
        return [
            new TwigFunction('profiler_dump', $this->dumpData(...)['is_safe' => ['html'], 'needs_environment' => true]),
            new TwigFunction('profiler_dump_log', $this->dumpLog(...)['is_safe' => ['html'], 'needs_environment' => true]),
        ];
    }

    public function dumpData(Environment $env, Data $data, int $maxDepth = 0): string
    {
        $this->dumper->setCharset($env->getCharset());
        $this->dumper->dump($data, null, [
            'maxDepth' => $maxDepth,
        ]);

        $dump = stream_get_contents($this->output, -1, 0);
        rewind($this->output);
        ftruncate($this->output, 0);

        return str_replace("\n</pre", '</pre', rtrim($dump));
    }

    public function dumpLog(Environment $env, string $message, Data $context = null): string
    {
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\VarDumper;

class FunctionsTest extends TestCase
{
    public function testDumpWithoutArg()
    {
        $this->setupVarDumper();

        ob_start();
        $return = dump();
        ob_end_clean();

        $this->assertNull($return);
    }

    public function testDumpReturnsFirstArg()
    {
        $this->setupVarDumper();

        $var1 = 'a';

        
$this->outputStream = fopen('php://stdout', 'w');

                try {
                    return parent::supportsColors();
                } finally {
                    $this->outputStream = $outputStream;
                }
            }
        };

        return FlattenException::createFromThrowable($exception)
            ->setAsString($dumper->dump($cloner->cloneVar($exception), true));
    }
}
    // static defined ones.     $this->dispatcher->dispatch(new RouteBuildEvent($collection), RoutingEvents::DYNAMIC);

    // ALTER is the final step to alter all the existing routes. We cannot stop     // people from adding new routes here, but we define two separate steps to     // make it clear.     $this->dispatcher->dispatch(new RouteBuildEvent($collection), RoutingEvents::ALTER);

    $this->checkProvider->setChecks($collection);

    $this->dumper->addRoutes($collection);
    $this->dumper->dump();

    $this->lock->release('router_rebuild');
    $this->dispatcher->dispatch(new Event(), RoutingEvents::FINISHED);
    $this->building = FALSE;

    $this->rebuildNeeded = FALSE;

    return TRUE;
  }

  /** * {@inheritdoc} */
/** * Confirms that we can find routes with the exact incoming path. */
  public function testExactPathMatch() {
    $connection = Database::getConnection();
    $provider = new RouteProvider($connection$this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');

    $this->fixtures->createTables($connection);

    $dumper = new MatcherDumper($connection$this->state, $this->logger, 'test_routes');
    $dumper->addRoutes($this->fixtures->sampleRouteCollection());
    $dumper->dump();

    $path = '/path/one';

    $request = Request::create($path, 'GET');

    $routes = $provider->getRouteCollectionForRequest($request);

    foreach ($routes as $route) {
      $this->assertEquals($path$route->getPath(), 'Found path has correct pattern');
    }
  }

  
EOF;
        $this->assertSame($expected$dumper->dump($this->array, 4, 0));
        $this->assertSameData($this->array, $this->parser->parse($expected));
    }

    public function testSpecifications()
    {
        $files = $this->parser->parse(file_get_contents($this->path.'/index.yml'));
        foreach ($files as $file) {
            $yamls = file_get_contents($this->path.'/'.$file.'.yml');

            // split YAMLs documents             foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
                
class ManagerRegistryTest extends TestCase
{
    public static function setUpBeforeClass(): void
    {
        $container = new ContainerBuilder();

        $container->register('foo', \stdClass::class)->setPublic(true);
        $container->getDefinition('foo')->setLazy(true)->addTag('proxy', ['interface' => \stdClass::class]);
        $container->compile();

        $dumper = new PhpDumper($container);
        eval('?>'.$dumper->dump(['class' => 'LazyServiceDoctrineBridgeContainer']));
    }

    public function testResetService()
    {
        $container = new \LazyServiceDoctrineBridgeContainer();

        $registry = new TestManagerRegistry('name', []['defaultManager' => 'foo'], 'defaultConnection', 'defaultManager', 'proxyInterfaceName');
        $registry->setTestContainer($container);

        $foo = $container->get('foo');
        $foo->bar = 123;
        
return self::dumpNull($flags);
            case $value instanceof \DateTimeInterface:
                return $value->format(match (true) {
                    !$length = \strlen(rtrim($value->format('u'), '0')) => 'c',
                    $length < 4 => 'Y-m-d\TH:i:s.vP',
                    default => 'Y-m-d\TH:i:s.uP',
                });
            case $value instanceof \UnitEnum:
                return sprintf('!php/const %s::%s', $value::class$value->name);
            case \is_object($value):
                if ($value instanceof TaggedValue) {
                    return '!'.$value->getTag().' '.self::dump($value->getValue()$flags);
                }

                if (Yaml::DUMP_OBJECT & $flags) {
                    return '!php/object '.self::dump(serialize($value));
                }

                if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) {
                    return self::dumpHashArray($value$flags);
                }

                if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
                    
use Symfony\Component\VarDumper\VarDumper;

VarDumper::setHandler(function D$var, string $label = null) {
    $dumper = new DumpDataCollector();
    $cloner = new VarCloner();
    $handler = function D$var, string $label = null) use ($dumper$cloner) {
        $var = $cloner->cloneVar($var);
        if (null !== $label) {
            $var = $var->withContext(['label' => $label]);
        }

        $dumper->dump($var);
    };
    VarDumper::setHandler($handler);
    $handler($var$label);
});

$arrayObject = new \ArrayObject();
dump($arrayObject);
$arrayObject['X'] = 'A';
$arrayObject['Y'] = new \ArrayObject(['type' => 'object']);
$arrayObject['Y']['Z'] = 'B';

return $this->container->resolveEnvPlaceholders($this->addParameters()."\n".$this->addServices());
    }

    private function addService(string $id, Definition $definition): string
    {
        $code = " $id:\n";
        if ($class = $definition->getClass()) {
            if (str_starts_with($class, '\\')) {
                $class = substr($class, 1);
            }

            $code .= sprintf(" class: %s\n", $this->dumper->dump($class));
        }

        if (!$definition->isPrivate()) {
            $code .= sprintf(" public: %s\n", $definition->isPublic() ? 'true' : 'false');
        }

        $tagsCode = '';
        $tags = $definition->getTags();
        $tags['container.error'] = array_map(fn ($e) => ['message' => $e]$definition->getErrors());
        foreach ($tags as $name => $tags) {
            foreach ($tags as $attributes) {
                


        $cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'].'/url_matching_routes.php',
            function DConfigCacheInterface $cache) {
                $dumper = $this->getMatcherDumperInstance();
                if (method_exists($dumper, 'addExpressionLanguageProvider')) {
                    foreach ($this->expressionLanguageProviders as $provider) {
                        $dumper->addExpressionLanguageProvider($provider);
                    }
                }

                $cache->write($dumper->dump()$this->getRouteCollection()->getResources());
            }
        );

        return $this->matcher = new $this->options['matcher_class'](self::getCompiledRoutes($cache->getPath())$this->context);
    }

    /** * Gets the UrlGenerator instance associated with this Router. */
    public function getGenerator(): UrlGeneratorInterface
    {
        
if (!$dumper instanceof ServerDumper) {
            $dumper = new ContextualizedDumper($dumper[new SourceContextProvider()]);
        }

        self::$handler = function D$var, string $label = null) use ($cloner$dumper) {
            $var = $cloner->cloneVar($var);

            if (null !== $label) {
                $var = $var->withContext(['label' => $label]);
            }

            $dumper->dump($var);
        };
    }

    private static function getDefaultContextProviders(): array
    {
        $contextProviders = [];

        if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && class_exists(Request::class)) {
            $requestStack = new RequestStack();
            $requestStack->push(Request::createFromGlobals());
            $contextProviders['request'] = new RequestContextProvider($requestStack);
        }
      $this->dumper = new $this->dumperClass($this->containerBuilder->reveal());
    }

    /** * Tests that an empty container works properly. * * @covers ::dump * @covers ::getArray * @covers ::supportsMachineFormat */
    public function testDumpForEmptyContainer() {
      $serialized_definition = $this->dumper->dump();
      $this->assertEquals(serialize($this->containerDefinition)$serialized_definition);
    }

    /** * Tests that alias processing works properly. * * @covers ::getAliases * * @dataProvider getAliasesDataProvider */
    public function testGetAliases($aliases$definition_aliases) {
      
Home | Imprint | This part of the site doesn't use cookies.