Skip to content

Commit 70b6e6d

Browse files
authored
Merge pull request #68 from ptondereau/update-symfony-5
Add support of Symfony 5.0
2 parents 46ea0a5 + 1ce6c4b commit 70b6e6d

31 files changed

+177
-90
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ doc/html
1313
.php_cs.cache
1414
/test/Command/Fixture/var/*
1515
!/test/Command/Fixture/var/.gitkeep
16+
.phpunit.result.cache

.travis.yml

Lines changed: 69 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
sudo: false
2-
31
language: php
2+
sudo: false
3+
dist: xenial
44

55
branches:
66
except:
@@ -11,46 +11,83 @@ cache:
1111
- $HOME/.composer/cache
1212
- $HOME/.php-cs-fixer
1313

14-
php:
15-
- 7.1
16-
- 7.2
17-
1814
env:
1915
global:
20-
- EXECUTE_CS_CHECK=false
21-
- TEST_COVERAGE=false
22-
matrix:
23-
- DEPENDENCIES="--prefer-lowest --prefer-stable"
24-
- DEPENDENCIES=""
25-
26-
matrix:
27-
fast_finish: true
28-
include:
29-
- php: 7.2
30-
env: DEPENDENCIES="" EXECUTE_CS_CHECK=true TEST_COVERAGE=true
31-
exclude:
32-
- php: 7.2
33-
env: DEPENDENCIES=""
16+
- COMPOSER_MEMORY_LIMIT=-1
3417

3518
before_install:
36-
- phpenv config-rm xdebug.ini || return 0
19+
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
3720
- composer self-update
38-
- if [[ $TEST_COVERAGE == 'true' ]]; then composer require --no-update satooshi/php-coveralls:^1.0 ; fi
21+
- composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
3922

4023
install:
41-
- travis_retry composer update --no-interaction --prefer-dist $DEPENDENCIES
42-
- composer info -i
43-
44-
before_script:
45-
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then mkdir -p "$HOME/.php-cs-fixer" ; fi
24+
- travis_retry composer update -n --prefer-dist --prefer-stable
4625

4726
script:
48-
- if [[ $TEST_COVERAGE == 'true' ]]; then php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml; else ./vendor/bin/phpunit; fi
49-
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run; fi
50-
- ./vendor/bin/phpstan analyse -c phpstan.neon -l 7 src
27+
- ./vendor/bin/phpunit -v
28+
29+
jobs:
30+
include:
31+
- php: 7.1
32+
env: LOWEST SYMFONY_DEPRECATIONS_HELP=weak SYMFONY_REQUIRE="3.4.*"
33+
install:
34+
- composer require --dev lendable/symfony-messenger-polyfill --no-update
35+
- travis_retry composer update -n --prefer-lowest --prefer-stable --prefer-dist
36+
37+
- php: 7.2
38+
install:
39+
- composer require --dev symfony/messenger --no-update
40+
- travis_retry composer update -n --prefer-dist
41+
42+
- php: 7.3
43+
install:
44+
- composer require --dev symfony/messenger --no-update
45+
- travis_retry composer update -n --prefer-dist
46+
47+
48+
# Test against latest Symfony 3.4
49+
- php: 7.4
50+
env: SYMFONY_REQUIRE="3.4.*"
51+
install:
52+
- composer require --dev lendable/symfony-messenger-polyfill --no-update
53+
- travis_retry composer update -n --prefer-dist
54+
55+
# Test against latest Symfony 4.4
56+
- php: 7.4
57+
env: SYMFONY_REQUIRE="4.4.*"
58+
install:
59+
- composer require --dev symfony/messenger --no-update
60+
- travis_retry composer update -n --prefer-dist
61+
62+
# Test against latest Symfony 5.0
63+
- php: 7.4
64+
env: SYMFONY_REQUIRE="5.0.*"
65+
install:
66+
- composer require --dev symfony/messenger --no-update
67+
- travis_retry composer update -n --prefer-dist
68+
69+
- stage: Code Quality
70+
env: CODING_STANDARDS
71+
php: 7.4
72+
install:
73+
- composer require --dev symfony/messenger --no-update
74+
- travis_retry composer update -n --prefer-dist
75+
script:
76+
- ./vendor/bin/php-cs-fixer fix -v --diff --dry-run
77+
- ./vendor/bin/phpstan analyse -c phpstan.neon -l 7 src
5178

52-
after_script:
53-
- if [[ $TEST_COVERAGE == 'true' ]]; then php vendor/bin/coveralls -v; fi
79+
- stage: Coverage
80+
php: 7.4
81+
install:
82+
- composer require --dev symfony/messenger --no-update
83+
- travis_retry composer update -n --prefer-dist
84+
before_script:
85+
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
86+
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
87+
- composer require --dev php-coveralls/php-coveralls
88+
script:
89+
- ./vendor/bin/phpunit -v --coverage-clover ./build/logs/clover.xml
90+
- ./vendor/bin/php-coveralls -v
5491

5592
notifications:
5693
webhooks:

composer.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,26 @@
5252
},
5353
"require": {
5454
"php": "^7.1",
55-
"symfony/config": "^3.3 || ^4.0",
56-
"symfony/dependency-injection": "^3.3 || ^4.0",
57-
"symfony/http-kernel": "^3.3 || ^4.0",
58-
"symfony/framework-bundle": "^3.3 || ^4.0",
55+
"ext-pdo": "*",
56+
"ext-json": "*",
57+
"symfony/config": "^3.4 || ^4.4 || ^5.0",
58+
"symfony/dependency-injection": "^3.4 || ^4.4 || ^5.0",
59+
"symfony/http-kernel": "^3.4 || ^4.4 || ^5.0",
60+
"symfony/framework-bundle": "^3.4 || ^4.4 || ^5.0",
5961
"prooph/event-store": "^7.0"
6062
},
6163
"require-dev": {
6264
"prooph/event-sourcing": "^5.0",
6365
"prooph/snapshot-store": "^1.0",
6466
"prooph/pdo-event-store": "^1.0",
65-
"phpunit/phpunit": "^6",
66-
"symfony/yaml" : "^3.3 || ^4.0",
67+
"phpunit/phpunit": "^7 || ^8",
68+
"symfony/yaml" : "^3.4 || ^4.4 || ^5.0",
6769
"bookdown/bookdown": "1.x-dev as 1.0.0",
6870
"prooph/bookdown-template": "^0.2.3",
6971
"friendsofphp/php-cs-fixer": "^2.8.1",
7072
"prooph/php-cs-fixer-config": "^0.2.1",
71-
"matthiasnoback/symfony-dependency-injection-test": "^2.3",
72-
"phpstan/phpstan": "^0.9.2",
73-
"symfony/messenger": "^4.3"
73+
"matthiasnoback/symfony-dependency-injection-test": "^3.1 || ^4.1",
74+
"phpstan/phpstan": "^0.12"
7475
},
7576
"suggest": {
7677
"prooph/event-store-bus-bridge": "To Marry CQRS (ProophSerivceBus) with Event Sourcing"

phpstan.neon

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
parameters:
22
reportUnmatchedIgnoredErrors: false
3+
checkMissingIterableValueType: false
4+
checkGenericClassInNonGenericObjectType: false
35
ignoreErrors:
46
# Only available in ArrayNodeDefinition which is given
57
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)\.#'
@@ -9,6 +11,7 @@ parameters:
911
# TreeBuilder in Symfony 4.2 and up has a constructor and a getRootNode() method
1012
- '#Class Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder does not have a constructor and must be instantiated without any parameters\.#'
1113
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder::getRootNode\(\)#'
14+
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder::root\(\)#'
1215
# More Symfony 4.2 compatibility errors
1316
- '#Parameter \#2 \$deleteEmittedEvents of method Prooph\\EventStore\\Projection\\ProjectionManager::deleteProjection\(\) expects bool, array<string>\|bool\|string\|null given\.#'
1417
- '#Property Prooph\\Bundle\\EventStore\\Command\\AbstractProjectionCommand::\$projectionName \(string\) does not accept array<string>\|string\|null\.#'
@@ -18,4 +21,5 @@ parameters:
1821
# MariaDbEventStore is available since pdo-event-store v1.3
1922
- '#Class Prooph\\EventStore\\Pdo\\MariaDbEventStore not found\.#'
2023
- '#Method Prooph\\Bundle\\EventStore\\ProjectionManagerFactory::createProjectionManager\(\) should return Prooph\\EventStore\\Projection\\ProjectionManager but returns Prooph\\EventStore\\Pdo\\Projection\\MariaDbProjectionManager\.#'
21-
- '#Instantiated class Prooph\\EventStore\\Pdo\\Projection\\MariaDbProjectionManager not found\.#'
24+
- '#Instantiated class Prooph\\EventStore\\Pdo\\Projection\\MariaDbProjectionManager not found\.#'
25+
- '#Parameter \#1 $argument of class ReflectionClass constructor expects class-string<T of object>\|T of object, string\|null given.#'

phpunit.xml.dist

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
colors="true"
55
convertErrorsToExceptions="true"
66
convertNoticesToExceptions="true"
7-
convertWarningsToExceptions="true"
8-
syntaxCheck="true"
7+
convertWarningsToExceptions="false"
98
backupGlobals="true"
109
backupStaticAttributes="false">
1110

src/Command/AbstractProjectionCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ public function __construct(
7575
parent::__construct();
7676
}
7777

78-
protected function configure()
78+
protected function configure(): void
7979
{
8080
$this->addArgument(static::ARGUMENT_PROJECTION_NAME, InputArgument::REQUIRED, 'The name of the Projection');
8181
}
8282

83-
protected function initialize(InputInterface $input, OutputInterface $output)
83+
protected function initialize(InputInterface $input, OutputInterface $output): void
8484
{
8585
$input->validate();
8686

@@ -89,18 +89,18 @@ protected function initialize(InputInterface $input, OutputInterface $output)
8989
$this->projectionName = $input->getArgument(static::ARGUMENT_PROJECTION_NAME);
9090

9191
if (! $this->projectionManagerForProjectionsLocator->has($this->projectionName)) {
92-
throw new RuntimeException(\sprintf('ProjectionManager for "%s" not found', $this->projectionName));
92+
throw new RuntimeException(\vsprintf('ProjectionManager for "%s" not found', \is_array($this->projectionName) ? $this->projectionName : [$this->projectionName]));
9393
}
9494
$this->projectionManager = $this->projectionManagerForProjectionsLocator->get($this->projectionName);
9595

9696
if (! $this->projectionsLocator->has($this->projectionName)) {
97-
throw new RuntimeException(\sprintf('Projection "%s" not found', $this->projectionName));
97+
throw new RuntimeException(\vsprintf('Projection "%s" not found', \is_array($this->projectionName) ? $this->projectionName : [$this->projectionName]));
9898
}
9999
$this->projection = $this->projectionsLocator->get($this->projectionName);
100100

101101
if ($this->projection instanceof ReadModelProjection) {
102102
if (! $this->projectionReadModelLocator->has($this->projectionName)) {
103-
throw new RuntimeException(\sprintf('ReadModel for "%s" not found', $this->projectionName));
103+
throw new RuntimeException(\vsprintf('ReadModel for "%s" not found', \is_array($this->projectionName) ? $this->projectionName : [$this->projectionName]));
104104
}
105105
$this->readModel = $this->projectionReadModelLocator->get($this->projectionName);
106106

@@ -114,7 +114,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
114114
if (null === $this->projector) {
115115
throw new RuntimeException('Projection was not created');
116116
}
117-
$output->writeln(\sprintf('<header>Initialized projection "%s"</header>', $this->projectionName));
117+
$output->writeln(\vsprintf('<header>Initialized projection "%s"</header>', \is_array($this->projectionName) ? $this->projectionName : [$this->projectionName]));
118118
try {
119119
$state = $this->projectionManager->fetchProjectionStatus($this->projectionName)->getValue();
120120
} catch (\Prooph\EventStore\Exception\RuntimeException $e) {

src/Command/FormatsOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
trait FormatsOutput
1111
{
12-
protected function formatOutput(OutputInterface $output)
12+
protected function formatOutput(OutputInterface $output): void
1313
{
1414
$outputFormatter = $output->getFormatter();
1515
$outputFormatter->setStyle('header', new OutputFormatterStyle('green', null));

src/Command/ProjectionDeleteCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ProjectionDeleteCommand extends AbstractProjectionCommand
1212
{
1313
protected const OPTION_WITH_EVENTS = 'with-emitted-events';
1414

15-
protected function configure()
15+
protected function configure(): void
1616
{
1717
parent::configure();
1818
$this
@@ -21,7 +21,7 @@ protected function configure()
2121
->addOption(static::OPTION_WITH_EVENTS, 'w', InputOption::VALUE_NONE, 'Delete with emitted events');
2222
}
2323

24-
protected function execute(InputInterface $input, OutputInterface $output)
24+
protected function execute(InputInterface $input, OutputInterface $output): int
2525
{
2626
$withEvents = $input->getOption(self::OPTION_WITH_EVENTS);
2727
if ($withEvents) {
@@ -30,5 +30,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
3030
$output->writeln(\sprintf('<action>Deleting projection </action><highlight>%s</highlight>', $this->projectionName));
3131
}
3232
$this->projectionManager->deleteProjection($this->projectionName, $withEvents);
33+
34+
return 0;
3335
}
3436
}

src/Command/ProjectionNamesCommand.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(ContainerInterface $projectionManagersLocator, array
4040
parent::__construct();
4141
}
4242

43-
protected function configure()
43+
protected function configure(): void
4444
{
4545
$this
4646
->setName('event-store:projection:names')
@@ -64,6 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6464
});
6565
}
6666

67+
/** @var string|null $filter */
6768
$filter = $input->getArgument(self::ARGUMENT_FILTER);
6869
$regex = $input->getOption(static::OPTION_REGEX);
6970

