Skip to content

Commit

Permalink
Update phpstan
Browse files Browse the repository at this point in the history
In this commit phpstan is updated to the latest version (2.0.2).
By doing so some new errors bubbled up, these are also addressed in
this commit.
  • Loading branch information
LVoogd committed Nov 23, 2024
1 parent 4a42aa3 commit d6fa8da
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4",
"fakerphp/faker": "^1.21",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.7",
"symfony/browser-kit": "7.1.*",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 18 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
parameters:
ignoreErrors:
-
message: "#^Method Dev\\\\Common\\\\Infrastructure\\\\Cache\\\\RecordingCache\\:\\:get\\(\\) has parameter \\$metadata with no value type specified in iterable type array\\.$#"
message: '#^Method Dev\\Common\\Infrastructure\\Cache\\RecordingCache\:\:get\(\) has parameter \$metadata with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src-dev/Common/Infrastructure/Cache/RecordingCache.php

-
message: "#^Method App\\\\Feed\\\\Infrastructure\\\\Persistence\\\\Doctrine\\\\Article\\\\DoctrineArticleRepository\\:\\:findByUrl\\(\\) should return App\\\\Feed\\\\Domain\\\\Article\\\\Article\\|null but returns mixed\\.$#"
message: '#^Method App\\Feed\\Infrastructure\\Persistence\\Doctrine\\Article\\DoctrineArticleRepository\:\:findByUrl\(\) should return App\\Feed\\Domain\\Article\\Article\|null but returns mixed\.$#'
identifier: return.type
count: 1
path: src/Feed/Infrastructure/Persistence/Doctrine/Article/DoctrineArticleRepository.php

-
message: "#^Parameter \\#1 \\$id of class App\\\\Feed\\\\Domain\\\\Article\\\\ArticleId constructor expects string, mixed given\\.$#"
message: '#^Parameter \#1 \$id of class App\\Feed\\Domain\\Article\\ArticleId constructor expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Feed/Infrastructure/Persistence/Doctrine/Article/DoctrineArticleRepository.php

-
message: "#^Method App\\\\Feed\\\\Infrastructure\\\\Persistence\\\\Doctrine\\\\Source\\\\DoctrineSourceRepository\\:\\:findByNameOrThrow\\(\\) should return App\\\\Feed\\\\Domain\\\\Source\\\\Source but returns mixed\\.$#"
message: '#^Method App\\Feed\\Infrastructure\\Persistence\\Doctrine\\Source\\DoctrineSourceRepository\:\:findByNameOrThrow\(\) should return App\\Feed\\Domain\\Source\\Source but returns mixed\.$#'
identifier: return.type
count: 1
path: src/Feed/Infrastructure/Persistence/Doctrine/Source/DoctrineSourceRepository.php

-
message: "#^Parameter \\#2 \\$configurator of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:registerAttributeForAutoconfiguration\\(\\) expects callable\\(Symfony\\\\Component\\\\DependencyInjection\\\\ChildDefinition, App\\\\Common\\\\Infrastructure\\\\Messenger\\\\CommandBus\\\\AsCommandHandler, Reflector\\)\\: void, Closure\\(Symfony\\\\Component\\\\DependencyInjection\\\\ChildDefinition, App\\\\Common\\\\Infrastructure\\\\Messenger\\\\CommandBus\\\\AsCommandHandler, ReflectionClass\\|ReflectionMethod\\)\\: void given\\.$#"
message: '#^Parameter \#2 \$configurator of method Symfony\\Component\\DependencyInjection\\ContainerBuilder\:\:registerAttributeForAutoconfiguration\(\) expects callable\(Symfony\\Component\\DependencyInjection\\ChildDefinition, App\\Common\\Infrastructure\\Messenger\\CommandBus\\AsCommandHandler, Reflector\)\: void, Closure\(Symfony\\Component\\DependencyInjection\\ChildDefinition, App\\Common\\Infrastructure\\Messenger\\CommandBus\\AsCommandHandler, ReflectionClass\|ReflectionMethod\)\: void given\.$#'
identifier: argument.type
count: 1
path: src/Kernel.php

-
message: "#^Parameter \\#2 \\$configurator of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:registerAttributeForAutoconfiguration\\(\\) expects callable\\(Symfony\\\\Component\\\\DependencyInjection\\\\ChildDefinition, App\\\\Common\\\\Infrastructure\\\\Messenger\\\\EventBus\\\\AsEventSubscriber, Reflector\\)\\: void, Closure\\(Symfony\\\\Component\\\\DependencyInjection\\\\ChildDefinition, App\\\\Common\\\\Infrastructure\\\\Messenger\\\\EventBus\\\\AsEventSubscriber, ReflectionClass\\|ReflectionMethod\\)\\: void given\\.$#"
message: '#^Parameter \#2 \$configurator of method Symfony\\Component\\DependencyInjection\\ContainerBuilder\:\:registerAttributeForAutoconfiguration\(\) expects callable\(Symfony\\Component\\DependencyInjection\\ChildDefinition, App\\Common\\Infrastructure\\Messenger\\EventBus\\AsEventSubscriber, Reflector\)\: void, Closure\(Symfony\\Component\\DependencyInjection\\ChildDefinition, App\\Common\\Infrastructure\\Messenger\\EventBus\\AsEventSubscriber, ReflectionClass\|ReflectionMethod\)\: void given\.$#'
identifier: argument.type
count: 1
path: src/Kernel.php

-
message: '#^Expression "new class\(\$uuid\) extends \\App\\Common\\Identifier\\UuidId…" on a separate line does not do anything\.$#'
identifier: expr.resultUnused
count: 1
path: tests/Unit/Common/Identifier/UuidIdTest.php
2 changes: 1 addition & 1 deletion src-dev/Feed/Repository/InMemoryArticleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function findLatestIds(int $offset, int $numberOfArticles): array

return array_map(
fn(Article $entity) => $entity->getId(),
array_values(array_slice($entities, $offset, $numberOfArticles))
array_slice($entities, $offset, $numberOfArticles)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function process(ContainerBuilder $container): void
throw new \Exception('%s must implement static method `getSource`.');
}

$source = call_user_func([$service, 'getSource']);
$source = $service::getSource();

if (in_array($source, $sources)) {
throw new \Exception(sprintf(
Expand Down
2 changes: 1 addition & 1 deletion src/Feed/Infrastructure/Helper/DOM/DOM.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
public static function getString(DOMElement $element, string $key): string
{
return $element->getElementsByTagName($key)->item(0)?->firstChild?->nodeValue
return $element->getElementsByTagName($key)->item(0)?->firstChild->nodeValue
?? throw new OutOfBoundsException(sprintf('`%s` does not exist in DOMElement', $key));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function findLatestIds(
int $offset,
int $numberOfArticles,
): array {
return array_map(
return array_values(array_map(
fn($id) => new ArticleId($id),
$this->createQueryBuilder('a')
->select('a.id')
Expand All @@ -65,7 +65,7 @@ public function findLatestIds(
->setMaxResults($numberOfArticles)
->getQuery()
->getSingleColumnResult()
);
));
}

public function findByUrl(string $url): ?Article
Expand Down

0 comments on commit d6fa8da

Please sign in to comment.