diff --git a/src/Contracts/Dispatchable.php b/src/Contracts/Dispatchable.php index c759488..45c4406 100644 --- a/src/Contracts/Dispatchable.php +++ b/src/Contracts/Dispatchable.php @@ -1,12 +1,17 @@ scenarioRepository->findHandlerScenarioFor($event); - $reaction = $this->scenarioRunner->run($scenario, $event); - - return $reaction; + return $this->scenarioRunner->run($scenario, $event); } } \ No newline at end of file diff --git a/src/Core/Event.php b/src/Core/Event.php index 0bc1f11..287708a 100644 --- a/src/Core/Event.php +++ b/src/Core/Event.php @@ -54,7 +54,7 @@ public function name($eventName) /** * @fluent * - * @param $eventName + * @param string $eventName * * @return \Keios\Apparatus\Contracts\Dispatchable $this */ @@ -94,6 +94,7 @@ public function expect(array $expectedReactions) /** * @return mixed + * @throws \Keios\Apparatus\Exceptions\NoHandlerScenarioFoundException */ public function getReaction() { @@ -102,7 +103,7 @@ public function getReaction() } /** - * @return mixed + * @return string|null */ public function getEventName() { diff --git a/src/Core/Scenario.php b/src/Core/Scenario.php index 1ff9714..f6fcef8 100644 --- a/src/Core/Scenario.php +++ b/src/Core/Scenario.php @@ -65,6 +65,8 @@ public function __construct() /** * @param \Keios\Apparatus\Core\Dispatcher $dispatcher + * + * @return mixed|void */ public function setDispatcher(Dispatcher $dispatcher) { @@ -73,6 +75,8 @@ public function setDispatcher(Dispatcher $dispatcher) /** * @param \Keios\Apparatus\Contracts\Dispatchable $event + * + * @return mixed|void */ public function inject(Dispatchable $event) { @@ -117,6 +121,9 @@ public function has($property) /** * @return mixed + * @throws \Keios\Apparatus\Exceptions\NoStepForEventFoundException + * @throws \Keios\Apparatus\Exceptions\NotInitializedException + * @throws \Keios\Apparatus\Exceptions\NoStepsDefinedException */ public function run() { @@ -143,9 +150,9 @@ public function run() } /** - * @param $eventName - * @param $data - * @param array $expectedReactions + * @param string $eventName + * @param $data + * @param array $expectedReactions * * @return mixed */ @@ -158,6 +165,9 @@ public function dispatch($eventName, $data, array $expectedReactions) /** * @param \Keios\Apparatus\Core\Step $step + * + * @throws \Keios\Apparatus\Exceptions\EventAlreadyRegisteredException + * @throws \Keios\Apparatus\Exceptions\StepAlreadyRegisteredException */ public function add(Step $step) { @@ -168,6 +178,9 @@ public function add(Step $step) /** * @param $stepName * @param \Keios\Apparatus\Core\Step $step + * + * @throws \Keios\Apparatus\Exceptions\NoStepWithNameFoundException + * @throws \Keios\Apparatus\Exceptions\EventAlreadyRegisteredException */ public function replace($stepName, Step $step) { @@ -177,6 +190,9 @@ public function replace($stepName, Step $step) /** * @param $stepName * @param \Keios\Apparatus\Core\Step $step + * + * @throws \Keios\Apparatus\Exceptions\EventAlreadyRegisteredException + * @throws \Keios\Apparatus\Exceptions\NoStepWithNameFoundException */ public function insertBefore($stepName, Step $step) { @@ -186,6 +202,9 @@ public function insertBefore($stepName, Step $step) /** * @param $stepName * @param \Keios\Apparatus\Core\Step $step + * + * @throws \Keios\Apparatus\Exceptions\EventAlreadyRegisteredException + * @throws \Keios\Apparatus\Exceptions\NoStepWithNameFoundException */ public function insertAfter($stepName, Step $step) { diff --git a/src/Core/ScenarioConfiguration.php b/src/Core/ScenarioConfiguration.php index 35f02a3..3d873b3 100644 --- a/src/Core/ScenarioConfiguration.php +++ b/src/Core/ScenarioConfiguration.php @@ -18,8 +18,8 @@ class ScenarioConfiguration implements LoaderInterface protected $registeredScenarios = []; /** - * @param $eventName - * @param $scenarioClassName + * @param string $eventName + * @param string $scenarioClassName * * @throws \Keios\Apparatus\Exceptions\InvalidScenarioException * @throws \Keios\Apparatus\Exceptions\ScenarioNotFoundException @@ -38,7 +38,7 @@ public function bind($eventName, $scenarioClassName) } /** - * @param $scenarioClassName + * @param string $scenarioClassName * * @throws \Keios\Apparatus\Exceptions\ScenarioNotFoundException */ @@ -52,7 +52,7 @@ protected function assertScenarioExists($scenarioClassName) } /** - * @param $scenarioClassName + * @param string $scenarioClassName * * @throws \Keios\Apparatus\Exceptions\InvalidScenarioException */ diff --git a/src/Core/ScenarioFactory.php b/src/Core/ScenarioFactory.php index 7ef16b2..b30b4ce 100644 --- a/src/Core/ScenarioFactory.php +++ b/src/Core/ScenarioFactory.php @@ -32,6 +32,7 @@ public function __construct(LoaderInterface $scenarioLoader) * @param \Keios\Apparatus\Contracts\Dispatchable $event * * @return mixed + * @throws \Keios\Apparatus\Exceptions\InvalidScenarioException * @throws \Keios\Apparatus\Exceptions\NoHandlerScenarioFoundException */ public function findHandlerScenarioFor(Dispatchable $event) @@ -44,7 +45,7 @@ public function findHandlerScenarioFor(Dispatchable $event) } /** - * @param $eventName + * @param string $eventName * * @return bool */ @@ -93,11 +94,9 @@ protected function make($eventName) protected function resolveClosure($closure) { $scenario = $closure(); - - if ($interfaces = class_implements($scenario)) { - if (in_array('Keios\Apparatus\Contracts\Runnable', $interfaces)) { + $interfaces = class_implements($scenario); + if ($interfaces && in_array('Keios\Apparatus\Contracts\Runnable', $interfaces, true)) { return is_object($scenario) ? $scenario : new $scenario(); - } } throw new InvalidScenarioException( @@ -106,7 +105,7 @@ protected function resolveClosure($closure) } /** - * @param $eventName + * @param string $eventName * * @throws \Keios\Apparatus\Exceptions\NoHandlerScenarioFoundException */ diff --git a/src/Core/ScenarioRepository.php b/src/Core/ScenarioRepository.php index 570bb93..fecb539 100644 --- a/src/Core/ScenarioRepository.php +++ b/src/Core/ScenarioRepository.php @@ -31,6 +31,8 @@ public function __construct(ScenarioFactory $scenarioFactory) * @param \Keios\Apparatus\Contracts\Dispatchable $event * * @return mixed + * @throws \Keios\Apparatus\Exceptions\InvalidScenarioException + * @throws \Keios\Apparatus\Exceptions\NoHandlerScenarioFoundException */ public function findHandlerScenarioFor(Dispatchable $event) { diff --git a/src/Core/ScenarioRunner.php b/src/Core/ScenarioRunner.php index 6b9514b..e65270d 100644 --- a/src/Core/ScenarioRunner.php +++ b/src/Core/ScenarioRunner.php @@ -11,7 +11,7 @@ class ScenarioRunner { /** - * @var + * @var Dispatcher */ protected $dispatcher; diff --git a/src/Core/ScenarioStepsList.php b/src/Core/ScenarioStepsList.php index 407e78c..66e270b 100644 --- a/src/Core/ScenarioStepsList.php +++ b/src/Core/ScenarioStepsList.php @@ -33,7 +33,7 @@ class ScenarioStepsList /** * @var null|Step */ - protected $currentStep = null; + protected $currentStep; /** * @var \Keios\Apparatus\Contracts\Runnable @@ -52,6 +52,7 @@ public function __construct(Runnable $scenario) * @param $eventName * * @throws \Keios\Apparatus\Exceptions\NoStepsDefinedException + * @throws \Keios\Apparatus\Exceptions\NoStepForEventFoundException */ public function initialize($eventName) { @@ -117,6 +118,7 @@ public function getPreviousStep() /** * @return bool + * @throws \Keios\Apparatus\Exceptions\NotInitializedException */ public function hasNextStep() { @@ -125,6 +127,7 @@ public function hasNextStep() /** * @return bool + * @throws \Keios\Apparatus\Exceptions\NotInitializedException */ public function hasPreviousStep() { @@ -132,7 +135,7 @@ public function hasPreviousStep() } /** - * + * @throws \Keios\Apparatus\Exceptions\NotInitializedException */ public function moveToNextStep() { @@ -141,7 +144,7 @@ public function moveToNextStep() } /** - * + * @throws \Keios\Apparatus\Exceptions\NotInitializedException */ public function moveToPreviousStep() { @@ -150,7 +153,7 @@ public function moveToPreviousStep() } /** - * @param $stepName + * @param string $stepName * * @throws \Keios\Apparatus\Exceptions\NoStepWithNameFoundException */ @@ -177,7 +180,7 @@ public function add(Step $step) } /** - * @param $stepName + * @param string $stepName * * @return bool */ @@ -187,7 +190,7 @@ public function hasStepNamed($stepName) } /** - * @param $eventName + * @param string $eventName * * @return mixed * @throws \Keios\Apparatus\Exceptions\NoStepForEventFoundException @@ -200,8 +203,11 @@ public function getStepForEvent($eventName) } /** - * @param $stepName + * @param string $stepName * @param \Keios\Apparatus\Core\Step $step + * + * @throws \Keios\Apparatus\Exceptions\EventAlreadyRegisteredException + * @throws \Keios\Apparatus\Exceptions\NoStepWithNameFoundException */ public function insertAfter($stepName, Step $step) { @@ -209,8 +215,11 @@ public function insertAfter($stepName, Step $step) } /** - * @param $stepName + * @param string $stepName * @param \Keios\Apparatus\Core\Step $step + * + * @throws \Keios\Apparatus\Exceptions\EventAlreadyRegisteredException + * @throws \Keios\Apparatus\Exceptions\NoStepWithNameFoundException */ public function insertBefore($stepName, Step $step) { @@ -218,10 +227,11 @@ public function insertBefore($stepName, Step $step) } /** - * @param $stepNameToReplace + * @param string $stepNameToReplace * @param \Keios\Apparatus\Core\Step $replacingStep * * @throws \Keios\Apparatus\Exceptions\NoStepWithNameFoundException + * @throws \Keios\Apparatus\Exceptions\EventAlreadyRegisteredException */ public function replace($stepNameToReplace, Step $replacingStep) { @@ -247,7 +257,7 @@ public function replace($stepNameToReplace, Step $replacingStep) } /** - * @param $stepName + * @param string $stepName * @param \Keios\Apparatus\Core\Step $step * @param bool $after * @@ -311,7 +321,7 @@ protected function assertUniqueEventBinding(array $eventNames) } /** - * @param $stepName + * @param string $stepName * * @throws \Keios\Apparatus\Exceptions\StepAlreadyRegisteredException */ @@ -325,7 +335,7 @@ protected function assertUniqueStepName($stepName) } /** - * @param $eventName + * @param string $eventName * * @throws \Keios\Apparatus\Exceptions\NoStepForEventFoundException */ @@ -359,7 +369,7 @@ protected function assertIsInitialized() } /** - * @param $stepName + * @param string $stepName * * @throws \Keios\Apparatus\Exceptions\NoStepWithNameFoundException */ diff --git a/src/Core/SideAction.php b/src/Core/SideAction.php index 10855d6..106420e 100644 --- a/src/Core/SideAction.php +++ b/src/Core/SideAction.php @@ -9,6 +9,12 @@ */ abstract class SideAction extends Action { + /** + * @param Runnable $scenario + * @param $result + * + * @return mixed|void + */ public function __invoke(Runnable $scenario, $result) { $this->scenario = $scenario; diff --git a/src/Core/Step.php b/src/Core/Step.php index 4313cdb..14a1045 100644 --- a/src/Core/Step.php +++ b/src/Core/Step.php @@ -15,7 +15,7 @@ class Step protected static $sideActionsCache = []; /** - * @var + * @var string */ protected $name; @@ -25,7 +25,7 @@ class Step protected $action; /** - * @var + * @var Runnable */ protected $scenario; @@ -40,7 +40,7 @@ class Step protected $sideActions = []; /** - * @param $name + * @param string $name * @param callable $action * @param array $triggeringEvents */ @@ -80,7 +80,7 @@ public function __invoke($lastStepResult) } /** - * @return mixed + * @return string|null */ public function getName() { @@ -97,7 +97,9 @@ public function getTriggeringEvents() /** * @fluent + * * @param callable $sideAction + * * @return Step */ public function with(callable $sideAction) @@ -107,9 +109,6 @@ public function with(callable $sideAction) return $this; } - /** - * - */ protected function importSideActions() { if (isset(static::$sideActionsCache[$this->name]) && is_array(static::$sideActionsCache[$this->name])) { @@ -143,7 +142,7 @@ protected function executeSideActions($result) } /** - * @param $stepName + * @param string $stepName * @param callable $sideAction */ public static function addSideAction($stepName, callable $sideAction)