Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
mcg-web committed Nov 22, 2024
1 parent 2327323 commit 7314c16
Show file tree
Hide file tree
Showing 32 changed files with 138 additions and 54 deletions.
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

$finder = PhpCsFixer\Finder::create()
->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)
;
23 changes: 0 additions & 23 deletions .php_cs.dist

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Config\GraphQLEndpoint;

class GraphQLEndpointInvalidSchemaException extends \RuntimeException
use RuntimeException;

class GraphQLEndpointInvalidSchemaException extends RuntimeException
{
public static function forSchemaAndResolver($schemaName, $resolverClass)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Config\GraphQLEndpoint\Helpers;

final class OverblogGraphQLBundleEndpointResolver
Expand Down
2 changes: 2 additions & 0 deletions src/Config/GraphQLEndpoint/RootResolver.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Config\GraphQLEndpoint;

use Overblog\GraphiQLBundle\Config\GraphiQLControllerEndpoint;
Expand Down
2 changes: 2 additions & 0 deletions src/Config/GraphQLEndpoint/RouteResolver.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Config\GraphQLEndpoint;

use Overblog\GraphiQLBundle\Config\GraphiQLControllerEndpoint;
Expand Down
2 changes: 2 additions & 0 deletions src/Config/GraphiQLControllerEndpoint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Config;

interface GraphiQLControllerEndpoint
Expand Down
2 changes: 2 additions & 0 deletions src/Config/GraphiQLViewConfig.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Config;

final class GraphiQLViewConfig
Expand Down
2 changes: 2 additions & 0 deletions src/Config/GraphiQLViewJavaScriptLibraries.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Config;

final class GraphiQLViewJavaScriptLibraries
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/GraphiQLController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Controller;

use Overblog\GraphiQLBundle\Config\GraphiQLControllerEndpoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\DependencyInjection\Compiler\Endpoints;

use Overblog\GraphiQLBundle\Config\GraphiQLControllerEndpoint;
Expand All @@ -9,8 +11,8 @@

final class DefaultEndpointWiringPass implements CompilerPassInterface
{
//@todo https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php
public function process(ContainerBuilder $container)
// @todo https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php
public function process(ContainerBuilder $container): void
{
$endpointDefinition = $container->getDefinition('overblog_graphiql.controller.graphql.endpoint');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\DependencyInjection\Compiler\Endpoints;

use Overblog\GraphiQLBundle\Config\GraphQLEndpoint\RouteResolver;
Expand All @@ -9,7 +11,7 @@

final class OverblogGraphQLBundleEndpointWiringPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$bundles = $container->getParameter('kernel.bundles_metadata');

Expand Down
6 changes: 5 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\DependencyInjection;

use Overblog\GraphiQLBundle\Config\GraphQLEndpoint\Helpers\OverblogGraphQLBundleEndpointResolver;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

use function method_exists;

final class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
Expand Down Expand Up @@ -47,6 +51,6 @@ public function getConfigTreeBuilder(): TreeBuilder
private static function getRootNodeWithoutDeprecation(TreeBuilder $builder, $name, $type = 'array')
{
// BC layer for symfony/config 4.1 and older
return \method_exists($builder, 'getRootNode') ? $builder->getRootNode() : $builder->root($name, $type);
return method_exists($builder, 'getRootNode') ? $builder->getRootNode() : $builder->root($name, $type);
}
}
2 changes: 2 additions & 0 deletions src/DependencyInjection/OverblogGraphiQLExtension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
Expand Down
2 changes: 2 additions & 0 deletions src/OverblogGraphiQLBundle.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle;

use Overblog\GraphiQLBundle\DependencyInjection\Compiler\Endpoints\DefaultEndpointWiringPass;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Tests\Config\GraphQLEndpoint\Helpers;

use Overblog\GraphiQLBundle\Config\GraphQLEndpoint\Helpers\OverblogGraphQLBundleEndpointResolver;
use PHPUnit\Framework\TestCase;

final class OverblogGraphQLBundleEndpointResolverTest extends TestCase
{
public function testGetDefaultRoute()
public function testGetDefaultRoute(): void
{
$defaultRoute = OverblogGraphQLBundleEndpointResolver::getByName('default');
$this->assertSame(['overblog_graphql_endpoint'], $defaultRoute);
Expand All @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions tests/Config/GraphQLEndpoint/RootResolverTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Tests\Config\GraphQLEndpoint;

use Overblog\GraphiQLBundle\Config\GraphQLEndpoint\GraphQLEndpointInvalidSchemaException;
Expand All @@ -16,7 +18,7 @@ private function subject()
return new RootResolver();
}

public function testInvalidSchema()
public function testInvalidSchema(): void
{
$rootResolver = $this->subject();

Expand All @@ -26,7 +28,7 @@ public function testInvalidSchema()
$rootResolver->getBySchema('any');
}

public function testDefaultSchema()
public function testDefaultSchema(): void
{
$rootResolver = $this->subject();

Expand Down
6 changes: 4 additions & 2 deletions tests/Config/GraphQLEndpoint/RouteResolverTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Tests\Config\GraphQLEndpoint;

use Overblog\GraphiQLBundle\Config\GraphQLEndpoint\GraphQLEndpointInvalidSchemaException;
Expand Down Expand Up @@ -29,7 +31,7 @@ private function subject(array $routeCollection)
);
}

public function testInvalidRoute()
public function testInvalidRoute(): void
{
$routeResolver = $this->subject([]);

Expand All @@ -39,7 +41,7 @@ public function testInvalidRoute()
$routeResolver->getDefault();
}

public function testArrayRoutes()
public function testArrayRoutes(): void
{
$this->router->expects($this->exactly(3))
->method('generate')
Expand Down
2 changes: 2 additions & 0 deletions tests/Controller/GraphiQLControllerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphQLBundle\Tests\Controller;

use Overblog\GraphiQLBundle\Tests\TestCase;
Expand Down
6 changes: 4 additions & 2 deletions tests/Fixtures/TestKernel.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Tests\Fixtures;

use Overblog\GraphiQLBundle\OverblogGraphiQLBundle;
Expand All @@ -23,9 +25,9 @@ public function registerBundles(): array
/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(function (ContainerBuilder $container) {
$loader->load(function (ContainerBuilder $container): void {
$container->loadFromExtension('framework', [
'secret' => 'test',
'test' => true,
Expand Down
9 changes: 7 additions & 2 deletions tests/ForwardCompatTestCaseTrait.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Tests;

use ReflectionMethod;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

use const PHP_VERSION_ID;

// see https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Tests/Functional/ForwardCompatTestCaseTrait.php

if (70000 <= \PHP_VERSION_ID && (new \ReflectionMethod(WebTestCase::class, 'tearDown'))->hasReturnType()) {
if (70000 <= PHP_VERSION_ID && (new ReflectionMethod(WebTestCase::class, 'tearDown'))->hasReturnType()) {
eval('
namespace Overblog\GraphiQLBundle\Tests;
Expand All @@ -28,7 +33,7 @@ protected function tearDown(): void
*/
trait ForwardCompatTestCaseTrait
{
protected function tearDown()
protected function tearDown(): void
{
static::ensureKernelShutdown();
static::$kernel = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Tests\Functional\DependencyInjection\Fixtures\Xml;

use Overblog\GraphiQLBundle\OverblogGraphiQLBundle;
Expand All @@ -23,10 +25,10 @@ public function registerBundles(): array
/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__.'/config.xml');
$loader->load(function (ContainerBuilder $container) {
$loader->load(function (ContainerBuilder $container): void {
$container->loadFromExtension('framework', [
'assets' => ['enabled' => false],
]);
Expand Down
Loading

0 comments on commit 7314c16

Please sign in to comment.