Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of Symfony 5.0 #68

Merged
merged 8 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ doc/html
.php_cs.cache
/test/Command/Fixture/var/*
!/test/Command/Fixture/var/.gitkeep
.phpunit.result.cache
101 changes: 69 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sudo: false

language: php
sudo: false
dist: xenial

branches:
except:
Expand All @@ -11,46 +11,83 @@ cache:
- $HOME/.composer/cache
- $HOME/.php-cs-fixer

php:
- 7.1
- 7.2

env:
global:
- EXECUTE_CS_CHECK=false
- TEST_COVERAGE=false
matrix:
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- DEPENDENCIES=""

matrix:
fast_finish: true
include:
- php: 7.2
env: DEPENDENCIES="" EXECUTE_CS_CHECK=true TEST_COVERAGE=true
exclude:
- php: 7.2
env: DEPENDENCIES=""
- COMPOSER_MEMORY_LIMIT=-1

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

install:
- travis_retry composer update --no-interaction --prefer-dist $DEPENDENCIES
- composer info -i

before_script:
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then mkdir -p "$HOME/.php-cs-fixer" ; fi
- travis_retry composer update -n --prefer-dist --prefer-stable

script:
- 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
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run; fi
- ./vendor/bin/phpstan analyse -c phpstan.neon -l 7 src
- ./vendor/bin/phpunit -v

jobs:
include:
- php: 7.1
env: LOWEST SYMFONY_DEPRECATIONS_HELP=weak SYMFONY_REQUIRE="3.4.*"
install:
- composer require --dev lendable/symfony-messenger-polyfill --no-update
- travis_retry composer update -n --prefer-lowest --prefer-stable --prefer-dist

- php: 7.2
install:
- composer require --dev symfony/messenger --no-update
- travis_retry composer update -n --prefer-dist

- php: 7.3
install:
- composer require --dev symfony/messenger --no-update
- travis_retry composer update -n --prefer-dist


# Test against latest Symfony 3.4
- php: 7.4
env: SYMFONY_REQUIRE="3.4.*"
install:
- composer require --dev lendable/symfony-messenger-polyfill --no-update
- travis_retry composer update -n --prefer-dist

# Test against latest Symfony 4.4
- php: 7.4
env: SYMFONY_REQUIRE="4.4.*"
install:
- composer require --dev symfony/messenger --no-update
- travis_retry composer update -n --prefer-dist

# Test against latest Symfony 5.0
- php: 7.4
env: SYMFONY_REQUIRE="5.0.*"
install:
- composer require --dev symfony/messenger --no-update
- travis_retry composer update -n --prefer-dist

- stage: Code Quality
env: CODING_STANDARDS
php: 7.4
install:
- composer require --dev symfony/messenger --no-update
- travis_retry composer update -n --prefer-dist
script:
- ./vendor/bin/php-cs-fixer fix -v --diff --dry-run
- ./vendor/bin/phpstan analyse -c phpstan.neon -l 7 src

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

notifications:
webhooks:
Expand Down
19 changes: 10 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,26 @@
},
"require": {
"php": "^7.1",
"symfony/config": "^3.3 || ^4.0",
"symfony/dependency-injection": "^3.3 || ^4.0",
"symfony/http-kernel": "^3.3 || ^4.0",
"symfony/framework-bundle": "^3.3 || ^4.0",
"ext-pdo": "*",
"ext-json": "*",
"symfony/config": "^3.4 || ^4.4 || ^5.0",
"symfony/dependency-injection": "^3.4 || ^4.4 || ^5.0",
"symfony/http-kernel": "^3.4 || ^4.4 || ^5.0",
"symfony/framework-bundle": "^3.4 || ^4.4 || ^5.0",
"prooph/event-store": "^7.0"
},
"require-dev": {
"prooph/event-sourcing": "^5.0",
"prooph/snapshot-store": "^1.0",
"prooph/pdo-event-store": "^1.0",
"phpunit/phpunit": "^6",
"symfony/yaml" : "^3.3 || ^4.0",
"phpunit/phpunit": "^7 || ^8",
"symfony/yaml" : "^3.4 || ^4.4 || ^5.0",
"bookdown/bookdown": "1.x-dev as 1.0.0",
"prooph/bookdown-template": "^0.2.3",
"friendsofphp/php-cs-fixer": "^2.8.1",
"prooph/php-cs-fixer-config": "^0.2.1",
"matthiasnoback/symfony-dependency-injection-test": "^2.3",
"phpstan/phpstan": "^0.9.2",
"symfony/messenger": "^4.3"
"matthiasnoback/symfony-dependency-injection-test": "^3.1 || ^4.1",
"phpstan/phpstan": "^0.12"
},
"suggest": {
"prooph/event-store-bus-bridge": "To Marry CQRS (ProophSerivceBus) with Event Sourcing"
Expand Down
6 changes: 5 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
parameters:
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
# Only available in ArrayNodeDefinition which is given
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)\.#'
Expand All @@ -9,6 +11,7 @@ parameters:
# TreeBuilder in Symfony 4.2 and up has a constructor and a getRootNode() method
- '#Class Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder does not have a constructor and must be instantiated without any parameters\.#'
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder::getRootNode\(\)#'
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder::root\(\)#'
# More Symfony 4.2 compatibility errors
- '#Parameter \#2 \$deleteEmittedEvents of method Prooph\\EventStore\\Projection\\ProjectionManager::deleteProjection\(\) expects bool, array<string>\|bool\|string\|null given\.#'
- '#Property Prooph\\Bundle\\EventStore\\Command\\AbstractProjectionCommand::\$projectionName \(string\) does not accept array<string>\|string\|null\.#'
Expand All @@ -18,4 +21,5 @@ parameters:
# MariaDbEventStore is available since pdo-event-store v1.3
- '#Class Prooph\\EventStore\\Pdo\\MariaDbEventStore not found\.#'
- '#Method Prooph\\Bundle\\EventStore\\ProjectionManagerFactory::createProjectionManager\(\) should return Prooph\\EventStore\\Projection\\ProjectionManager but returns Prooph\\EventStore\\Pdo\\Projection\\MariaDbProjectionManager\.#'
- '#Instantiated class Prooph\\EventStore\\Pdo\\Projection\\MariaDbProjectionManager not found\.#'
- '#Instantiated class Prooph\\EventStore\\Pdo\\Projection\\MariaDbProjectionManager not found\.#'
- '#Parameter \#1 $argument of class ReflectionClass constructor expects class-string<T of object>\|T of object, string\|null given.#'
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
syntaxCheck="true"
convertWarningsToExceptions="false"
backupGlobals="true"
backupStaticAttributes="false">

Expand Down
12 changes: 6 additions & 6 deletions src/Command/AbstractProjectionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ public function __construct(
parent::__construct();
}

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

protected function initialize(InputInterface $input, OutputInterface $output)
protected function initialize(InputInterface $input, OutputInterface $output): void
{
$input->validate();

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

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

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

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

Expand All @@ -114,7 +114,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
if (null === $this->projector) {
throw new RuntimeException('Projection was not created');
}
$output->writeln(\sprintf('<header>Initialized projection "%s"</header>', $this->projectionName));
$output->writeln(\vsprintf('<header>Initialized projection "%s"</header>', \is_array($this->projectionName) ? $this->projectionName : [$this->projectionName]));
try {
$state = $this->projectionManager->fetchProjectionStatus($this->projectionName)->getValue();
} catch (\Prooph\EventStore\Exception\RuntimeException $e) {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/FormatsOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

trait FormatsOutput
{
protected function formatOutput(OutputInterface $output)
protected function formatOutput(OutputInterface $output): void
{
$outputFormatter = $output->getFormatter();
$outputFormatter->setStyle('header', new OutputFormatterStyle('green', null));
Expand Down
6 changes: 4 additions & 2 deletions src/Command/ProjectionDeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ProjectionDeleteCommand extends AbstractProjectionCommand
{
protected const OPTION_WITH_EVENTS = 'with-emitted-events';

protected function configure()
protected function configure(): void
{
parent::configure();
$this
Expand All @@ -21,7 +21,7 @@ protected function configure()
->addOption(static::OPTION_WITH_EVENTS, 'w', InputOption::VALUE_NONE, 'Delete with emitted events');
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$withEvents = $input->getOption(self::OPTION_WITH_EVENTS);
if ($withEvents) {
Expand All @@ -30,5 +30,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(\sprintf('<action>Deleting projection </action><highlight>%s</highlight>', $this->projectionName));
}
$this->projectionManager->deleteProjection($this->projectionName, $withEvents);

return 0;
}
}
11 changes: 8 additions & 3 deletions src/Command/ProjectionNamesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(ContainerInterface $projectionManagersLocator, array
parent::__construct();
}

protected function configure()
protected function configure(): void
{
$this
->setName('event-store:projection:names')
Expand All @@ -64,6 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
});
}

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

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

$names = [];
$offset = (int) $input->getOption(self::OPTION_OFFSET);
$limit = (int) $input->getOption(self::OPTION_LIMIT);
/** @var int $offset */
$offset = $input->getOption(self::OPTION_OFFSET);
/** @var int $limit */
$limit = $input->getOption(self::OPTION_LIMIT);
$maxNeeded = $offset + $limit;

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

$table->render();

return 0;
}
}
4 changes: 3 additions & 1 deletion src/Command/ProjectionResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ProjectionResetCommand extends AbstractProjectionCommand
{
protected function configure()
protected function configure(): void
{
parent::configure();
$this
Expand All @@ -21,5 +21,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(\sprintf('<action>Resetting projection <highlight>%s</highlight></action>', $this->projectionName));
$this->projectionManager->resetProjection($this->projectionName);

return 0;
}
}
2 changes: 2 additions & 0 deletions src/Command/ProjectionRunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$projector = $this->projection->project($this->projector);
$projector->run($keepRunning);
$output->writeln(\sprintf('<action>Projection <highlight>%s</highlight> completed.</action>', $this->projectionName));

return 0;
}
}
9 changes: 7 additions & 2 deletions src/Command/ProjectionStateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ProjectionStateCommand extends AbstractProjectionCommand
{
protected function configure()
protected function configure(): void
{
parent::configure();
$this
Expand All @@ -20,6 +20,11 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('<action>Current state:</action>');
$output->writeln(\json_encode($this->projectionManager->fetchProjectionState($this->projectionName)));

/** @var string $state */
$state = \json_encode($this->projectionManager->fetchProjectionState($this->projectionName));
$output->writeln($state);

return 0;
}
}
4 changes: 3 additions & 1 deletion src/Command/ProjectionStopCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ProjectionStopCommand extends AbstractProjectionCommand
{
protected function configure()
protected function configure(): void
{
parent::configure();
$this
Expand All @@ -21,5 +21,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(\sprintf('<action>Stopping projection <highlight>%s</highlight></action>', $this->projectionName));
$this->projectionManager->stopProjection($this->projectionName);

return 0;
}
}
4 changes: 3 additions & 1 deletion src/Command/ProjectionStreamPositionsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class ProjectionStreamPositionsCommand extends AbstractProjectionCommand
{
protected function configure()
protected function configure(): void
{
parent::configure();
$this
Expand All @@ -26,5 +26,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$table->addRow([$stream, $position]);
}
$table->render();

return 0;
}
}
Loading