Converts the given {@see Type} in PHP type.
355795
protected function getPhpType(Type $type): string
    {
        switch ($builtinType = $type->getBuiltinType()) {
            case Type::BUILTIN_TYPE_ARRAY:
            case Type::BUILTIN_TYPE_INT:
            case Type::BUILTIN_TYPE_FLOAT:
            case Type::BUILTIN_TYPE_BOOL:
            case Type::BUILTIN_TYPE_STRING:
                return $builtinType;
            case Type::BUILTIN_TYPE_OBJECT:
                if (null !== ($className = $type->getClassName()) && is_a($className, \DateTimeInterface::class, true)) {
                    return \DateTimeInterface::class;
                }

            // no break
            default:
                return 'string';
        }
    }
392905
private static TYPE toTYPE(String type) {
        if (null == type || type.trim().isEmpty()) {
            return TYPE.OBJECT;
        } else {
            return TYPE.valueOf(type.toUpperCase());
        }
    }
765151
private static Object selfConvert( String parsingMethod, String value, Class<?> type )
    {
        try
        {
            Method method = type.getMethod( parsingMethod, String.class );
            return method.invoke( null, value );
        }
        catch (InvocationTargetException e)
        {
            throw new IllegalArgumentException( "Can't convert " + value + " to " + type.getName(), e.getCause() );
        }
        catch (Exception e)
        {
            throw new IllegalArgumentException( "Can't convert " + value + " to " + type.getName(), e );
        }
    }
1187983
public function type($type)
    {
        if (is_string($type)) {
            $map = array(
                'double' => 1,
                'string' => 2,
                'object' => 3,
                'array' => 4,
                'binary' => 5,
                'undefined' => 6,
                'objectid' => 7,
                'boolean' => 8,
                'date' => 9,
                'null' => 10,
                'regex' => 11,
                'jscode' => 13,
                'symbol' => 14,
                'jscodewithscope' => 15,
                'integer32' => 16,
                'timestamp' => 17,
                'integer64' => 18,
                'maxkey' => 127,
                'minkey' => 255,
            );

            $type = isset($map[$type]) ? $map[$type] : $type;
        }

        return $this->operator('$type', $type);
    }
894822
private function convertType($value)
    {
        $type = gettype($value);

        if ($this->type === $type || !is_scalar($value)) {
            return $value;
        }

        switch ($this->type) {
            case self::TYPE_BOOL:
                return $this->convertBool($value);
            case self::TYPE_INT:
                return $this->convertInt($value);
            case self::TYPE_FLOAT:
                return $this->convertFloat($value);
            default:
                return $this->convertString($value);
        }
    }
1096708
function MetaType($t,$len=-1,$fieldobj=false)
	{
		if (is_object($t)) {
			$fieldobj = $t;
			$t = $fieldobj->type;
			$len = $fieldobj->max_length;
		}

		$_typeConversion = array(
			-155 => 'D',
			  93 => 'D',
			-154 => 'D',
			  -2 => 'D',
			  91 => 'D',

			  12 => 'C',
			   1 => 'C',
			  -9 => 'C',
			  -8 => 'C',

			  -7 => 'L',
			  -6 => 'I2',
			  -5 => 'I8',
			 -11 => 'I',
			   4 => 'I',
			   5 => 'I4',

			  -1 => 'X',
			 -10 => 'X',

			   2 => 'N',
			   3 => 'N',
			   6 => 'N',
			   7 => 'N',

			-152 => 'X',
			-151 => 'X',
			  -4 => 'X',
			  -3 => 'X'
			);

		return $_typeConversion($t);

	}
