Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ cache:
- $HOME/.composer/cache

php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4

matrix:
fast_finish: true
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
}
],
"require": {
"php": ">=7.0.8",
"symfony/event-dispatcher": "~2.8|~3.0|~4.0"
"symfony/event-dispatcher-contracts": "^1.0|^2.0"
},
"require-dev": {
"phpunit/phpunit": "~6.5"
"phpunit/phpunit": "~6.5",
"symfony/event-dispatcher": "^4.3|^5.0"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 6 additions & 6 deletions src/StateMachine/StateMachine.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Stagehand\FSM\Transition\ActionRunnerInterface;
use Stagehand\FSM\Transition\GuardEvaluatorInterface;
use Stagehand\FSM\Transition\TransitionInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
* @see http://en.wikipedia.org/wiki/Finite_state_machine
Expand Down Expand Up @@ -195,7 +195,7 @@ public function triggerEvent($eventId)
$event = $this->currentState->getTransitionEvent(array_shift($this->eventQueue));
if ($event !== null) {
if ($this->eventDispatcher !== null) {
$this->eventDispatcher->dispatch(StateMachineEvents::EVENT_PROCESS, new StateMachineEvent($this, $this->currentState, $event));
$this->eventDispatcher->dispatch(new StateMachineEvent($this, $this->currentState, $event), StateMachineEvents::EVENT_PROCESS);
}

$fromState = $this->currentState;
Expand All @@ -211,7 +211,7 @@ public function triggerEvent($eventId)
$doEvent = $this->currentState->getDoEvent();
if ($doEvent !== null) {
if ($this->eventDispatcher !== null) {
$this->eventDispatcher->dispatch(StateMachineEvents::EVENT_DO, new StateMachineEvent($this, $this->currentState, $doEvent));
$this->eventDispatcher->dispatch(new StateMachineEvent($this, $this->currentState, $doEvent), StateMachineEvents::EVENT_DO);
}

$this->runAction($this, $doEvent);
Expand Down Expand Up @@ -380,15 +380,15 @@ private function transition(TransitionInterface $transition)
$exitEvent = $transition->getFromState()->getExitEvent();
if ($exitEvent !== null) {
if ($this->eventDispatcher !== null) {
$this->eventDispatcher->dispatch(StateMachineEvents::EVENT_EXIT, new StateMachineEvent($this, $transition->getFromState(), $exitEvent));
$this->eventDispatcher->dispatch(new StateMachineEvent($this, $transition->getFromState(), $exitEvent), StateMachineEvents::EVENT_EXIT);
}

$this->runAction($this, $exitEvent);
}
}

if ($this->eventDispatcher !== null) {
$this->eventDispatcher->dispatch(StateMachineEvents::EVENT_TRANSITION, new StateMachineEvent($this, null, $transition->getEvent(), $transition));
$this->eventDispatcher->dispatch(new StateMachineEvent($this, null, $transition->getEvent(), $transition), StateMachineEvents::EVENT_TRANSITION);
}
$this->runAction($this, $transition->getEvent(), $transition);
$this->previousState = $transition->getFromState();
Expand All @@ -399,7 +399,7 @@ private function transition(TransitionInterface $transition)
$entryEvent = $toState->getEntryEvent();
if ($entryEvent !== null) {
if ($this->eventDispatcher !== null) {
$this->eventDispatcher->dispatch(StateMachineEvents::EVENT_ENTRY, new StateMachineEvent($this, $toState, $entryEvent));
$this->eventDispatcher->dispatch(new StateMachineEvent($this, $toState, $entryEvent), StateMachineEvents::EVENT_ENTRY);
}

$this->runAction($this, $entryEvent);
Expand Down
2 changes: 1 addition & 1 deletion src/StateMachine/StateMachineEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Stagehand\FSM\Event\EventInterface;
use Stagehand\FSM\State\StateInterface;
use Stagehand\FSM\Transition\TransitionInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

/**
* @since Class available since Release 2.1.0
Expand Down
2 changes: 1 addition & 1 deletion tests/StateMachine/StateMachineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Stagehand\FSM\Transition\GuardEvaluatorInterface;
use Stagehand\FSM\Transition\TransitionInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
* @since Class available since Release 0.1.0
Expand Down