Skip to content
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
8 changes: 6 additions & 2 deletions src/Type/Definition/FloatType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class FloatType extends ScalarType
*/
public function serialize($value) : float
{
$float = is_numeric($value) || is_bool($value) ? floatval($value) : null;
$float = is_numeric($value) || is_bool($value)
? (float) $value
: null;

if ($float === null || ! is_finite($float)) {
throw new Error(
Expand All @@ -54,7 +56,9 @@ public function serialize($value) : float
*/
public function parseValue($value) : float
{
$float = is_float($value) || is_int($value) ? floatval($value) : null;
$float = is_float($value) || is_int($value)
? (float) $value
: null;

if ($float === null || ! is_finite($float)) {
throw new Error(
Expand Down
8 changes: 5 additions & 3 deletions src/Type/Definition/IntType.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public function serialize($value)
return $value;
}

$float = is_numeric($value) || is_bool($value) ? floatval($value) : null;
$float = is_numeric($value) || is_bool($value)
? (float) $value
: null;

if ($float === null || floor($float) !== $float) {
throw new Error(
Expand All @@ -65,7 +67,7 @@ public function serialize($value)
);
}

return intval($float);
return (int) $float;
}

/**
Expand All @@ -91,7 +93,7 @@ public function parseValue($value) : int
);
}

return intval($value);
return (int) $value;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/AST.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,9 @@ public static function valueFromASTUntyped($valueNode, ?array $variables = null)
case $valueNode instanceof NullValueNode:
return null;
case $valueNode instanceof IntValueNode:
return intval($valueNode->value, 10);
return (int) $valueNode->value;
case $valueNode instanceof FloatValueNode:
return floatval($valueNode->value);
return (float) $valueNode->value;
case $valueNode instanceof StringValueNode:
case $valueNode instanceof EnumValueNode:
case $valueNode instanceof BooleanValueNode:
Expand Down