1370925
public void convert(TypeDesc fromType, TypeDesc toType) {
        if (toType == TypeDesc.OBJECT) {
            if (fromType.isPrimitive()) {
                toType = fromType.toObjectType();
            }
            else {
                return;
            }
        }

        if (fromType == toType) {
            return;
        }

        TypeDesc fromPrimitiveType = fromType.toPrimitiveType();
        if (fromPrimitiveType == null) {
            throw invalidConversion(fromType, toType);
        }
        int fromTypeCode = fromPrimitiveType.getTypeCode();

        if (!fromType.isPrimitive()) {
            unbox(fromType, fromPrimitiveType);
        }

        TypeDesc toPrimitiveType = toType.toPrimitiveType();
        if (toPrimitiveType == null) {
            throw invalidConversion(fromType, toType);
        }
        int toTypeCode = toPrimitiveType.getTypeCode();

        int stackAdjust = 0;
        byte op;

        switch (fromTypeCode) {
        case TypeDesc.INT_CODE:
        case TypeDesc.BYTE_CODE:
        case TypeDesc.SHORT_CODE:
        case TypeDesc.CHAR_CODE:
        case TypeDesc.BOOLEAN_CODE:
            switch (toTypeCode) {
            case TypeDesc.BYTE_CODE:
                op = (fromTypeCode == TypeDesc.BYTE_CODE) ?
                    Opcode.NOP : Opcode.I2B;
                break;
            case TypeDesc.SHORT_CODE:
                op = (fromTypeCode == TypeDesc.SHORT_CODE) ?
                    Opcode.NOP : Opcode.I2S;
                break;
            case TypeDesc.CHAR_CODE:
                op = (fromTypeCode == TypeDesc.CHAR_CODE) ?
                    Opcode.NOP : Opcode.I2C;
                break;
            case TypeDesc.FLOAT_CODE:
                op = Opcode.I2F;
                break;
            case TypeDesc.LONG_CODE:
                stackAdjust = 1;
                op = Opcode.I2L;
                break;
            case TypeDesc.DOUBLE_CODE:
                stackAdjust = 1;
                op = Opcode.I2D;
                break;
            case TypeDesc.INT_CODE:
                op = Opcode.NOP;
                break;
            case TypeDesc.BOOLEAN_CODE:
                toBoolean(!toType.isPrimitive());
                return;
            default:
                throw invalidConversion(fromType, toType);
            }
            break;

        case TypeDesc.LONG_CODE:
            switch (toTypeCode) {
            case TypeDesc.INT_CODE:
                stackAdjust = -1;
                op = Opcode.L2I;
                break;
            case TypeDesc.FLOAT_CODE:
                stackAdjust = -1;
                op = Opcode.L2F;
                break;
            case TypeDesc.DOUBLE_CODE:
                op = Opcode.L2D;
                break;
            case TypeDesc.BYTE_CODE:
            case TypeDesc.CHAR_CODE:
            case TypeDesc.SHORT_CODE:
                addCode(-1, Opcode.L2I);
                convert(TypeDesc.INT, toPrimitiveType);
                // fall through
            case TypeDesc.LONG_CODE:
                op = Opcode.NOP;
                break;
            case TypeDesc.BOOLEAN_CODE:
                loadConstant(0L);
                math(Opcode.LCMP);
                toBoolean(!toType.isPrimitive());
                return;
            default:
                throw invalidConversion(fromType, toType);
            }
            break;

        case TypeDesc.FLOAT_CODE:
            switch (toTypeCode) {
            case TypeDesc.INT_CODE:
                op = Opcode.F2I;
                break;
            case TypeDesc.LONG_CODE:
                stackAdjust = 1;
                op = Opcode.F2L;
                break;
            case TypeDesc.DOUBLE_CODE:
                stackAdjust = 1;
                op = Opcode.F2D;
                break;
            case TypeDesc.BYTE_CODE:
            case TypeDesc.CHAR_CODE:
            case TypeDesc.SHORT_CODE:
                addCode(0, Opcode.F2I);
                convert(TypeDesc.INT, toPrimitiveType);
                // fall through
            case TypeDesc.FLOAT_CODE:
                op = Opcode.NOP;
                break;
            case TypeDesc.BOOLEAN_CODE:
                loadConstant(0.0f);
                math(Opcode.FCMPG);
                toBoolean(!toType.isPrimitive());
                return;
            default:
                throw invalidConversion(fromType, toType);
            }
            break;

        case TypeDesc.DOUBLE_CODE:
            switch (toTypeCode) {
            case TypeDesc.INT_CODE:
                stackAdjust = -1;
                op = Opcode.D2I;
                break;
            case TypeDesc.FLOAT_CODE:
                stackAdjust = -1;
                op = Opcode.D2F;
                break;
            case TypeDesc.LONG_CODE:
                op = Opcode.D2L;
                break;
            case TypeDesc.BYTE_CODE:
            case TypeDesc.CHAR_CODE:
            case TypeDesc.SHORT_CODE:
                addCode(-1, Opcode.D2I);
                convert(TypeDesc.INT, toPrimitiveType);
                // fall through
            case TypeDesc.DOUBLE_CODE:
                op = Opcode.NOP;
                break;
            case TypeDesc.BOOLEAN_CODE:
                loadConstant(0.0d);
                math(Opcode.DCMPG);
                toBoolean(!toType.isPrimitive());
                return;
            default:
                throw invalidConversion(fromType, toType);
            }
            break;

        default:
            throw invalidConversion(fromType, toType);
        }

        if (toType.isPrimitive()) {
            if (op != Opcode.NOP) {
                addCode(stackAdjust, op);
            }
        }
        else {
            if (op == Opcode.NOP) {
                prebox(toPrimitiveType, toType);
            }
            // Slight optimization here. Perform prebox on single word value,
            // depending on what conversion is being applied.
            else if (!fromPrimitiveType.isDoubleWord() &&
                     toPrimitiveType.isDoubleWord()) {
                prebox(fromPrimitiveType, toType);
                addCode(stackAdjust, op);
            }
            else {
                addCode(stackAdjust, op);
                prebox(toPrimitiveType, toType);
            }
            box(toPrimitiveType, toType);
        }
    }
834458
function at_type() {
  match(/@type/);
  add_tag("type");
  skip_horiz_white();
  if (look(/\{/)) {
    var tdf = typedef();
    current_tag["type"] = tdf["type"];
    current_tag["optional"] = tdf["optional"] ? true : false;
  }
  else if (look(/\S/)) {
    current_tag["type"] = match(/\S+/);
  }
  skip_white();
}
206387
public function toValue($type = null, $valueAttribute = null)
    {
        $value = ($valueAttribute)? (string)$this[$valueAttribute] : (string)$this;
        $type = ($type)?: (string)$this['type'];

        switch ($type) {
            case 'int':
                $value = (int)$value;
                break;

            case 'float':
                $value = (float)$value;
                break;

            case 'bool':
                $value = $this->_toBoolean($value);
                break;

            case 'double':
                $value = (double)$value;
                break;

            case 'null':
                $value = null;
                break;

            case 'array':
                $value = $this->toArray(true);
                break;
        }

        return $value;
    }
970597
function GetPhpType()
	{
		$rt = $this->Type;
		switch ($this->Type)
		{
			case "smallint":
			case "bigint":
			case "tinyint":
			case "mediumint":
				$rt = "int";
				break;
			case "varchar":
			case "text":
			case "tinytext":
				$rt = "string";
				break;
			case "date":
			case "datetime":
				$rt = "date";
				break;
			case "decimal":
			case "float":
				$rt = "float";
				break;
			default;
				break;
		}

		return $rt;
	}
1215454
protected static function convertBase(
        /*# string */ $input,
        /*# string */ $fromBase,
        /*# string */ $toBase
    )/*# : string */ {
        if ($fromBase === $toBase) {
            return $input;
        } elseif ($fromBase === self::BASE10) {
            return static::fromBase10($input, $toBase);
        } elseif ($toBase === self::BASE10) {
            return static::toBase10($input, $fromBase);
        } else {
            return static::fromBase10(static::toBase10($input, $fromBase), $toBase);
        }
    }
33687
public function parseType()
    {
        if ( ! $this->type ) {
            $this->stream->resetPointer();

            switch ( $this->stream->read(2) ) {
                case "BM":
                    return $this->type = 'bmp';
                case "GI":
                    return $this->type = 'gif';
                case chr(0xFF) . chr(0xd8):
                    return $this->type = 'jpeg';
                case "\0\0":
                    switch ( $this->readByte($this->stream->peek(1)) ) {
                        case 1:
                            return $this->type = 'ico';
                        case 2:
                            return $this->type = 'cur';
                    }

                    return false;

                case chr(0x89) . 'P':
                    return $this->type = 'png';
                case "RI":
                    if ( substr($this->stream->read(10), 6, 4) == 'WEBP' ) {
                        return $this->type = 'webp';
                    }

                    return false;
                case'8B':
                    return $this->type = 'psd';
                case "II":
                case "MM":
                    return $this->type = 'tiff';
                default:
                    $this->stream->resetPointer();

                    // Keep reading bytes until we find '<svg'.
                    while ( true ) {
                        $byte = $this->stream->read( 1 );
                        if ( '<' === $byte && 'svg' === $this->stream->peek( 3 ) ) {
                            $this->type = 'svg';
                            return $this->type;
                        }
                    }
                    return false;
            }
        }

        return $this->type;
    }
1048142
@Override
	public Object convert(String value, Class type) {
		if (isNullOrEmpty(value)) {
			return null;
		}

		if (Character.isDigit(value.charAt(0))) {
			return resolveByOrdinal(value, type);
		} else {
			return resolveByName(value, type);
		}
	}
356081
private function convertType(Type $type, bool $input, ?string $queryName, ?string $mutationName, int $depth = 0)
    {
        switch ($builtinType = $type->getBuiltinType()) {
            case Type::BUILTIN_TYPE_BOOL:
                $graphqlType = GraphQLType::boolean();
                break;
            case Type::BUILTIN_TYPE_INT:
                $graphqlType = GraphQLType::int();
                break;
            case Type::BUILTIN_TYPE_FLOAT:
                $graphqlType = GraphQLType::float();
                break;
            case Type::BUILTIN_TYPE_STRING:
                $graphqlType = GraphQLType::string();
                break;
            case Type::BUILTIN_TYPE_ARRAY:
            case Type::BUILTIN_TYPE_ITERABLE:
                $graphqlType = $this->graphqlTypes['Iterable'];
                break;
            case Type::BUILTIN_TYPE_OBJECT:
                if (($input && $depth > 0) || is_a($type->getClassName(), \DateTimeInterface::class, true)) {
                    $graphqlType = GraphQLType::string();
                    break;
                }

                $resourceClass = $this->isCollection($type) && ($collectionValueType = $type->getCollectionValueType()) ? $collectionValueType->getClassName() : $type->getClassName();
                if (null === $resourceClass) {
                    return null;
                }

                try {
                    $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
                    if ([] === $resourceMetadata->getGraphql() ?? []) {
                        return null;
                    }
                } catch (ResourceClassNotFoundException $e) {
                    // Skip objects that are not resources for now
                    return null;
                }

                $graphqlType = $this->getResourceObjectType($resourceClass, $resourceMetadata, $input, $queryName, $mutationName, false, $depth);
                break;
            default:
                throw new InvalidTypeException(sprintf('The type "%s" is not supported.', $builtinType));
        }

        if ($this->isCollection($type)) {
            return $this->paginationEnabled && !$input ? $this->getResourcePaginatedCollectionType($graphqlType) : GraphQLType::listOf($graphqlType);
        }

        return $type->isNullable() || (null !== $mutationName && 'update' === $mutationName) ? $graphqlType : GraphQLType::nonNull($graphqlType);
    }
1155850
@Deprecated
	public static Object convert(final Class<?> clazz, String val)
	{
		return StringToTypeConverter.convert(clazz, val);
	}
1313349
public static <T> T convert(Object source, TypeReference<T> destType) {
        return JSON.convertValue(source, destType);
    }
651830
protected function resolveType($type)
    {
        switch ($type) {
            case IndexMapping::TYPE_BOOLEAN:
                return ["type" => "boolean"];

            case IndexMapping::TYPE_FLOAT:
                return ["type" => "float"];

            case IndexMapping::TYPE_INTEGER:
                return ["type" => "integer"];

            case IndexMapping::TYPE_DATE:
                return ["type" => "date", "format" => "YYYY-MM-dd"];

            case IndexMapping::TYPE_DATETIME:
                return ["type" => "date"];

            case IndexMapping::TYPE_TIME:
                return ["type" => "date", "format" => "HH:mm:ss"];

            default:
            case IndexMapping::TYPE_STRING:
            case IndexMapping::TYPE_BIG_TEXT:
                return ["type" => "string", "analyzer" => "standard"];
        }
    }