for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Finite\Event;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* This class is here to provide a compatibility layer between symfony
* versions from 2.8 to ^5.0
*/
class StateMachineDispatcher
{
* @var EventDispatcherInterface
private $eventDispatcher;
public function __construct(EventDispatcherInterface $eventDispatcher = null)
$this->eventDispatcher = $eventDispatcher ?: new EventDispatcher;
}
public function dispatch($eventName, StateMachineEvent $event)
if (self::isUnder43()) {
return $this->eventDispatcher->dispatch($eventName, $event);
$event
object<Finite\Event\StateMachineEvent>
null|string
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
return $this->eventDispatcher->dispatch($event, $eventName);
object<Symfony\Contracts\EventDispatcher\object>
public function addListener($eventName, $listener, $priority = 0)
return $this->eventDispatcher->addListener($eventName, $listener, $priority);
private static function isUnder43()
static $result = null;
if (null === $result) {
$reflectionMethod = new \ReflectionMethod(EventDispatcherInterface::class, 'dispatch');
$reflectionParameters = $reflectionMethod->getParameters();
$result = count($reflectionParameters) >= 2 && 'event' === $reflectionParameters[1]->getName();
return $result;
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: