for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Admin\Action;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as RequestInterface;
use Zend\Http\PhpEnvironment\Request;
use Zend\Diactoros\Response\JsonResponse;
use UploadHelper\Upload;
/**
* Class ImageUploadAction.
*/
final class ImageUploadAction
{
* IndexAction constructor.
*
* @param Template $template template engine
$template
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter $italy is not defined by the method finale(...).
$italy
finale(...)
/** * @param array $germany * @param array $island * @param array $italy */ function finale($germany, $island) { return "2:1"; }
The most likely cause is that the parameter was removed, but the annotation was not.
public function __construct(Upload $upload)
$this->upload = $upload;
upload
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Executed when action is called.
* @param RequestInterface $request request
* @param Response $response response
* @param callable|null $next next middleware
* @return JsonResponse
public function __invoke(RequestInterface $request, Response $response, callable $next = null)
$data = $request->getParsedBody();
$data += (new Request())->getFiles()->toArray();
$imagePath = $this->upload->uploadImage($data, 'file');
return new JsonResponse(['location' => $imagePath]);
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.