for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Error;
use Cake\Core\Configure;
use Cake\Error\ErrorHandler;
use Whoops\Handler\PrettyPageHandler;
use Whoops\Run;
class WhoopsErrorHandler extends ErrorHandler
{
/**
* The Whoops instance.
*
* @var \Whoops\Run
*/
protected $_whoops;
* Get the Whoops instance.
* @return \Whoops\Run The Whoops instance.
public function getWhoopsInstance()
if (empty($this->_whoops)) {
$this->_whoops = new Run();
}
return $this->_whoops;
* Display an error.
* Only when debug > 2 will a formatted error be displayed.
* @param array $error An array of error data.
* @param bool $debug Whether or not the app is in debug mode.
* @return void
protected function _displayError($error, $debug)
if ($debug) {
$whoops = $this->getWhoopsInstance();
$whoops->pushHandler(new PrettyPageHandler());
new \Whoops\Handler\PrettyPageHandler()
object<Whoops\Handler\PrettyPageHandler>
callable
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
$whoops->handleError($error['level'], $error['description'], $error['file'], $error['line']);
} else {
parent::_displayError($error, $debug);
* Displays an exception response body.
* @param \Exception $exception The exception to display
protected function _displayException($exception)
if (Configure::read('debug')) {
$whoops->handleException($exception);
$exception
object<Exception>
object<Throwable>
parent::_displayException($exception);
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: