![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/framework/GraphQl/Type/Definition/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Framework\GraphQl\Type\Definition; use Exception; use GraphQL\Error\Error as GraphQLError; use GraphQL\Language\AST\IntValueNode; use GraphQL\Language\AST\Node; use GraphQL\Language\AST\ValueNode; /** * Replacement for the IntType definition that can typecast non-numeric values for backwards compatibility */ class IntType extends \GraphQL\Type\Definition\IntType { /** * Try to typecast valid values before running the native validations * * @param mixed $value * @return int * @throws GraphQLError */ public function parseValue($value): int { if ($value !== '' && (is_numeric($value) || is_bool($value))) { $value = (float)$value; } return parent::parseValue($value); } /** * Try to parse the literal value the same way as a variable before calling the native literal parsing * * @param Node $valueNode * @param array|null $variables * @return int * @throws Exception */ public function parseLiteral(Node $valueNode, ?array $variables = null): int { try { if ($valueNode instanceof ValueNode && !($valueNode instanceof IntValueNode) && isset($valueNode->value)) { $valueNode = new IntValueNode([ 'value' => (string)$this->parseValue($valueNode->value), 'loc' => $valueNode->loc ]); } } catch (Exception $e) {} // @codingStandardsIgnoreLine return parent::parseLiteral($valueNode, $variables); } }