Skip to content

style: use cdn77/coding-standard #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"webonyx/graphql-php": "^15.4"
},
"require-dev": {
"doctrine/coding-standard": "^12.0",
"cdn77/coding-standard": "^7.4",
"infection/infection": "^0.30.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^2.0",
Expand Down
6 changes: 1 addition & 5 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@
<file>src</file>
<file>tests</file>

<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
</rule>
<rule ref="Cdn77" />
</ruleset>
6 changes: 3 additions & 3 deletions src/Builder/ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@
{
if (is_callable($this->fields)) {
$originalFields = $this->fields;
$closure = static function () use ($field, $originalFields): array {
$originalFields = $originalFields();
$closure = static function () use ($field, $originalFields): array {
$originalFields = $originalFields();
$originalFields[] = $field;

return $originalFields;
};
$this->fields = $closure;
$this->fields = $closure;
} else {
$this->fields[] = $field;
}
Expand All @@ -100,7 +100,7 @@
return [
'name' => $this->name,
'description' => $this->description,
'interfaces' => $this->interfaces,

Check warning on line 103 in src/Builder/ObjectBuilder.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "ArrayItem": @@ @@ /** @phpstan-return ObjectConfig */ public function build(): array { - return ['name' => $this->name, 'description' => $this->description, 'interfaces' => $this->interfaces, 'fields' => $this->fields, 'resolveField' => $this->fieldResolver]; + return ['name' => $this->name, 'description' => $this->description, 'interfaces' > $this->interfaces, 'fields' => $this->fields, 'resolveField' => $this->fieldResolver]; } }
'fields' => $this->fields,
'resolveField' => $this->fieldResolver,
];
Expand Down
3 changes: 2 additions & 1 deletion src/Builder/TypeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

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

protected string|null $description = null;

Expand Down
7 changes: 5 additions & 2 deletions src/Error/FormattedError.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
/** @deprecated Use {@see ProvidesExtensions} */
class FormattedError extends \GraphQL\Error\FormattedError
{
public static function createFromException(Throwable $exception, int $debugFlag = DebugFlag::NONE, string|null $internalErrorMessage = null): array
{
public static function createFromException(
Throwable $exception,
int $debugFlag = DebugFlag::NONE,
string|null $internalErrorMessage = null,
): array {
$arrayError = parent::createFromException($exception, $debugFlag, $internalErrorMessage);

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

Check warning on line 20 in src/Error/FormattedError.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "LogicalAnd": @@ @@ public static function createFromException(Throwable $exception, int $debugFlag = DebugFlag::NONE, string|null $internalErrorMessage = null): array { $arrayError = parent::createFromException($exception, $debugFlag, $internalErrorMessage); - if ($exception instanceof \GraphQL\Error\Error && $exception->getPrevious() instanceof Error) { + if ($exception instanceof \GraphQL\Error\Error || $exception->getPrevious() instanceof Error) { $arrayError['extensions']['type'] = $exception->getPrevious()->getType(); } return $arrayError; } }
$arrayError['extensions']['type'] = $exception->getPrevious()->getType();
}

Expand Down
6 changes: 5 additions & 1 deletion src/Exception/InvalidArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@

final class InvalidArgument extends Exception implements ClientAware
{
private function __construct(string $message = '', int $code = 0, Throwable|null $previous = null)

Check warning on line 17 in src/Exception/InvalidArgument.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "DecrementInteger": @@ @@ use function sprintf; final class InvalidArgument extends Exception implements ClientAware { - private function __construct(string $message = '', int $code = 0, Throwable|null $previous = null) + private function __construct(string $message = '', int $code = -1, Throwable|null $previous = null) { parent::__construct($message, $code, $previous); }
{
parent::__construct($message, $code, $previous);
}

public static function invalidNameFormat(string $invalidName): self
{
return new self(sprintf('Name "%s" does not match pattern "%s"', $invalidName, TypeBuilder::VALID_NAME_PATTERN));
return new self(sprintf(
'Name "%s" does not match pattern "%s"',
$invalidName,
TypeBuilder::VALID_NAME_PATTERN,
));
}

public static function valueNotIso8601Compliant(mixed $invalidValue): self
Expand Down
2 changes: 1 addition & 1 deletion tests/Builder/EnumBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function testCreate(): void
$name = 'SomeEnum';

$builder = EnumBuilder::create($name);
$object = $builder
$object = $builder
->addValue('Value1', 'EnumName')
->addValue('Value2', null, 'Value 2 Description')
->addValue(0, 'Numeric', 'Value 2 Description')
Expand Down
2 changes: 1 addition & 1 deletion tests/Builder/FieldBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testCreate(): void
self::assertIsCallable($field['resolve']);

$resolveInfoReflection = new ReflectionClass(ResolveInfo::class);
$resolveInfo = $resolveInfoReflection->newInstanceWithoutConstructor();
$resolveInfo = $resolveInfoReflection->newInstanceWithoutConstructor();

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

Expand Down
6 changes: 3 additions & 3 deletions tests/Builder/InputObjectBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ final class InputObjectBuilderTest extends TestCase
public function testCreate(): void
{
$description = 'To the sichuan-style nachos add ghee, noodles, buttermilk and heated herring.';
$name = 'SomeType';
$interface = new class () extends InterfaceType {
$name = 'SomeType';
$interface = new class () extends InterfaceType {
public function __construct()
{
$builder = InterfaceBuilder::create('InterfaceA');
Expand All @@ -31,7 +31,7 @@ public function __construct()
};

$builder = InputObjectBuilder::create($name);
$object = $builder
$object = $builder
->setDescription($description)
->setFields(
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Builder/InterfaceBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class InterfaceBuilderTest extends TestCase
{
public function testCreate(): void
{
$name = 'InterfaceA';
$name = 'InterfaceA';
$description = 'Description';

$interfaceA = new class () extends InterfaceType {
Expand Down
10 changes: 5 additions & 5 deletions tests/Builder/ObjectBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ final class ObjectBuilderTest extends TestCase
public function testCreate(): void
{
$description = 'To the sichuan-style nachos add ghee, noodles, buttermilk and heated herring.';
$name = 'SomeType';
$interface = new class () extends InterfaceType {
$name = 'SomeType';
$interface = new class () extends InterfaceType {
public function __construct()
{
$builder = InterfaceBuilder::create('InterfaceA');
Expand All @@ -31,7 +31,7 @@ public function __construct()
};

$builder = ObjectBuilder::create($name);
$object = $builder
$object = $builder
->setDescription($description)
->addInterface($interface)
->setFields(
Expand All @@ -56,7 +56,7 @@ public function __construct()
public function testAddFields(): void
{
$builder = ObjectBuilder::create('Name');
$object = $builder
$object = $builder
->setFields([
FieldBuilder::create('SomeField', Type::string())->build(),
])
Expand All @@ -70,7 +70,7 @@ public function testAddFields(): void
public function testAddFieldsToCallable(): void
{
$builder = ObjectBuilder::create('Name');
$object = $builder
$object = $builder
->setFields(static fn () => [
FieldBuilder::create('SomeField', Type::string())->build(),
])
Expand Down
2 changes: 1 addition & 1 deletion tests/Builder/UnionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static function ($value) use ($typeA, $typeB): ObjectType {
self::assertIsCallable($union['resolveType']);

$resolveInfoReflection = new ReflectionClass(ResolveInfo::class);
$resolveInfo = $resolveInfoReflection->newInstanceWithoutConstructor();
$resolveInfo = $resolveInfoReflection->newInstanceWithoutConstructor();

self::assertSame($typeA, $union['resolveType'](true, null, $resolveInfo));
self::assertSame($typeB, $union['resolveType'](false, null, $resolveInfo));
Expand Down
1 change: 1 addition & 0 deletions tests/Error/FormattedErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function testDebug(): void
self::assertSame(
[
'message' => 'Internal server error',
// phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
'extensions' => ['debugMessage' => 'When smashing sun-dried shrimps, be sure they are room temperature.'],
],
FormattedError::createFromException($exception, DebugFlag::INCLUDE_DEBUG_MESSAGE),
Expand Down
Loading