src/Viserio/Bridge/Twig/Command/DebugCommand.php
public function handle(): int
    {
        $types = ['functions', 'filters', 'tests', 'globals'];

        if ($this->option('format') === 'json') {
            $data = [];

            foreach ($types as $type) {
                foreach ($this->environment->{'get' . \ucfirst($type)}() as $name => $entity) {
                    $data[$type][$name] = $this->getMetadata($type, $entity);
                }
            }

            $data['tests']        = \array_keys($data['tests']);
            $data['loader_paths'] = $this->getLoaderPaths($this->environment);

            $this->line(\json_encode($data));

            return 0;
        }

        $filter = $this->option('filter');

        foreach ($types as $index => $type) {
            $items = [];

            foreach ($this->environment->{'get' . \ucfirst($type)}() as $name => $entity) {
                if (! (bool) $filter || \mb_strpos($name, $filter) !== false) {
                    $items[$name] = $name . $this->getPrettyMetadata($type, $entity);
                }
            }

            if (\count($items) === 0) {
                continue;
            }

            $this->output->section(\ucfirst($type));

            \ksort($items);

            $this->output->listing($items);
        }

        $this->output->section('Configured Paths');
        $this->output->table(['Namespace', 'Paths'], $this->buildTableRows($this->getLoaderPaths($this->environment)));

        return 0;
    }
public function handle(): int
    {
        $types = ['functions', 'filters', 'tests', 'globals'];

        if ($this->option('format') === 'json') {
            $data = [];

            foreach ($types as $type) {
                foreach ($this->environment->{'get' . \ucfirst($type)}() as $name => $entity) {
                    $data[$type][$name] = $this->getMetadata($type, $entity);
                }
            }

            $data['tests']        = \array_keys($data['tests']);
            $data['loader_paths'] = $this->getLoaderPaths($this->environment);

            $this->line(\json_encode($data));

            return 0;
        }

        $filter = $this->option('filter');

        foreach ($types as $index => $type) {
            $items = [];

            foreach ($this->environment->{'get' . \ucfirst($type)}() as $name => $entity) {
                if (! (bool) $filter || \mb_strpos($name, $filter) !== false) {
                    $items[$name] = $name . $this->getPrettyMetadata($type, $entity);
                }
            }

            if (\count($items) === 0) {
                continue;
            }

            $this->output->section(\ucfirst($type));

            \ksort($items);

            $this->output->listing($items);
        }

        $this->output->section('Configured Paths');
        $this->output->table(['Namespace', 'Paths'], $this->buildTableRows($this->getLoaderPaths($this->environment)));

        return 0;
    }
{@inheritdoc}