From 7bf5085e72788bee22694da480ebd6880d3522e3 Mon Sep 17 00:00:00 2001 From: Timur Murtukov Date: Sat, 30 Jan 2021 15:56:11 +0100 Subject: [PATCH] Update PHPStan version and fix new errors --- composer.json | 2 +- src/DependencyInjection/Compiler/ConfigParserPass.php | 5 ++++- .../Compiler/ResolverMapTaggedServiceMappingPass.php | 4 +++- src/DependencyInjection/OverblogGraphQLExtension.php | 8 +++++--- tests/Functional/App/IsolatedResolver/EchoQuery.php | 1 + 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 14fa5734f..8ebaa2926 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "require-dev": { "doctrine/orm": "^2.5", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12.32", + "phpstan/phpstan": "^0.12.58", "phpstan/phpstan-phpunit": "^0.12.11", "phpstan/phpstan-symfony": "^0.12.6", "phpunit/phpunit": "^9.2", diff --git a/src/DependencyInjection/Compiler/ConfigParserPass.php b/src/DependencyInjection/Compiler/ConfigParserPass.php index 6579a71cd..2750b5baa 100644 --- a/src/DependencyInjection/Compiler/ConfigParserPass.php +++ b/src/DependencyInjection/Compiler/ConfigParserPass.php @@ -177,6 +177,7 @@ private function mappingConfig(array $config, ContainerBuilder $container): arra // app only config files (yml or xml or graphql) if ($mappingConfig['auto_discover']['root_dir'] && $container->hasParameter('kernel.root_dir')) { + // @phpstan-ignore-next-line $typesMappings[] = ['dir' => $container->getParameter('kernel.root_dir').'/config/graphql', 'types' => null]; } if ($mappingConfig['auto_discover']['bundles']) { @@ -212,10 +213,12 @@ function (array $typeMapping) use ($container) { private function mappingFromBundles(ContainerBuilder $container): array { $typesMappings = []; + + /** @var array $bundles */ $bundles = $container->getParameter('kernel.bundles'); // auto detect from bundle - foreach ($bundles as $name => $class) { + foreach ($bundles as $class) { // skip this bundle if (OverblogGraphQLBundle::class === $class) { continue; diff --git a/src/DependencyInjection/Compiler/ResolverMapTaggedServiceMappingPass.php b/src/DependencyInjection/Compiler/ResolverMapTaggedServiceMappingPass.php index 44ffcfa7c..49423b042 100644 --- a/src/DependencyInjection/Compiler/ResolverMapTaggedServiceMappingPass.php +++ b/src/DependencyInjection/Compiler/ResolverMapTaggedServiceMappingPass.php @@ -25,9 +25,11 @@ final class ResolverMapTaggedServiceMappingPass implements CompilerPassInterface public function process(ContainerBuilder $container): void { $resolverMapsSortedBySchema = []; - $resolverMapsBySchemas = $container->getParameter('overblog_graphql.resolver_maps'); $typeDecoratorListenerDefinition = $container->getDefinition(TypeDecoratorListener::class); + /** @var array $resolverMapsBySchemas */ + $resolverMapsBySchemas = $container->getParameter('overblog_graphql.resolver_maps'); + foreach ($container->findTaggedServiceIds(self::SERVICE_TAG, true) as $serviceId => $tags) { foreach ($tags as $tag) { if (!isset($tag['schema'])) { diff --git a/src/DependencyInjection/OverblogGraphQLExtension.php b/src/DependencyInjection/OverblogGraphQLExtension.php index 1d391e814..93c3b7038 100644 --- a/src/DependencyInjection/OverblogGraphQLExtension.php +++ b/src/DependencyInjection/OverblogGraphQLExtension.php @@ -65,15 +65,17 @@ public function load(array $configs, ContainerBuilder $container): void $container->setParameter($this->getAlias().'.resources_dir', realpath(__DIR__.'/../Resources')); } - public function getAlias() + public function getAlias(): string { return Configuration::NAME; } - public function getConfiguration(array $config, ContainerBuilder $container) + public function getConfiguration(array $config, ContainerBuilder $container): Configuration { return new Configuration( + // @phpstan-ignore-next-line $container->getParameter('kernel.debug'), + // @phpstan-ignore-next-line $container->hasParameter('kernel.cache_dir') ? $container->getParameter('kernel.cache_dir') : null ); } @@ -295,7 +297,7 @@ private function setServicesAliases(array $config, ContainerBuilder $container): /** * Returns a list of custom exceptions mapped to error/warning classes. * - * @param array $exceptionConfig + * @param array> $exceptionConfig * * @return array Custom exception map, [exception => UserError/UserWarning] */ diff --git a/tests/Functional/App/IsolatedResolver/EchoQuery.php b/tests/Functional/App/IsolatedResolver/EchoQuery.php index 250ca43ec..6a7b1d6fc 100644 --- a/tests/Functional/App/IsolatedResolver/EchoQuery.php +++ b/tests/Functional/App/IsolatedResolver/EchoQuery.php @@ -14,6 +14,7 @@ final class EchoQuery implements QueryInterface, ContainerAwareInterface public function display(string $message): string { + // @phpstan-ignore-next-line return $this->container->getParameter('echo.prefix').$message; } }