Skip to content

Commit 751b2f8

Browse files
author
Jeremiah VALERIE
committed
Merge branch 'simplyfy_phpcs'
2 parents 4f56698 + 5ed5756 commit 751b2f8

31 files changed

+175
-167
lines changed

.php_cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
use Symfony\CS\Config\Config;
13-
use Symfony\CS\Finder\DefaultFinder;
14-
use Symfony\CS\Fixer\Contrib\HeaderCommentFixer;
15-
use Symfony\CS\FixerInterface;
12+
require_once __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php';
1613

17-
$finder = DefaultFinder::create()
18-
->in(__DIR__)
19-
;
14+
use SLLH\StyleCIBridge\ConfigBridge;
15+
use Symfony\CS\Fixer\Contrib\HeaderCommentFixer;
2016

2117
$header = <<<EOF
2218
This file is part of the OverblogGraphQLBundle package.
@@ -27,11 +23,21 @@ For the full copyright and license information, please view the LICENSE
2723
file that was distributed with this source code.
2824
EOF;
2925

30-
HeaderCommentFixer::setHeader($header);
26+
// PHP-CS-Fixer 1.x
27+
if (method_exists('Symfony\CS\Fixer\Contrib\HeaderCommentFixer', 'getHeader')) {
28+
HeaderCommentFixer::setHeader($header);
29+
}
3130

32-
return Config::create()
33-
->level(FixerInterface::SYMFONY_LEVEL)
34-
->fixers(['align_double_arrow', 'header_comment'])
35-
->finder($finder)
36-
->setUsingCache(true)
37-
;
31+
$config = ConfigBridge::create();
32+
33+
// PHP-CS-Fixer 2.x
34+
if (method_exists($config, 'setRules')) {
35+
$config->setRules(array_merge($config->getRules(), [
36+
'header_comment' => ['header' => $header]
37+
]));
38+
}
39+
40+
return $config
41+
->setUsingCache(true)
42+
->fixers(array_merge($config->getFixers(), ['header_comment']))
43+
;

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: symfony

Command/GraphDumpSchemaCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
3838
$output = new SymfonyStyle($input, $output);
3939

4040
$request = [
41-
'query' => Introspection::getIntrospectionQuery(false),
42-
'variables' => [],
41+
'query' => Introspection::getIntrospectionQuery(false),
42+
'variables' => [],
4343
'operationName' => null,
4444
];
4545

DependencyInjection/OverblogGraphQLExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ private function detectConfigFiles(ContainerBuilder $container, $configPath, $ty
203203
}
204204

205205
return [
206-
'type' => $type,
206+
'type' => $type,
207207
'files' => $finder,
208208
];
209209
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,5 +729,5 @@ vendor/phpunit/phpunit/phpunit
729729
Fix PHP CS:
730730

731731
```bash
732-
vendor/bin/php-cs-fixer fix ./ --level=symfony --fixers=header_comment,align_double_arrow
732+
vendor/bin/php-cs-fixer fix ./
733733
```

Relay/Connection/ConnectionType.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public function __construct(array $config)
3030
Utils::invariant(!empty($config['name']), 'Every type is expected to have name');
3131

3232
Config::validate($config, [
33-
'name' => Config::STRING | Config::REQUIRED,
34-
'nodeType' => Config::OBJECT_TYPE | Config::CALLBACK | Config::REQUIRED,
33+
'name' => Config::STRING | Config::REQUIRED,
34+
'nodeType' => Config::OBJECT_TYPE | Config::CALLBACK | Config::REQUIRED,
3535
'edgeFields' => Config::arrayOf(
3636
FieldDefinition::getDefinition(),
3737
Config::KEY_AS_NAME
@@ -41,7 +41,7 @@ public function __construct(array $config)
4141
Config::KEY_AS_NAME
4242
),
4343
'resolveCursor' => Config::CALLBACK,
44-
'resolveNode' => Config::CALLBACK,
44+
'resolveNode' => Config::CALLBACK,
4545
]);
4646

