diff --git a/composer.json b/composer.json index fb489c3..4733d4f 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/phpcs.xml.dist b/phpcs.xml.dist index f1f7bfb..47224bb 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -14,9 +14,5 @@ src tests - - - - - + diff --git a/src/Builder/ObjectBuilder.php b/src/Builder/ObjectBuilder.php index 5884615..46f14ab 100644 --- a/src/Builder/ObjectBuilder.php +++ b/src/Builder/ObjectBuilder.php @@ -68,13 +68,13 @@ public function addField(FieldDefinition|array $field): self { 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; } diff --git a/src/Builder/TypeBuilder.php b/src/Builder/TypeBuilder.php index 7d859b5..5478759 100644 --- a/src/Builder/TypeBuilder.php +++ b/src/Builder/TypeBuilder.php @@ -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; diff --git a/src/Error/FormattedError.php b/src/Error/FormattedError.php index 3fae5dd..1ce266f 100644 --- a/src/Error/FormattedError.php +++ b/src/Error/FormattedError.php @@ -10,8 +10,11 @@ /** @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) { diff --git a/src/Exception/InvalidArgument.php b/src/Exception/InvalidArgument.php index 0a8d48f..23951d1 100644 --- a/src/Exception/InvalidArgument.php +++ b/src/Exception/InvalidArgument.php @@ -21,7 +21,11 @@ private function __construct(string $message = '', int $code = 0, Throwable|null 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 diff --git a/tests/Builder/EnumBuilderTest.php b/tests/Builder/EnumBuilderTest.php index b4bc591..c008d39 100644 --- a/tests/Builder/EnumBuilderTest.php +++ b/tests/Builder/EnumBuilderTest.php @@ -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') diff --git a/tests/Builder/FieldBuilderTest.php b/tests/Builder/FieldBuilderTest.php index 042545b..83f5f9f 100644 --- a/tests/Builder/FieldBuilderTest.php +++ b/tests/Builder/FieldBuilderTest.php @@ -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)); diff --git a/tests/Builder/InputObjectBuilderTest.php b/tests/Builder/InputObjectBuilderTest.php index 1030771..c549cc3 100644 --- a/tests/Builder/InputObjectBuilderTest.php +++ b/tests/Builder/InputObjectBuilderTest.php @@ -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'); @@ -31,7 +31,7 @@ public function __construct() }; $builder = InputObjectBuilder::create($name); - $object = $builder + $object = $builder ->setDescription($description) ->setFields( [ diff --git a/tests/Builder/InterfaceBuilderTest.php b/tests/Builder/InterfaceBuilderTest.php index 72783a7..213df47 100644 --- a/tests/Builder/InterfaceBuilderTest.php +++ b/tests/Builder/InterfaceBuilderTest.php @@ -18,7 +18,7 @@ final class InterfaceBuilderTest extends TestCase { public function testCreate(): void { - $name = 'InterfaceA'; + $name = 'InterfaceA'; $description = 'Description'; $interfaceA = new class () extends InterfaceType { diff --git a/tests/Builder/ObjectBuilderTest.php b/tests/Builder/ObjectBuilderTest.php index 803dcef..3be428e 100644 --- a/tests/Builder/ObjectBuilderTest.php +++ b/tests/Builder/ObjectBuilderTest.php @@ -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'); @@ -31,7 +31,7 @@ public function __construct() }; $builder = ObjectBuilder::create($name); - $object = $builder + $object = $builder ->setDescription($description) ->addInterface($interface) ->setFields( @@ -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(), ]) @@ -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(), ]) diff --git a/tests/Builder/UnionBuilderTest.php b/tests/Builder/UnionBuilderTest.php index b158ec9..bdca087 100644 --- a/tests/Builder/UnionBuilderTest.php +++ b/tests/Builder/UnionBuilderTest.php @@ -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)); diff --git a/tests/Error/FormattedErrorTest.php b/tests/Error/FormattedErrorTest.php index e778b65..42cadc8 100644 --- a/tests/Error/FormattedErrorTest.php +++ b/tests/Error/FormattedErrorTest.php @@ -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),