for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace AbterPhp\Framework\Debug\Exceptions\Handlers\Whoops;
use Opulence\Debug\Exceptions\Handlers\IExceptionHandler;
use Psr\Log\LoggerInterface;
use Throwable;
/**
* @SuppressWarnings(PHPMD)
*/
class ExceptionHandler implements IExceptionHandler
{
/** @var LoggerInterface */
protected $logger;
/** @var ExceptionRenderer */
protected $whoopsRenderer;
/** @var string|null */
protected $sapi;
* @param LoggerInterface $logger
* @param ExceptionRenderer $whoopsRenderer
* @param array $exceptionsSkipped
public function __construct(LoggerInterface $logger, ExceptionRenderer $whoopsRenderer, array $exceptionsSkipped)
$exceptionsSkipped
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function __construct(LoggerInterface $logger, ExceptionRenderer $whoopsRenderer, /** @scrutinizer ignore-unused */ array $exceptionsSkipped)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$this->logger = $logger;
$this->whoopsRenderer = $whoopsRenderer;
}
* @return string|null
public function getSapi(): ?string
if (null === $this->sapi) {
$this->sapi = PHP_SAPI;
return $this->sapi;
* @param string|null $sapi
*
* @return $this
public function setSapi(?string $sapi): ExceptionHandler
$this->sapi = $sapi;
return $this;
* Handles an exception
* @param Throwable $ex The exception to handle
public function handle($ex)
$this->whoopsRenderer->render($ex);
* Registers the handler with PHP
public function register()
$whoops = $this->whoopsRenderer->getRun();
$whoops->pushHandler(new \Whoops\Handler\PlainTextHandler($this->logger));
if ($this->getSapi() !== 'cli') {
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
$whoops->register();
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.