@@ -80,8 +81,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
8081
$output->writeln('</action>');
8182

8283
$names = [];
83-
$offset = (int) $input->getOption(self::OPTION_OFFSET);
84-
$limit = (int) $input->getOption(self::OPTION_LIMIT);
84+
/** @var int $offset */
85+
$offset = $input->getOption(self::OPTION_OFFSET);
86+
/** @var int $limit */
87+
$limit = $input->getOption(self::OPTION_LIMIT);
8588
$maxNeeded = $offset + $limit;
8689

8790
foreach ($managerNames as $managerName) {
@@ -110,5 +113,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
110113
->setRows($names);
111114

112115
$table->render();
116+
117+
return 0;
113118
}
114119
}

src/Command/ProjectionResetCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class ProjectionResetCommand extends AbstractProjectionCommand
1111
{
12-
protected function configure()
12+
protected function configure(): void
1313
{
1414
parent::configure();
1515
$this
@@ -21,5 +21,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
2121
{
2222
$output->writeln(\sprintf('<action>Resetting projection <highlight>%s</highlight></action>', $this->projectionName));
2323
$this->projectionManager->resetProjection($this->projectionName);
24+
25+
return 0;
2426
}
2527
}

src/Command/ProjectionRunCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
3434
$projector = $this->projection->project($this->projector);
3535
$projector->run($keepRunning);
3636
$output->writeln(\sprintf('<action>Projection <highlight>%s</highlight> completed.</action>', $this->projectionName));
37+
38+
return 0;
3739
}
3840
}

src/Command/ProjectionStateCommand.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class ProjectionStateCommand extends AbstractProjectionCommand
1111
{
12-
protected function configure()
12+
protected function configure(): void
1313
{
1414
parent::configure();
1515
$this
@@ -20,6 +20,11 @@ protected function configure()
2020
protected function execute(InputInterface $input, OutputInterface $output)
2121
{
2222
$output->writeln('<action>Current state:</action>');
23-
$output->writeln(\json_encode($this->projectionManager->fetchProjectionState($this->projectionName)));
23+
24+
/** @var string $state */
25+
$state = \json_encode($this->projectionManager->fetchProjectionState($this->projectionName));
26+
$output->writeln($state);
27+
28+
return 0;
2429
}
2530
}

src/Command/ProjectionStopCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class ProjectionStopCommand extends AbstractProjectionCommand
1111
{
12-
protected function configure()
12+
protected function configure(): void
1313
{
1414
parent::configure();
1515
$this
@@ -21,5 +21,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
2121
{
2222
$output->writeln(\sprintf('<action>Stopping projection <highlight>%s</highlight></action>', $this->projectionName));
2323
$this->projectionManager->stopProjection($this->projectionName);
24+
25+
return 0;
2426
}
2527
}

src/Command/ProjectionStreamPositionsCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class ProjectionStreamPositionsCommand extends AbstractProjectionCommand
1212
{
13-
protected function configure()
13+
protected function configure(): void
1414
{
1515
parent::configure();
1616
$this
@@ -26,5 +26,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
2626
$table->addRow([$stream, $position]);
2727
}
2828
$table->render();
29+
30+
return 0;
2931
}
3032
}

0 commit comments

Comments
 (0)