diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3152a1..b15bef1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,32 +1,51 @@ name: CI on: - pull_request: - branches: - - "*.*" - - master + pull_request: null push: branches: - "*.*" - - master + - "master" + schedule: + - cron: "0 4 * * *" jobs: tests: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: php-version: - '8.0' - '8.1' + - '8.2' + - '8.3' + - '8.4' symfony-version: - - '5.3.*' - '5.4.*' - '6.0.*' + - '6.2.*' + - '6.4.*' + - '7.0.*' + - '7.1.*' dependencies: - 'lowest' - 'highest' remove-dependencies: [ '' ] + coverage: [ 'none' ] + exclude: + - php-version: '8.0' + symfony-version: '6.2.*' + - php-version: '8.0' + symfony-version: '6.4.*' + - php-version: '8.0' + symfony-version: '7.0.*' + - php-version: '8.0' + symfony-version: '7.1.*' + - php-version: '8.1' + symfony-version: '7.0.*' + - php-version: '8.1' + symfony-version: '7.1.*' steps: - name: "Checkout" uses: "actions/checkout@v2" @@ -61,20 +80,21 @@ jobs: run: composer test coding-standard: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 name: Coding Standard steps: - name: "Checkout" - uses: "actions/checkout@v2" + uses: "actions/checkout@v4" - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: tools: flex - php-version: "8.0" + php-version: "8.2" + coverage: "none" - name: "Install dependencies" - uses: ramsey/composer-install@1.3.0 + uses: "ramsey/composer-install@v2" - name: "Check coding standard" - run: composer check-cs + run: composer run check-cs 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 3a636b2..2a5c2ec 100644 --- a/composer.json +++ b/composer.json @@ -22,24 +22,24 @@ }, "require": { "php": "^8.0", - "symfony/http-foundation": "^5.3.7 || ^6.0 || ^7.0", - "symfony/twig-bundle": "^5.3.7 || ^6.0 || ^7.0", - "symfony/routing": "^5.3.7 || ^6.0 || ^7.00" + "symfony/http-foundation": "^5.4 || ^6.0 || ^7.0", + "symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0", + "symfony/routing": "^5.4 || ^6.0 || ^7.00" }, "require-dev": { "overblog/graphql-bundle": "dev-master", "webonyx/graphql-php": "^15.4", "phpunit/phpunit": "^9.5.10", - "symfony/browser-kit": "^5.3 || ^6.0 || ^7.0", - "symfony/config": "^5.3.7 || ^6.0 || ^7.0", - "symfony/console": "^5.3.7 || ^6.0 || ^7.0", - "symfony/dependency-injection": "^5.3.7 || ^6.0 || ^7.0", - "symfony/dom-crawler": "^5.3.7 || ^6.0 || ^7.0", - "symfony/expression-language": "^5.3.7 || ^6.0 || ^7.0", - "symfony/framework-bundle": "^5.3.7 || ^6.0 || ^7.0", - "symfony/finder": "^5.3.7 || ^6.0 || ^7.0", - "symfony/templating": "^5.3.7 || ^6.0 || ^7.0", - "symfony/yaml": "^5.3.7 || ^6.0 || ^7.0", + "symfony/browser-kit": "^5.4 || ^6.0 || ^7.0", + "symfony/config": "^5.4 || ^6.0 || ^7.0", + "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", + "symfony/dom-crawler": "^5.4 || ^6.0 || ^7.0", + "symfony/expression-language": "^5.4 || ^6.0 || ^7.0", + "symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0", + "symfony/finder": "^5.4 || ^6.0 || ^7.0", + "symfony/templating": "^5.4 || ^6.0 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0", "twig/twig": "^3.3.3" }, "autoload": { @@ -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..3d2c2d4 100644 --- a/tests/Controller/GraphiQLControllerTest.php +++ b/tests/Controller/GraphiQLControllerTest.php @@ -1,5 +1,7 @@ assertInstanceOf(Response::class, $response); $this->assertSame(200, $response->getStatusCode(), $response->getContent()); - $this->stringContains('Loading...', $response->getContent()); + $this->assertStringContainsString('Loading...', $response->getContent()); } public function testDefaultSchemaViaMultipleRoute(): void @@ -39,6 +41,6 @@ public function testDefaultSchemaViaMultipleRoute(): void $this->assertInstanceOf(Response::class, $response); $this->assertSame(200, $response->getStatusCode()); - $this->stringContains('Loading...', $response->getContent()); + $this->assertStringContainsString('Loading...', $response->getContent()); } } diff --git a/tests/Fixtures/TestKernel.php b/tests/Fixtures/TestKernel.php index b5845ad..414dbbe 100644 --- a/tests/Fixtures/TestKernel.php +++ b/tests/Fixtures/TestKernel.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..f59f810 100644 --- a/tests/Integration/OverblogGraphQLBundle/Controller/GraphiQLControllerTest.php +++ b/tests/Integration/OverblogGraphQLBundle/Controller/GraphiQLControllerTest.php @@ -1,5 +1,7 @@ assertInstanceOf(Response::class, $response); $this->assertSame(200, $response->getStatusCode()); - $this->stringContains('Loading...', $response->getContent()); - $this->stringContains('var endpoint = "\/"', $response->getContent()); + $this->assertStringContainsString('Loading...', $response->getContent()); + $this->assertStringContainsString('var endpoint = "\/"', $response->getContent()); } } diff --git a/tests/Integration/OverblogGraphQLBundle/Fixtures/TestKernel.php b/tests/Integration/OverblogGraphQLBundle/Fixtures/TestKernel.php index 7e04183..17608bb 100644 --- a/tests/Integration/OverblogGraphQLBundle/Fixtures/TestKernel.php +++ b/tests/Integration/OverblogGraphQLBundle/Fixtures/TestKernel.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 @@