Serialize value with type prefix
@param mixed $value
@return string encoded value
349502
protected function encode($val) {
		switch (true) {
			case is_array($val):
				return self::T_ARRAY . json_encode($val);
			case is_int($val):
				return self::T_INT . $val;
			case is_bool($val):
				return self::T_BOOLEAN . $val;
			case is_float($val):
				return self::T_DOUBLE . $val;
			case is_object($val):
				return self::T_OBJECT . serialize($val);
			default:
				return self::T_STRING . $val;
		}
	}
430379
public function serialize($value) : string
    {
        if (!is_numeric($value)) {
            throw InvalidValueException::valueDoesNotMatchType($this, $value);
        }

        return (string) (float) $value;
    }
890953
protected static function _encodeValue($value)
    {
        $string = '';

        switch (gettype($value))
        {
            case 'integer':
            case 'double':
                $string = $value;
                break;

            case 'boolean':
                $string = $value ? 'true' : 'false';
                break;

            case 'string':
                // Sanitize any CRLF characters..
                $string = '"' . str_replace(array("\r\n", "\n"), '\\n', $value) . '"';
                break;
        }

        return $string;
    }
1359718
public function convert($value)
    {
        if (!is_scalar($value)) {
            return false;
        }

        if (is_string($value)) {
            return $value;
        }

        if (is_float($value)) {
            return sprintf('float_%.4f', $value);
        }

        $prefix = '';

        if (!is_bool($value)) {
            $prefix = gettype($value) . '_';
        }

        
        return $prefix . var_export($value, true);
    }
881602
public function encodeValue($value)
    {
        if ($this->urlEncode == self::RFC_3986) {
            return rawurlencode($value);
        } elseif ($this->urlEncode == self::FORM_URLENCODED) {
            return urlencode($value);
        } else {
            return (string) $value;
        }
    }
1155524
public static function dump($value): string
    {
        try {
            return serialize($value);
        } catch (\Throwable $e) {
        }

        throw new DumpException(sprintf('Error serializing value. %s', $e->getMessage()), 0, $e);
    }
983659
public function serialize($value) {
        $filters = $this->getFilters();
        for ($i = count($filters) - 1; $i >= 0; --$i) {
            $value = $filters[$i]->fromValue($value);
        }
        return $this->toData($value);
    }
368783
public function encodeValue($value)
    {
        if (is_bool($value)) {
            return (int) $value;
        }

        if ($value instanceof Enum) {
            return $value->name();
        }

        if ($value instanceof Stream) {
            return json_encode($value->__toString());
        }

        return json_encode($value);
    }
1365055
protected function serializeType($value, $type)
    {
        return $this->connection->convertToDatabaseValue(
            $value,
            TypeMapper::getDoctrineTypeByType($type)
        );
    }
850700
public static function encodeForMaria($value)
    {
        return is_string($value)
        && (!mb_check_encoding($value, 'UTF-8') || strpos($value, self::DATA_URI_PREFIX) === 0)
            ? self::DATA_URI_PREFIX . base64_encode($value)
            : $value;
    }
1181907
private function serializeField($value)
    {
        if (is_string($value)) {
            // @todo Could be decimal (D) or byte array (x)
            // @see https://github.com/recoilphp/amqp/issues/25
            return 'S' . $this->serializeLongString($value);
        }
        if (is_int($value)) {
            // @todo Could be timestamp (T)
            // @see https://github.com/recoilphp/amqp/issues/25
            if ($value >= 0) {
                if ($value < 0x80) {
                    return 'b' . $this->serializeSignedInt8($value);
                }
                if ($value < 0x8000) {
                    return 's' . $this->serializeSignedInt16($value);
                }
                if ($value < 0x80000000) {
                    return 'I' . $this->serializeSignedInt32($value);
                }
            } else {
                if ($value >= -0x80) {
                    return 'b' . $this->serializeSignedInt8($value);
                }
                if ($value >= -0x8000) {
                    return 's' . $this->serializeSignedInt16($value);
                }
                if ($value >= -0x80000000) {
                    return 'I' . $this->serializeSignedInt32($value);
                }
            }

            return 'l' . $this->serializeSignedInt64($value);
        }
        if (true === $value) {
            return "t\x01";
        }
        if (false === $value) {
            return "t\x00";
        }
        if (null === $value) {
            return 'V';
        }
        if (is_float($value)) {
            return 'd' . $this->serializeDouble($value);
        }
        if (is_array($value)) {
            return $this->serializeArrayOrTable($value);
        }
        throw new InvalidArgumentException(
            'Could not serialize value (' . chr($value) . ').'
        );
    }
153109
public function encode($value)
    {

        $createdIv = $this->createIvSizeAndIvString();
        $createdKey = $this->createSpecialKey($createdIv);

        if (false !== $encrypted = @mcrypt_encrypt($this->algorithm, $createdKey, $value, $this->mode, $createdIv)) {

            return urlencode(base64_encode(
                serialize(
                    [
                        'iv'    => base64_encode($createdIv),
                        'key'   => base64_encode($createdKey),
                        'value' => trim(base64_encode($encrypted)),
                    ]
                )
            ));
        }

        return false;
    }
845990
public function serialize($value) : string
    {
        if (!$value instanceof \DateTimeInterface) {
            throw InvalidValueException::valueDoesNotMatchType($this, $value);
        }

        return (string) $value->format($this->format);
    }
1213965
public function serialize($value)
    {
        $value = self::replaceKeys($this->replacements, $value);
        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><data></data>');
        $this->arrayToXml($value, $xml);

        return $xml->asXML();
    }
1095287
private function makeSerializable($value)
    {
        if (null === $value) {
            return $value;
        }

        if ($value instanceof Traversable || is_array($value)) {
            $value = ArrayUtils::iteratorToArray($value);

            foreach ($value as $key => $val) {
                $value[$key] = $this->makeSerializable($val);
            }

            return $value;
        }

        if (is_scalar($value)) {
            return $value;
        }

        if (is_resource($value)) {
            return 'resource';
        }

        return new ObjectStub($value);
    }
184723
private function serialize($value)
    {
        $compressed = gzcompress($value);
        if ($compressed === false) {
            return false;
        }

        $encoded = base64_encode($compressed);
        return $encoded;
    }
302624
protected function serialize($value)
    {
        $result = serialize($value);

        if ($this->connection instanceof PostgresConnection && Str::contains($result, "\0")) {
            $result = base64_encode($result);
        }

        return $result;
    }