[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/symfony/error-handler/ErrorRenderer/ -> CliErrorRenderer.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <[email protected]>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\ErrorHandler\ErrorRenderer;
  13  
  14  use Symfony\Component\ErrorHandler\Exception\FlattenException;
  15  use Symfony\Component\VarDumper\Cloner\VarCloner;
  16  use Symfony\Component\VarDumper\Dumper\CliDumper;
  17  
  18  // Help opcache.preload discover always-needed symbols
  19  class_exists(CliDumper::class);
  20  
  21  /**
  22   * @author Nicolas Grekas <[email protected]>
  23   */
  24  class CliErrorRenderer implements ErrorRendererInterface
  25  {
  26      /**
  27       * {@inheritdoc}
  28       */
  29      public function render(\Throwable $exception): FlattenException
  30      {
  31          $cloner = new VarCloner();
  32          $dumper = new class() extends CliDumper {
  33              protected function supportsColors(): bool
  34              {
  35                  $outputStream = $this->outputStream;
  36                  $this->outputStream = fopen('php://stdout', 'w');
  37  
  38                  try {
  39                      return parent::supportsColors();
  40                  } finally {
  41                      $this->outputStream = $outputStream;
  42                  }
  43              }
  44          };
  45  
  46          return FlattenException::createFromThrowable($exception)
  47              ->setAsString($dumper->dump($cloner->cloneVar($exception), true));
  48      }
  49  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer