From 7314c16bdf85ec5575c444303b17ea0c046f680e Mon Sep 17 00:00:00 2001 From: Jeremiah VALERIE Date: Fri, 22 Nov 2024 10:56:42 +0100 Subject: [PATCH] Fix CS --- .gitignore | 10 +++-- .php-cs-fixer.dist.php | 42 +++++++++++++++++++ .php_cs.dist | 23 ---------- composer.json | 2 +- .../GraphQLEndpointInvalidSchemaException.php | 6 ++- .../OverblogGraphQLBundleEndpointResolver.php | 2 + src/Config/GraphQLEndpoint/RootResolver.php | 2 + src/Config/GraphQLEndpoint/RouteResolver.php | 2 + src/Config/GraphiQLControllerEndpoint.php | 2 + src/Config/GraphiQLViewConfig.php | 2 + .../GraphiQLViewJavaScriptLibraries.php | 2 + src/Controller/GraphiQLController.php | 2 + .../Endpoints/DefaultEndpointWiringPass.php | 6 ++- ...verblogGraphQLBundleEndpointWiringPass.php | 4 +- src/DependencyInjection/Configuration.php | 6 ++- .../OverblogGraphiQLExtension.php | 2 + src/OverblogGraphiQLBundle.php | 2 + ...rblogGraphQLBundleEndpointResolverTest.php | 6 ++- .../GraphQLEndpoint/RootResolverTest.php | 6 ++- .../GraphQLEndpoint/RouteResolverTest.php | 6 ++- tests/Controller/GraphiQLControllerTest.php | 2 + tests/Fixtures/TestKernel.php | 6 ++- tests/ForwardCompatTestCaseTrait.php | 9 +++- .../Fixtures/Xml/TestKernel.php | 6 ++- .../Fixtures/Yaml/TestKernel.php | 4 +- .../Xml/ConfigurationTest.php | 4 +- .../Yaml/ConfigurationTest.php | 4 +- .../Controller/GraphiQLControllerTest.php | 4 +- .../Fixtures/TestKernel.php | 6 ++- .../OverblogGraphQLBundle/TestCase.php | 2 + tests/TestCase.php | 8 ++-- tests/TestKernel.php | 2 + 32 files changed, 138 insertions(+), 54 deletions(-) create mode 100644 .php-cs-fixer.dist.php delete mode 100644 .php_cs.dist diff --git a/.gitignore b/.gitignore index f89622e..6c753cc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,13 @@ -.idea phpunit.xml /build /vendor /bin composer.lock composer.phar -.php_cs.cache -.php_cs +/.php-cs-fixer.php +/*.cache + +phpbench.phar +phpbench.phar.* +/.phpbench_storage php-cs-fixer.phar -/.phpunit.result.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..cc64d4b --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,42 @@ +exclude('Annotation') + ->name('*.php') + ->in([__DIR__.'/src', __DIR__.'/tests']) +; + +return (new PhpCsFixer\Config()) + ->setRules( + [ + '@Symfony' => true, + '@PHP80Migration' => true, + '@PHP80Migration:risky' => true, + 'ordered_imports' => ['imports_order' => ['class', 'function', 'const']], + 'general_phpdoc_annotation_remove' => [ + 'annotations' => [ + 'author', + 'category', + 'copyright', + 'created', + 'license', + 'package', + 'since', + 'subpackage', + 'version', + ], + ], + 'fully_qualified_strict_types' => true, + 'single_line_throw' => false, + 'phpdoc_to_comment' => false, + 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], + 'global_namespace_import' => ['import_functions' => true, 'import_classes' => true, 'import_constants' => true], + 'phpdoc_summary' => false, + 'single_line_comment_style' => false, + 'phpdoc_no_alias_tag' => ['replacements' => ['type' => 'var']], + 'no_mixed_echo_print' => ['use' => 'echo'], + ] + ) + ->setFinder($finder) + ->setUsingCache(true) + ; diff --git a/.php_cs.dist b/.php_cs.dist deleted file mode 100644 index 1c2bebd..0000000 --- a/.php_cs.dist +++ /dev/null @@ -1,23 +0,0 @@ -exclude('vendor') - ->name('*.php') - ->in(__DIR__) -; - -return PhpCsFixer\Config::create() - ->setRules( - [ - '@Symfony' => true, - 'single_blank_line_before_namespace' => true, - 'ordered_imports' => true, - 'concat_space' => ['spacing' => 'none'], - 'phpdoc_no_alias_tag' => ['type' => 'var'], - 'no_mixed_echo_print' => ['use' => 'echo'], - 'binary_operator_spaces' => ['align_double_arrow' => false, 'align_equals' => false], - ] - ) - ->setFinder($finder) - ->setUsingCache(true) -; diff --git a/composer.json b/composer.json index a7c57cf..2a5c2ec 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,7 @@ }, "scripts": { "test": "bin/phpunit --color=always", - "install-cs": "test -f php-cs-fixer.phar || wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.18.7/php-cs-fixer.phar -O php-cs-fixer.phar", + "install-cs": "test -f php-cs-fixer.phar || wget https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v3.48.0/php-cs-fixer.phar -O php-cs-fixer.phar", "fix-cs": [ "@install-cs", "@php php-cs-fixer.phar fix --diff -v --allow-risky=yes --ansi" diff --git a/src/Config/GraphQLEndpoint/GraphQLEndpointInvalidSchemaException.php b/src/Config/GraphQLEndpoint/GraphQLEndpointInvalidSchemaException.php index d31c410..71f7f84 100644 --- a/src/Config/GraphQLEndpoint/GraphQLEndpointInvalidSchemaException.php +++ b/src/Config/GraphQLEndpoint/GraphQLEndpointInvalidSchemaException.php @@ -1,8 +1,12 @@ getDefinition('overblog_graphiql.controller.graphql.endpoint'); diff --git a/src/DependencyInjection/Compiler/Endpoints/OverblogGraphQLBundleEndpointWiringPass.php b/src/DependencyInjection/Compiler/Endpoints/OverblogGraphQLBundleEndpointWiringPass.php index 693f7b5..187a84a 100644 --- a/src/DependencyInjection/Compiler/Endpoints/OverblogGraphQLBundleEndpointWiringPass.php +++ b/src/DependencyInjection/Compiler/Endpoints/OverblogGraphQLBundleEndpointWiringPass.php @@ -1,5 +1,7 @@ getParameter('kernel.bundles_metadata'); diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 881710a..04c7e58 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -1,5 +1,7 @@ getRootNode() : $builder->root($name, $type); + return method_exists($builder, 'getRootNode') ? $builder->getRootNode() : $builder->root($name, $type); } } diff --git a/src/DependencyInjection/OverblogGraphiQLExtension.php b/src/DependencyInjection/OverblogGraphiQLExtension.php index 34f5cad..06cfb5b 100644 --- a/src/DependencyInjection/OverblogGraphiQLExtension.php +++ b/src/DependencyInjection/OverblogGraphiQLExtension.php @@ -1,5 +1,7 @@ assertSame(['overblog_graphql_endpoint'], $defaultRoute); @@ -16,7 +18,7 @@ public function testGetDefaultRoute() /** * @dataProvider getSchemas */ - public function testGetWithSchemaName($schemaName, $expectedResult) + public function testGetWithSchemaName($schemaName, $expectedResult): void { $route = OverblogGraphQLBundleEndpointResolver::getByName($schemaName); $this->assertSame($expectedResult, $route); diff --git a/tests/Config/GraphQLEndpoint/RootResolverTest.php b/tests/Config/GraphQLEndpoint/RootResolverTest.php index c4c8758..2082111 100644 --- a/tests/Config/GraphQLEndpoint/RootResolverTest.php +++ b/tests/Config/GraphQLEndpoint/RootResolverTest.php @@ -1,5 +1,7 @@ subject(); @@ -26,7 +28,7 @@ public function testInvalidSchema() $rootResolver->getBySchema('any'); } - public function testDefaultSchema() + public function testDefaultSchema(): void { $rootResolver = $this->subject(); diff --git a/tests/Config/GraphQLEndpoint/RouteResolverTest.php b/tests/Config/GraphQLEndpoint/RouteResolverTest.php index ad98fcb..05619ba 100644 --- a/tests/Config/GraphQLEndpoint/RouteResolverTest.php +++ b/tests/Config/GraphQLEndpoint/RouteResolverTest.php @@ -1,5 +1,7 @@ subject([]); @@ -39,7 +41,7 @@ public function testInvalidRoute() $routeResolver->getDefault(); } - public function testArrayRoutes() + public function testArrayRoutes(): void { $this->router->expects($this->exactly(3)) ->method('generate') diff --git a/tests/Controller/GraphiQLControllerTest.php b/tests/Controller/GraphiQLControllerTest.php index 2a6674a..c51d656 100644 --- a/tests/Controller/GraphiQLControllerTest.php +++ b/tests/Controller/GraphiQLControllerTest.php @@ -1,5 +1,7 @@ load(function (ContainerBuilder $container) { + $loader->load(function (ContainerBuilder $container): void { $container->loadFromExtension('framework', [ 'secret' => 'test', 'test' => true, diff --git a/tests/ForwardCompatTestCaseTrait.php b/tests/ForwardCompatTestCaseTrait.php index d0e3a69..be586c2 100644 --- a/tests/ForwardCompatTestCaseTrait.php +++ b/tests/ForwardCompatTestCaseTrait.php @@ -1,12 +1,17 @@ hasReturnType()) { +if (70000 <= PHP_VERSION_ID && (new ReflectionMethod(WebTestCase::class, 'tearDown'))->hasReturnType()) { eval(' namespace Overblog\GraphiQLBundle\Tests; @@ -28,7 +33,7 @@ protected function tearDown(): void */ trait ForwardCompatTestCaseTrait { - protected function tearDown() + protected function tearDown(): void { static::ensureKernelShutdown(); static::$kernel = null; diff --git a/tests/Functional/DependencyInjection/Fixtures/Xml/TestKernel.php b/tests/Functional/DependencyInjection/Fixtures/Xml/TestKernel.php index 474af49..e18de37 100644 --- a/tests/Functional/DependencyInjection/Fixtures/Xml/TestKernel.php +++ b/tests/Functional/DependencyInjection/Fixtures/Xml/TestKernel.php @@ -1,5 +1,7 @@ load(__DIR__.'/config.xml'); - $loader->load(function (ContainerBuilder $container) { + $loader->load(function (ContainerBuilder $container): void { $container->loadFromExtension('framework', [ 'assets' => ['enabled' => false], ]); diff --git a/tests/Functional/DependencyInjection/Fixtures/Yaml/TestKernel.php b/tests/Functional/DependencyInjection/Fixtures/Yaml/TestKernel.php index 318ae48..f8f0b53 100644 --- a/tests/Functional/DependencyInjection/Fixtures/Yaml/TestKernel.php +++ b/tests/Functional/DependencyInjection/Fixtures/Yaml/TestKernel.php @@ -1,5 +1,7 @@ load(__DIR__.'/config.yml'); } diff --git a/tests/Functional/DependencyInjection/Xml/ConfigurationTest.php b/tests/Functional/DependencyInjection/Xml/ConfigurationTest.php index 2beb978..b564b8c 100644 --- a/tests/Functional/DependencyInjection/Xml/ConfigurationTest.php +++ b/tests/Functional/DependencyInjection/Xml/ConfigurationTest.php @@ -1,5 +1,7 @@ str_replace('\\', '_', __NAMESPACE__)]); } - public function testSuccessConfiguration() + public function testSuccessConfiguration(): void { /** @var TestKernel $kernel */ $kernel = static::$kernel; diff --git a/tests/Functional/DependencyInjection/Yaml/ConfigurationTest.php b/tests/Functional/DependencyInjection/Yaml/ConfigurationTest.php index 5e89c27..d43026c 100644 --- a/tests/Functional/DependencyInjection/Yaml/ConfigurationTest.php +++ b/tests/Functional/DependencyInjection/Yaml/ConfigurationTest.php @@ -1,5 +1,7 @@ str_replace('\\', '_', __NAMESPACE__)]); } - public function testSuccessConfiguration() + public function testSuccessConfiguration(): void { /** @var TestKernel $kernel */ $kernel = static::$kernel; diff --git a/tests/Integration/OverblogGraphQLBundle/Controller/GraphiQLControllerTest.php b/tests/Integration/OverblogGraphQLBundle/Controller/GraphiQLControllerTest.php index 61be264..a7ff443 100644 --- a/tests/Integration/OverblogGraphQLBundle/Controller/GraphiQLControllerTest.php +++ b/tests/Integration/OverblogGraphQLBundle/Controller/GraphiQLControllerTest.php @@ -1,5 +1,7 @@ load(function (ContainerBuilder $container) { + $loader->load(function (ContainerBuilder $container): void { $container->loadFromExtension('framework', [ 'secret' => 'test', 'test' => true, diff --git a/tests/Integration/OverblogGraphQLBundle/TestCase.php b/tests/Integration/OverblogGraphQLBundle/TestCase.php index a30ad28..a6c8482 100644 --- a/tests/Integration/OverblogGraphQLBundle/TestCase.php +++ b/tests/Integration/OverblogGraphQLBundle/TestCase.php @@ -1,5 +1,7 @@