4747
if (!self::$pageInfoType instanceof PageInfoType) {
@@ -60,37 +60,37 @@ public function __construct(array $config)
6060
$resolveCursor = empty($config['resolveCursor']) ? null : $config['resolveCursor'];
6161

6262
$edgeType = new EdgeType([
63-
'name' => $name.'Edge',
63+
'name' => $name.'Edge',
6464
'description' => 'An edge in a connection.',
65-
'fields' => $this->getFieldsWithDefaults(
65+
'fields' => $this->getFieldsWithDefaults(
6666
$edgeFields,
6767
[
6868
'node' => [
69-
'type' => $nodeType,
70-
'resolve' => $resolveNode,
69+
'type' => $nodeType,
70+
'resolve' => $resolveNode,
7171
'description' => 'The item at the end of the edge.',
7272
],
7373
'cursor' => [
74-
'type' => Type::nonNull(Type::string()),
75-
'resolve' => $resolveCursor,
74+
'type' => Type::nonNull(Type::string()),
75+
'resolve' => $resolveCursor,
7676
'description' => 'A cursor for use in pagination.',
7777
],
7878
]
7979
),
8080
]);
8181

8282
parent::__construct([
83-
'name' => $name.'Connection',
83+
'name' => $name.'Connection',
8484
'description' => 'A connection to a list of items.',
85-
'fields' => $this->getFieldsWithDefaults(
85+
'fields' => $this->getFieldsWithDefaults(
8686
$connectionFields,
8787
[
8888
'pageInfo' => [
89-
'type' => Type::nonNull(self::$pageInfoType),
89+
'type' => Type::nonNull(self::$pageInfoType),
9090
'description' => 'Information to aid in pagination.',
9191
],
9292
'edges' => [
93-
'type' => Type::listOf($edgeType),
93+
'type' => Type::listOf($edgeType),
9494
'description' => 'Information to aid in pagination.',
9595
],
9696
]

Relay/Connection/Output/ConnectionBuilder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function connectionFromArray($data, $args = [])
3939
$data,
4040
$args,
4141
[
42-
'sliceStart' => 0,
42+
'sliceStart' => 0,
4343
'arrayLength' => count($data),
4444
]
4545
);
@@ -65,16 +65,16 @@ public static function connectionFromArraySlice($arraySlice, $args, array $meta)
6565
$connectionArguments = self::getOptionsWithDefaults(
6666
$args instanceof Argument ? $args->getRawArguments() : $args,
6767
[
68-
'after' => '',
68+
'after' => '',
6969
'before' => '',
70-
'first' => null,
71-
'last' => null,
70+
'first' => null,
71+
'last' => null,
7272
]
7373
);
7474
$arraySliceMetaInfo = self::getOptionsWithDefaults(
7575
$meta,
7676
[
77-
'sliceStart' => 0,
77+
'sliceStart' => 0,
7878
'arrayLength' => 0,
7979
]
8080
);

Relay/Connection/PageInfoType.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ class PageInfoType extends ObjectType
1919
public function __construct()
2020
{
2121
$config = [
22-
'name' => 'PageInfo',
22+
'name' => 'PageInfo',
2323
'description' => 'Information about pagination in a connection.',
24-
'fields' => [
24+
'fields' => [
2525
'hasNextPage' => [
26-
'type' => Type::nonNull(Type::boolean()),
26+
'type' => Type::nonNull(Type::boolean()),
2727
'description' => 'When paginating forwards, are there more items?',
2828
],
2929
'hasPreviousPage' => [
30-
'type' => Type::nonNull(Type::boolean()),
30+
'type' => Type::nonNull(Type::boolean()),
3131
'description' => 'When paginating backwards, are there more items?',
3232

3333
],
3434
'startCursor' => [
35-
'type' => Type::string(),
35+
'type' => Type::string(),
3636
'description' => 'When paginating backwards, the cursor to continue.',
3737
],
3838
'endCursor' => [
39-
'type' => Type::string(),
39+
'type' => Type::string(),
4040
'description' => 'When paginating forwards, the cursor to continue.',
4141
],
4242
],

Relay/Mutation/InputType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(array $config)
2727
Utils::invariant(!empty($config['name']), 'Every type is expected to have name');
2828

2929
Config::validate($config, [
30-
'name' => Config::STRING | Config::REQUIRED,
30+
'name' => Config::STRING | Config::REQUIRED,
3131
'fields' => Config::arrayOf(
3232
FieldDefinition::getDefinition(),
3333
Config::KEY_AS_NAME
@@ -51,8 +51,8 @@ public function __construct(array $config)
5151
}
5252

5353
parent::__construct([
54-
'name' => $name.'Input',
55-
'fields' => $augmentedInputFields,
54+
'name' => $name.'Input',
55+
'fields' => $augmentedInputFields,
5656
'description' => $description,
5757
]);
5858
}

Relay/Mutation/MutationField.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public function toFieldDefinition(array $config)
2626
Utils::invariant(!empty($config['name']), 'Every type is expected to have name');
2727

2828
Config::validate($config, [
29-
'name' => Config::STRING | Config::REQUIRED,
29+
'name' => Config::STRING | Config::REQUIRED,
3030
'mutateAndGetPayload' => Config::CALLBACK | Config::REQUIRED,
31-
'payloadType' => Config::OBJECT_TYPE | Config::CALLBACK | Config::REQUIRED,
32-
'inputType' => Config::INPUT_TYPE | Config::CALLBACK | Config::REQUIRED,
33-
'description' => Config::STRING,
31+
'payloadType' => Config::OBJECT_TYPE | Config::CALLBACK | Config::REQUIRED,
32+
'inputType' => Config::INPUT_TYPE | Config::CALLBACK | Config::REQUIRED,
33+
'description' => Config::STRING,
3434
]);
3535

3636
$name = $config['name'];
@@ -41,10 +41,10 @@ public function toFieldDefinition(array $config)
4141
$inputType = $config['inputType'];
4242

4343
return [
44-
'name' => $name,
44+
'name' => $name,
4545
'description' => $description,
46-
'type' => $payloadType,
47-
'args' => [
46+
'type' => $payloadType,
47+
'args' => [
4848
'input' => ['type' => Type::nonNull($inputType)],
4949
],
5050
'resolve' => function ($_, $input, $info) use ($mutateAndGetPayload, $name) {

0 commit comments

Comments
 (0)