for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Phossa Project
*
* PHP version 5.4
* @category Library
* @package Phossa2\Middleware
* @copyright Copyright (c) 2016 phossa.com
* @license http://mit-license.org/ MIT License
* @link http://www.phossa.com/
*/
/*# declare(strict_types=1); */
namespace Phossa2\Middleware\Middleware;
use Psr\Http\Message\RequestInterface;
use Phossa2\Shared\Base\ObjectAbstract;
use Psr\Http\Message\ResponseInterface;
use Franzl\Middleware\Whoops\WhoopsRunner;
use Phossa2\Middleware\Interfaces\DelegateInterface;
use Phossa2\Middleware\Interfaces\MiddlewareInterface;
* WhoopsMiddleware
* Using "franzl/whoops-middleware" for Whoops
* @author Hong Zhang <[email protected]>
* @version 2.1.0
* @since 2.1.0 added
class WhoopsMiddleware extends ObjectAbstract implements MiddlewareInterface
{
* Should be the very first middleware in the queue
* {@inheritDoc}
public function process(
RequestInterface $request,
ResponseInterface $response,
DelegateInterface $next = null
) {
try {
return $next->next($request, $response);
$next
null
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:
function someFunction(A $objectMaybe = null) { if ($objectMaybe instanceof A) { $objectMaybe->doSomething(); } }
} catch (\Exception $e) {
return WhoopsRunner::handle($e, $request);
}
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: