Skip to content

Commit

Permalink
Update to symfony 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
glaubinix committed Aug 21, 2021
1 parent d631618 commit c763592
Show file tree
Hide file tree
Showing 7 changed files with 677 additions and 754 deletions.
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"type": "library",
"require": {
"php": "^7.2",
"symfony/workflow": "^4.4",
"symfony/workflow": "^5.3",
"roave/security-advisories": "dev-master",
"doctrine/orm": "^2.5",
"symfony/console": "^4.4",
"doctrine/cache": "^1.6"
"symfony/console": "^5.3"
},
"repositories": [
{"type": "vcs", "url": "https://github.com/etoa/Silex"}
],
"license": "MIT",
"authors": [
{
Expand All @@ -30,7 +32,7 @@
"require-dev": {
"phpunit/phpunit": "^8.0",
"friendsofphp/php-cs-fixer": "^2.0",
"silex/silex": "^2.0",
"silex/silex": "dev-t/symfony-53",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
Expand Down
1,365 changes: 622 additions & 743 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ parameters:
- '#Dynamic call to static method PHPUnit\\Framework\\TestCase#'
- '#assertInstanceOf\(\) expects class-string\<object\>\, string given#'
- '#ProgressHandler\:\:handle\(\) expects callable#'
- '#Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required.#'
- '#Method LittleCubicleGames\\Quests\\Progress\\ProgressHandler::handle\(\) has parameter \$event with no typehint specified.#'
- '#Doctrine\\Common\\Cache\\ArrayCache#'
2 changes: 1 addition & 1 deletion src/Guard/IsCompletedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function validate(GuardEvent $event): void
}

/**
* @return string[]
* @return array<string, string>
*/
public static function getSubscribedEvents(): array
{
Expand Down
44 changes: 44 additions & 0 deletions src/Helper/ArrayCache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php declare(strict_types=1);

namespace LittleCubicleGames\Quests\Helper;

use Doctrine\Common\Cache\Cache;

class ArrayCache implements Cache
{
/** @var array<mixed, mixed> */
private $cache = [];

public function fetch($id)
{
return $this->cache[$id] ?? null;
}

public function contains($id)
{
return isset($this->cache[$id]);
}

public function save($id, $data, $lifeTime = 0)
{
$this->cache[$id] = $data;

return true;
}

public function delete($id)
{
if ($this->contains($id)) {
unset($this->cache[$id]);

return true;
}

return false;
}

public function getStats()
{
return null;
}
}
6 changes: 3 additions & 3 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace LittleCubicleGames\Quests;

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\Cache;
use LittleCubicleGames\Quests\Command\ValidationCommand;
use LittleCubicleGames\Quests\Definition\Quest\QuestBuilder;
use LittleCubicleGames\Quests\Definition\Registry\RandomRegistry;
Expand All @@ -11,6 +11,7 @@
use LittleCubicleGames\Quests\Definition\Task\TaskBuilder;
use LittleCubicleGames\Quests\Guard\IsCompletedListener;
use LittleCubicleGames\Quests\Guard\TriggerValidator;
use LittleCubicleGames\Quests\Helper\ArrayCache;
use LittleCubicleGames\Quests\Initialization\NextQuestListener;
use LittleCubicleGames\Quests\Initialization\QuestInitializer;
use LittleCubicleGames\Quests\Initialization\QuestStarter;
Expand All @@ -31,7 +32,6 @@
use Silex\Api\EventListenerProviderInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Workflow\MarkingStore\MethodMarkingStore;
use Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore;
use Symfony\Component\Workflow\Workflow;

class ServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface
Expand Down Expand Up @@ -76,7 +76,7 @@ public function register(Container $pimple): void
return new SlotBuilder();
};

$pimple['cubicle.quests.definition.cache'] = function (): ArrayCache {
$pimple['cubicle.quests.definition.cache'] = function (): Cache {
return new ArrayCache();
};

Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/WorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testProgress(): void
$event = new Event($eventQuest, new Marking(), new Transition(QuestDefinitionInterface::TRANSITION_REJECT, '', ''));
for ($i = 0; $i < 11; $i++) {
$this->assertSame(QuestDefinitionInterface::STATE_IN_PROGRESS, $quest->getState());
$this->app['dispatcher']->dispatch($eventName, $event);
$this->app['dispatcher']->dispatch($event, $eventName);
}

$this->assertSame(QuestDefinitionInterface::STATE_FINISHED, $quest->getState());
Expand Down

0 comments on commit c763592

Please sign in to comment.