Skip to content

Commit

Permalink
Symfony: make it easier to autowire
Browse files Browse the repository at this point in the history
  • Loading branch information
glaubinix committed Sep 15, 2021
1 parent 4d66c3d commit 379b1f2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Log/QuestLogListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class QuestLogListener implements EventSubscriberInterface
/** @var QuestLoggerInterface[] */
private $questLogger;

public function __construct(array $questLogger)
public function __construct(iterable $questLogger)
{
$this->questLogger = $questLogger;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Progress/ProgressHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
use LittleCubicleGames\Quests\Storage\QuestStorageInterface;
use LittleCubicleGames\Quests\Workflow\QuestDefinitionInterface;
use Symfony\Component\Workflow\Workflow;
use Symfony\Component\Workflow\WorkflowInterface;

class ProgressHandler
{
/** @var Workflow */
/** @var WorkflowInterface */
private $worfkflow;
/** @var QuestStorageInterface */
private $questStorage;

public function __construct(Workflow $worfkflow, QuestStorageInterface $questStorage)
public function __construct(WorkflowInterface $questsStateMachine, QuestStorageInterface $questStorage)
{
$this->worfkflow = $worfkflow;
$this->worfkflow = $questsStateMachine;
$this->questStorage = $questStorage;
}

Expand Down
5 changes: 3 additions & 2 deletions src/QuestAdvancer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use LittleCubicleGames\Quests\Storage\QuestStorageInterface;
use LittleCubicleGames\Quests\Workflow\QuestDefinitionInterface;
use Symfony\Component\Workflow\Workflow;
use Symfony\Component\Workflow\WorkflowInterface;

class QuestAdvancer
{
Expand All @@ -14,10 +15,10 @@ class QuestAdvancer
/** @var Workflow */
private $questWorkflow;

public function __construct(QuestStorageInterface $questStorage, Workflow $questWorkflow)
public function __construct(QuestStorageInterface $questStorage, WorkflowInterface $questsStateMachine)
{
$this->questStorage = $questStorage;
$this->questWorkflow = $questWorkflow;
$this->questWorkflow = $questsStateMachine;
}

public function startQuest(int $questId, int $userId): QuestInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Reward/Collect/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Provider
/** @var CollectorInterface[] */
private $collectors;

public function __construct(array $collectors)
public function __construct(iterable $collectors)
{
$this->collectors = $collectors;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Reward/NoRewardListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Workflow\Event\Event;
use Symfony\Component\Workflow\Workflow;
use Symfony\Component\Workflow\WorkflowInterface;

class NoRewardListener implements EventSubscriberInterface
{
/** @var RegistryInterface */
private $questRegistry;
/** @var Workflow */
/** @var WorkflowInterface */
private $worfkflow;

public function __construct(RegistryInterface $questRegistry, Workflow $worfkflow)
public function __construct(RegistryInterface $questRegistry, WorkflowInterface $questsStateMachine)
{
$this->questRegistry = $questRegistry;
$this->worfkflow = $worfkflow;
$this->worfkflow = $questsStateMachine;
}

public function validate(Event $event): void
Expand Down

0 comments on commit 379b1f2

Please sign in to comment.