1 | <?php |
||
21 | final class Statemachine implements EventfulStatemachine |
||
22 | { |
||
23 | /** |
||
24 | * The emitter used to emit events |
||
25 | * |
||
26 | * @var Emitter |
||
27 | */ |
||
28 | private $emitter; |
||
29 | |||
30 | /** |
||
31 | * Transition table used to determine which states support which actions |
||
32 | * |
||
33 | * @var TransitionTable |
||
34 | */ |
||
35 | private $stateTransitionTable; |
||
36 | |||
37 | /** |
||
38 | * Constructor |
||
39 | * |
||
40 | * @param TransitionTable $stateTransitionTable |
||
41 | * @param Listener $failureHandler (Optional) Listener that handles transition failures |
||
42 | * @param Listener $stateChanger (Optional) Listener that updates the object's state |
||
43 | */ |
||
44 | 8 | public function __construct( |
|
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | 8 | public function trigger(Input $input, Stateful $object) |
|
78 | |||
79 | /** |
||
80 | * {@inheritdoc} |
||
81 | */ |
||
82 | 1 | public function after(Input $input, State $currentState, Listener $listener, int $priority = Emitter::P_NORMAL) |
|
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | 3 | public function before(Input $input, State $currentState, Listener $listener, int $priority = Emitter::P_NORMAL) |
|
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | 1 | public function on(Input $input, State $currentState, Listener $listener, int $priority = Emitter::P_NORMAL) |
|
114 | |||
115 | /** |
||
116 | * Creates an event name based on an input, current state, and when that event should be emitted |
||
117 | * |
||
118 | * @param string $executedWhen |
||
119 | * @param Input $input |
||
120 | * @param State $currentState |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | 8 | private function getEventName(string $executedWhen, Input $input, State $currentState) : string |
|
128 | |||
129 | /** |
||
130 | * Emits the events corresponding to applying the provided input on the provided object. |
||
131 | * |
||
132 | * @param Input $input |
||
133 | * @param Stateful $object |
||
134 | * @param Context $context |
||
135 | * @param State $nextState |
||
136 | * |
||
137 | * @return void |
||
138 | * |
||
139 | * @throws StateTransitionFailed |
||
140 | */ |
||
141 | 7 | private function emitEvents(Input $input, Stateful $object, Context $context, State $nextState) |
|
156 | |||
157 | /** |
||
158 | * Returns events to be emitted whenever a state transition is attempted |
||
159 | * |
||
160 | * @param Input $input |
||
161 | * @param State $currentState |
||
162 | * |
||
163 | * @return Generator |
||
164 | */ |
||
165 | 7 | private function eventProvider(Input $input, State $currentState) : Generator |
|
182 | } |
||
183 |
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: