Skip to content

Commit cbd3fe0

Browse files
author
Pierre Tondereau
committed
Fix PHPStan errors.
1 parent 7d14c15 commit cbd3fe0

18 files changed

+51
-30
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ matrix:
2424
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" EXECUTE_CS_CHECK=true COVERAGE=true
2525
- php: 7.2
2626
- php: 7.3
27-
env: SYMFONY_REQUIRE="4.4.*"
27+
env: SYMFONY_REQUIRE="4.3.*"
2828
- php: 7.4
29-
env: SYMFONY_REQUIRE="4.4.*"
29+
env: SYMFONY_REQUIRE="4.3.*"
3030
- php: 7.4
3131
env: SYMFONY_REQUIRE="5.0.*"
3232
- php: 7.4
3333
env: SYMFONY_REQUIRE="5.1.*@dev"
3434
- php: nightly
35-
env: SYMFONY_REQUIRE="4.4.*"
35+
env: SYMFONY_REQUIRE="4.3.*"
3636
allow_failures:
3737
# Allow failures on next Symfony minor, should always be tested on newest stable PHP branch
3838
- php: 7.4
3939
env: SYMFONY_REQUIRE="5.1.*@dev"
4040
- php: nightly
41-
env: SYMFONY_REQUIRE="4.4.*"
41+
env: SYMFONY_REQUIRE="4.3.*"
4242

4343
before_install:
4444
- phpenv config-rm xdebug.ini || return 0

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"prooph/php-cs-fixer-config": "^0.2.1",
7373
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
7474
"phpstan/phpstan": "^0.12",
75-
"symfony/messenger": "^4.3 || ^5.0"
75+
"symfony/messenger": "^4.3 || ^5.0",
76+
"phpstan/phpstan-symfony": "^0.12.1"
7677
},
7778
"suggest": {
7879
"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.#'

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: 6 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) {

src/Command/ProjectionResetCommand.php

Lines changed: 1 addition & 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

src/Command/ProjectionStateCommand.php

Lines changed: 5 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,7 +20,10 @@ 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);
2427

2528
return 0;
2629
}

src/Command/ProjectionStopCommand.php

Lines changed: 1 addition & 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

0 commit comments

Comments
 (0)