for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Equip;
use Psr\Http\Message\ServerRequestInterface;
use Equip\Adr\InputInterface;
class Input implements InputInterface
{
/**
* Flatten all input from the request
*
* @param ServerRequestInterface $request
* @return array
*/
public function __invoke(
ServerRequestInterface $request
) {
$attrs = $request->getAttributes();
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
$a = "a"; $ab = "ab"; $abc = "abc";
will produce issues in the first and second line, while this second example
will produce no issues.
$body = $request->getParsedBody();
$cookies = $request->getCookieParams();
$query = $request->getQueryParams();
$uploads = $request->getUploadedFiles();
if (empty($body)) {
$body = [];
} elseif (is_object($body)) {
// Because the parsed body may also be represented as an object,
// additional parsing is required. This is a bit dirty but works
// very well for anonymous objects.
$body = json_decode(json_encode($body), true);
}
// Order matters here! Important values go last!
return array_replace(
$query,
$body,
$uploads,
$cookies,
$attrs
);
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.