for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace Star\Component\State\Callbacks;
use Star\Component\State\InvalidStateTransitionException;
use Star\Component\State\StateMachine;
final class CallContextMethodOnFailure implements TransitionCallback
{
/**
* @var string
*/
private $to;
private $method;
* @var mixed[]
private $args;
* @param string $to
* @param string $method
* @param mixed[] $args
public function __construct(
string $to,
string $method,
array $args
) {
$this->to = $to;
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.
$this->method = $method;
$this->args = $args;
}
* @param mixed $context
* @param StateMachine $machine
public function beforeStateChange($context, StateMachine $machine): void
public function afterStateChange($context, StateMachine $machine): void
* @param InvalidStateTransitionException $exception
* @param mixed|object $context
*
* @return string
public function onFailure(InvalidStateTransitionException $exception, $context, StateMachine $machine): string
$closure = function (array $args) use ($context) {
$context->{$this->method}(...$args);
};
$closure($this->args);
return $this->to;
This check marks files that end in a newline character, i.e. an empy line.