Skip to content
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

PHP 8.2 support #1256

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yml
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
php: [7.1, 7.2, 7.3, 7.4, 8.0, 8.1]
php: [7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2]
env: [
'EXECUTOR= DEPENDENCIES=--prefer-lowest',
'EXECUTOR=coroutine DEPENDENCIES=--prefer-lowest',
Expand Down
1 change: 1 addition & 0 deletions src/Type/Definition/FieldDefinition.php
Expand Up @@ -19,6 +19,7 @@
/**
* @todo Move complexity-related code to it's own place
*/
#[\AllowDynamicProperties]
class FieldDefinition
{
public const DEFAULT_COMPLEXITY_FN = 'GraphQL\Type\Definition\FieldDefinition::defaultComplexity';
Expand Down
1 change: 1 addition & 0 deletions src/Type/Definition/InputObjectField.php
Expand Up @@ -13,6 +13,7 @@
use function array_key_exists;
use function sprintf;

#[\AllowDynamicProperties]
class InputObjectField
{
/** @var string */
Expand Down
24 changes: 12 additions & 12 deletions src/Utils/BreakingChangesFinder.php
Expand Up @@ -103,7 +103,7 @@ public static function findRemovedTypes(

$breakingChanges[] = [
'type' => self::BREAKING_CHANGE_TYPE_REMOVED,
'description' => "${typeName} was removed.",
'description' => sprintf('%s was removed.', $typeName),
];
}

Expand Down Expand Up @@ -141,7 +141,7 @@ public static function findTypesThatChangedKind(
$schemaBTypeKindName = self::typeKindName($schemaBType);
$breakingChanges[] = [
'type' => self::BREAKING_CHANGE_TYPE_CHANGED_KIND,
'description' => "${typeName} changed from ${schemaATypeKindName} to ${schemaBTypeKindName}.",
'description' => sprintf('%s changed from %s to %s.', $typeName, $schemaATypeKindName, $schemaBTypeKindName),
];
}

Expand Down Expand Up @@ -209,7 +209,7 @@ public static function findFieldsThatChangedTypeOnObjectOrInterfaceTypes(
if (! isset($newTypeFieldsDef[$fieldName])) {
$breakingChanges[] = [
'type' => self::BREAKING_CHANGE_FIELD_REMOVED,
'description' => "${typeName}.${fieldName} was removed.",
'description' => sprintf('%s.%s was removed.', $typeName, $fieldName),
];
} else {
$oldFieldType = $oldTypeFieldsDef[$fieldName]->getType();
Expand All @@ -227,7 +227,7 @@ public static function findFieldsThatChangedTypeOnObjectOrInterfaceTypes(
: $newFieldType;
$breakingChanges[] = [
'type' => self::BREAKING_CHANGE_FIELD_CHANGED_KIND,
'description' => "${typeName}.${fieldName} changed type from ${oldFieldTypeString} to ${newFieldTypeString}.",
'description' => sprintf('%s.%s changed type from %s to %s.', $typeName, $fieldName, $oldFieldTypeString, $newFieldTypeString),
];
}
}
Expand Down Expand Up @@ -298,7 +298,7 @@ public static function findFieldsThatChangedTypeOnInputObjectTypes(
if (! isset($newTypeFieldsDef[$fieldName])) {
$breakingChanges[] = [
'type' => self::BREAKING_CHANGE_FIELD_REMOVED,
'description' => "${typeName}.${fieldName} was removed.",
'description' => sprintf('%s.%s was removed.', $typeName, $fieldName),
];
} else {
$oldFieldType = $oldTypeFieldsDef[$fieldName]->getType();
Expand All @@ -321,7 +321,7 @@ public static function findFieldsThatChangedTypeOnInputObjectTypes(
}
$breakingChanges[] = [
'type' => self::BREAKING_CHANGE_FIELD_CHANGED_KIND,
'description' => "${typeName}.${fieldName} changed type from ${oldFieldTypeString} to ${newFieldTypeString}.",
'description' => sprintf('%s.%s changed type from %s to %s.', $typeName, $fieldName, $oldFieldTypeString, $newFieldTypeString),
];
}
}
Expand All @@ -336,12 +336,12 @@ public static function findFieldsThatChangedTypeOnInputObjectTypes(
if ($fieldDef->isRequired()) {
$breakingChanges[] = [
'type' => self::BREAKING_CHANGE_REQUIRED_INPUT_FIELD_ADDED,
'description' => "A required field ${fieldName} on input type ${newTypeName} was added.",
'description' => sprintf('A required field %s on input type %s was added.', $fieldName, $newTypeName),
];
} else {
$dangerousChanges[] = [
'type' => self::DANGEROUS_CHANGE_OPTIONAL_INPUT_FIELD_ADDED,
'description' => "An optional field ${fieldName} on input type ${newTypeName} was added.",
'description' => sprintf('An optional field %s on input type %s was added.', $fieldName, $newTypeName),
];
}
}
Expand Down Expand Up @@ -525,12 +525,12 @@ static function ($arg) use ($oldArgDef) : bool {
$newArgType = $newArgDef->getType();
$breakingChanges[] = [
'type' => self::BREAKING_CHANGE_ARG_CHANGED_KIND,
'description' => "${typeName}.${fieldName} arg ${oldArgName} has changed type from ${oldArgType} to ${newArgType}",
'description' => sprintf('%s.%s arg %s has changed type from %s to %s', $typeName, $fieldName, $oldArgName, $oldArgType, $newArgType),
];
} elseif ($oldArgDef->defaultValueExists() && $oldArgDef->defaultValue !== $newArgDef->defaultValue) {
$dangerousChanges[] = [
'type' => self::DANGEROUS_CHANGE_ARG_DEFAULT_VALUE_CHANGED,
'description' => "${typeName}.${fieldName} arg ${oldArgName} has changed defaultValue",
'description' => sprintf('%s.%s arg %s has changed defaultValue', $typeName, $fieldName, $oldArgName),
];
}
} else {
Expand Down Expand Up @@ -563,12 +563,12 @@ static function ($arg) use ($newTypeFieldArgDef) : bool {
if ($newTypeFieldArgDef->isRequired()) {
$breakingChanges[] = [
'type' => self::BREAKING_CHANGE_REQUIRED_ARG_ADDED,
'description' => "A required arg ${newArgName} on ${newTypeName}.${fieldName} was added",
'description' => sprintf('A required arg %s on %s.%s was added', $newArgName, $newTypeName, $fieldName),
];
} else {
$dangerousChanges[] = [
'type' => self::DANGEROUS_CHANGE_OPTIONAL_ARG_ADDED,
'description' => "An optional arg ${newArgName} on ${newTypeName}.${fieldName} was added",
'description' => sprintf('An optional arg %s on %s.%s was added', $newArgName, $newTypeName, $fieldName),
];
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Utils/BuildClientSchema.php
Expand Up @@ -29,6 +29,7 @@
use function array_map;
use function array_merge;
use function json_encode;
use function sprintf;

class BuildClientSchema
{
Expand Down Expand Up @@ -187,7 +188,7 @@ private function getNamedType(string $typeName) : NamedType
{
if (! isset($this->typeMap[$typeName])) {
throw new InvariantViolation(
"Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema."
sprintf('Invalid or incomplete schema, unknown type: %s. Ensure that a full introspection query is used in order to build a client schema.', $typeName)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Rules/ValuesOfCorrectType.php
Expand Up @@ -179,7 +179,7 @@ static function ($field) : string {
public static function badValueMessage($typeName, $valueName, $message = null)
{
return sprintf('Expected type %s, found %s', $typeName, $valueName) .
($message ? "; ${message}" : '.');
($message ? sprintf('; %s', $message) : '.');
}

/**
Expand Down