formatArgs example

<div class="trace-line-header break-long-words <?= $trace['file'] ? 'sf-toggle' : ''; ?>" data-toggle-selector="#trace-html-<?= $prefix; ?>-<?= $i; ?>" data-toggle-initial="<?= 'expanded' === $style ? 'display' : ''; ?>"> <?php if ($trace['file']) { ?> <span class="icon icon-close"><?= $this->include('assets/images/icon-minus-square.svg'); ?></span> <span class="icon icon-open"><?= $this->include('assets/images/icon-plus-square.svg'); ?></span> <?php } ?> <?php if ('compact' !== $style && $trace['function']) { ?> <span class="trace-class"><?= $this->abbrClass($trace['class']); ?></span><?php if ($trace['type']) { ?><span class="trace-type"><?= $trace['type']; ?></span><?php } ?><span class="trace-method"><?= $trace['function']; ?></span><?php if (isset($trace['args'])) { ?><span class="trace-arguments">(<?= $this->formatArgs($trace['args']); ?>)</span><?php } ?> <?php } ?> <?php if ($trace['file']) { ?> <?php         $lineNumber = $trace['line'] ?: 1;
        $fileLink = $this->getFileLink($trace['file']$lineNumber);
        $filePath = strtr(strip_tags($this->formatFile($trace['file']$lineNumber))[' at line '.$lineNumber => '']);
        $filePathParts = explode(\DIRECTORY_SEPARATOR, $filePath);
        ?> <span class="block trace-file-path"> in <a href="
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]) {
                $formattedValue = '<em>null</em>';
            } elseif ('boolean' === $item[0]) {
                $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
            } elseif ('resource' === $item[0]) {
                $formattedValue = '<em>resource</em>';
            } else {
                $formattedValue = str_replace("\n", '', $this->escape(var_export($item[1], true)));
            }

            $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escape($key)$formattedValue);
        }
<div class="trace-line-header break-long-words <?= $trace['file'] ? 'sf-toggle' : ''; ?>" data-toggle-selector="#trace-html-<?= $prefix; ?>-<?= $i; ?>" data-toggle-initial="<?= 'expanded' === $style ? 'display' : ''; ?>"> <?php if ($trace['file']) { ?> <span class="icon icon-close"><?= $this->include('assets/images/icon-minus-square.svg'); ?></span> <span class="icon icon-open"><?= $this->include('assets/images/icon-plus-square.svg'); ?></span> <?php } ?> <?php if ('compact' !== $style && $trace['function']) { ?> <span class="trace-class"><?= $this->abbrClass($trace['class']); ?></span><?php if ($trace['type']) { ?><span class="trace-type"><?= $trace['type']; ?></span><?php } ?><span class="trace-method"><?= $trace['function']; ?></span><?php if (isset($trace['args'])) { ?><span class="trace-arguments">(<?= $this->formatArgs($trace['args']); ?>)</span><?php } ?> <?php } ?> <?php if ($trace['file']) { ?> <?php         $lineNumber = $trace['line'] ?: 1;
        $fileLink = $this->getFileLink($trace['file']$lineNumber);
        $filePath = strtr(strip_tags($this->formatFile($trace['file']$lineNumber))[' at line '.$lineNumber => '']);
        $filePathParts = explode(\DIRECTORY_SEPARATOR, $filePath);
        ?> <span class="block trace-file-path"> in <a href="

        $this->fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
        $this->projectDir = str_replace('\\', '/', $projectDir).'/';
        $this->charset = $charset;
    }

    public function getFilters(): array
    {
        return [
            new TwigFilter('abbr_class', $this->abbrClass(...)['is_safe' => ['html']]),
            new TwigFilter('abbr_method', $this->abbrMethod(...)['is_safe' => ['html']]),
            new TwigFilter('format_args', $this->formatArgs(...)['is_safe' => ['html']]),
            new TwigFilter('format_args_as_text', $this->formatArgsAsText(...)),
            new TwigFilter('file_excerpt', $this->fileExcerpt(...)['is_safe' => ['html']]),
            new TwigFilter('format_file', $this->formatFile(...)['is_safe' => ['html']]),
            new TwigFilter('format_file_from_text', $this->formatFileFromText(...)['is_safe' => ['html']]),
            new TwigFilter('format_log_message', $this->formatLogMessage(...)['is_safe' => ['html']]),
            new TwigFilter('file_link', $this->getFileLink(...)),
            new TwigFilter('file_relative', $this->getFileRelative(...)),
        ];
    }

    public function abbrClass(string $class): string
    {
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]) {
                $formattedValue = '<em>null</em>';
            } elseif ('boolean' === $item[0]) {
                $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
            } elseif ('resource' === $item[0]) {
                $formattedValue = '<em>resource</em>';
            } else {
                $formattedValue = str_replace("\n", '', $this->escape(var_export($item[1], true)));
            }

            $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escape($key)$formattedValue);
        }
Home | Imprint | This part of the site doesn't use cookies.