for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nip\Dispatcher\Resolver\Pipeline\Stages;
use Nip\Controllers\Controller;
use Nip\Dispatcher\Exceptions\InvalidCommandException;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
/**
* Class MethodCallStage
* @package Nip\Dispatcher\Resolver\Pipeline\Stages
*/
class MethodCallStage extends AbstractStage
{
* @return void
* @throws \Exception
public function processCommand()
if (!$this->hasInstanceAction()) {
throw new InvalidCommandException(
"No valid instance for callback in dispatcher command " .
"[" . print_r($this->getCommand(), true) . "]"
print_r($this->getCommand(), true)
string|true
concatenation
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
"[" . /** @scrutinizer ignore-type */ print_r($this->getCommand(), true) . "]"
);
}
$return = $this->callMethod();
$this->getCommand()->setReturn($return);
* @return ResponseInterface
protected function callMethod()
$command = $this->getCommand();
/** @var Controller $controllerInstance */
$controllerInstance = $this->getCommand()->getActionParam('instance');
if ($this->getCommand()->hasRequest()) {
$controllerInstance->setRequest($this->getCommand()->getRequest());
$method = $command->getActionParam('action');
$params = $command->hasActionParam('params') ? $command->getActionParam('params') : [];
return $controllerInstance->{$method}(...$params);