for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Controller;
use DateTime;
use Swagger;
use Zend\Diactoros\Response;
/**
* @SWG\Swagger(
* schemes={"https"},
* host="awesome.scot",
* basePath="/",
* @SWG\Info(
* version="1.0.0",
* title="BONE MVC API",
* description="This be a swashbucklin' API."
* ),
* @SWG\ExternalDocumentation(
* description="By delboy1978uk",
* url="https://github.com/delboy1978uk"
* )
*
*/
class IndexController extends BaseController
{
public function indexAction()
$this->enableLayout();
$this->enableView();
}
* Check basic connectivity. Returns a timestamp.
* @SWG\Get(
* path="/ping",
* tags={"status"},
* @SWG\Response(response="200", description="Sends a response with the time")
public function pingAction()
$date = new DateTime();
$this->sendJsonResponse(['pong' => $date->format('Y-m-d H:i:s')]);
* @return Response
public function apiAction()
$swagger = Swagger\scan(APPLICATION_PATH.'/src')->__toString();
scan
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
$swagger = /** @scrutinizer ignore-call */ Swagger\scan(APPLICATION_PATH.'/src')->__toString();
$response = new Response();
$response = $response->withHeader('Content-Type', 'application/json');
$response->getBody()->write($swagger);
return $response;
public function fakeClientCallbackAction()
$request = $this->getRequest();
die(var_dump($request));
var_dump($request)
null
This check looks for function or method calls that always return null and whose return value is used.
class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {
The method getObject() can return nothing but null, so it makes no sense to use the return value.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
exit
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.
public function emailAction()
$reg = $this->getViewEngine()->render('emails/user_registration');
echo $reg; exit;