Skip to content

Commit f540217

Browse files
authored
style: use cdn77/coding-standard (#179)
1 parent e8a2f6a commit f540217

13 files changed

+30
-25
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"webonyx/graphql-php": "^15.4"
2323
},
2424
"require-dev": {
25-
"doctrine/coding-standard": "^12.0",
25+
"cdn77/coding-standard": "^7.4",
2626
"infection/infection": "^0.30.0",
2727
"phpstan/extension-installer": "^1.1",
2828
"phpstan/phpstan": "^2.0",

phpcs.xml.dist

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,5 @@
1414
<file>src</file>
1515
<file>tests</file>
1616

17-
<rule ref="Doctrine">
18-
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification" />
19-
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" />
20-
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
21-
</rule>
17+
<rule ref="Cdn77" />
2218
</ruleset>

src/Builder/ObjectBuilder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ public function addField(FieldDefinition|array $field): self
6868
{
6969
if (is_callable($this->fields)) {
7070
$originalFields = $this->fields;
71-
$closure = static function () use ($field, $originalFields): array {
72-
$originalFields = $originalFields();
71+
$closure = static function () use ($field, $originalFields): array {
72+
$originalFields = $originalFields();
7373
$originalFields[] = $field;
7474

7575
return $originalFields;
7676
};
77-
$this->fields = $closure;
77+
$this->fields = $closure;
7878
} else {
7979
$this->fields[] = $field;
8080
}

src/Builder/TypeBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
abstract class TypeBuilder
88
{
9-
public const VALID_NAME_PATTERN = '~^[_a-zA-Z][_a-zA-Z0-9]*$~';
9+
// phpcs:ignore Cdn77.NamingConventions.ValidConstantName.ClassConstantNotUpperCase
10+
public const string VALID_NAME_PATTERN = '~^[_a-zA-Z][_a-zA-Z0-9]*$~';
1011

1112
protected string|null $description = null;
1213

src/Error/FormattedError.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
/** @deprecated Use {@see ProvidesExtensions} */
1111
class FormattedError extends \GraphQL\Error\FormattedError
1212
{
13-
public static function createFromException(Throwable $exception, int $debugFlag = DebugFlag::NONE, string|null $internalErrorMessage = null): array
14-
{
13+
public static function createFromException(
14+
Throwable $exception,
15+
int $debugFlag = DebugFlag::NONE,
16+
string|null $internalErrorMessage = null,
17+
): array {
1518
$arrayError = parent::createFromException($exception, $debugFlag, $internalErrorMessage);
1619

1720
if ($exception instanceof \GraphQL\Error\Error && $exception->getPrevious() instanceof Error) {

src/Exception/InvalidArgument.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ private function __construct(string $message = '', int $code = 0, Throwable|null
2121

2222
public static function invalidNameFormat(string $invalidName): self
2323
{
24-
return new self(sprintf('Name "%s" does not match pattern "%s"', $invalidName, TypeBuilder::VALID_NAME_PATTERN));
24+
return new self(sprintf(
25+
'Name "%s" does not match pattern "%s"',
26+
$invalidName,
27+
TypeBuilder::VALID_NAME_PATTERN,
28+
));
2529
}
2630

2731
public static function valueNotIso8601Compliant(mixed $invalidValue): self

tests/Builder/EnumBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function testCreate(): void
1818
$name = 'SomeEnum';
1919

2020
$builder = EnumBuilder::create($name);
21-
$object = $builder
21+
$object = $builder
2222
->addValue('Value1', 'EnumName')
2323
->addValue('Value2', null, 'Value 2 Description')
2424
->addValue(0, 'Numeric', 'Value 2 Description')

tests/Builder/FieldBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testCreate(): void
3232
self::assertIsCallable($field['resolve']);
3333

3434
$resolveInfoReflection = new ReflectionClass(ResolveInfo::class);
35-
$resolveInfo = $resolveInfoReflection->newInstanceWithoutConstructor();
35+
$resolveInfo = $resolveInfoReflection->newInstanceWithoutConstructor();
3636

3737
self::assertSame('Resolver result', $field['resolve'](null, [], null, $resolveInfo));
3838

tests/Builder/InputObjectBuilderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ final class InputObjectBuilderTest extends TestCase
1717
public function testCreate(): void
1818
{
1919
$description = 'To the sichuan-style nachos add ghee, noodles, buttermilk and heated herring.';
20-
$name = 'SomeType';
21-
$interface = new class () extends InterfaceType {
20+
$name = 'SomeType';
21+
$interface = new class () extends InterfaceType {
2222
public function __construct()
2323
{
2424
$builder = InterfaceBuilder::create('InterfaceA');
@@ -31,7 +31,7 @@ public function __construct()
3131
};
3232

3333
$builder = InputObjectBuilder::create($name);
34-
$object = $builder
34+
$object = $builder
3535
->setDescription($description)
3636
->setFields(
3737
[

tests/Builder/InterfaceBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class InterfaceBuilderTest extends TestCase
1818
{
1919
public function testCreate(): void
2020
{
21-
$name = 'InterfaceA';
21+
$name = 'InterfaceA';
2222
$description = 'Description';
2323

2424
$interfaceA = new class () extends InterfaceType {

0 commit comments

Comments
 (0)