AVClient::_decode, internal method for decoding server responses.

@param mixed $data The value to decode

@return mixed
@ignore
498772
public static function _decode($data)
    {
        // The json decoded response from Avos will make JSONObjects into stdClass
        //   objects.  We'll change it to an associative array here.
        if ($data instanceof \stdClass)
        {
            $tmp = (array) $data;
            if (!empty($tmp))
            {
                return self::_decode(get_object_vars($data));
            }
        }

        if (!$data && !is_array($data))
        {
            return null;
        }

        if (is_array($data))
        {
            $typeString = (isset($data['__type']) ? $data['__type'] : null);

            if ($typeString === 'Date')
            {
                return new \DateTime($data['iso']);
            }

            if ($typeString === 'Bytes')
            {
                return base64_decode($data['base64']);
            }

            if ($typeString === 'Pointer')
            {
                return AVObject::create($data['className'], $data['objectId']);
            }

            if ($typeString === 'File')
            {
                return AVFile::_createFromServer($data['name'], $data['url']);
            }

            if ($typeString === 'GeoPoint')
            {
                return new AVGeoPoint($data['latitude'], $data['longitude']);
            }

            if ($typeString === 'Object')
            {
                $output = AVObject::create($data['className']);
                $output->_mergeAfterFetch($data);

                return $output;
            }

            if ($typeString === 'Relation')
            {
                return $data;
            }

            $newDict = array();
            foreach ($data as $key => $value)
            {
                $newDict[$key] = static::_decode($value);
            }

            return $newDict;

        }

        return $data;
    }
593971
private function decode($data, $raw)
    {
        if (is_array($data)) {
            foreach ($data as $k => &$v) {
                $v = $this->decode($v, $raw[$k]);
            }
            return $data;
        }

        $data = $this->decodeBoolean($data, $raw);
        $data = $this->decodeNull($data, $raw);

        if (is_numeric($data) && ((string)($data + 0) === $data))
            return $data + 0;

        if (is_string($raw) && empty($raw))
            return "";

        return $data;
    }
341845
protected static function decode_chunked($data) {
		if (!preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', trim($data))) {
			return $data;
		}

		$decoded = '';
		$encoded = $data;

		while (true) {
			$is_chunked = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $encoded, $matches );
			if (!$is_chunked) {
				// Looks like it's not chunked after all
				return $data;
			}

			$length = hexdec(trim($matches[1]));
			if ($length === 0) {
				// Ignore trailer headers
				return $decoded;
			}

			$chunk_length = strlen($matches[0]);
			$decoded .= $part = substr($encoded, $chunk_length, $length);
			$encoded = substr($encoded, $chunk_length + $length + 2);

			if (trim($encoded) === '0' || empty($encoded)) {
				return $decoded;
			}
		}

		// We'll never actually get down here
		// @codeCoverageIgnoreStart
	}
188431
private function unserialize($data)
    {
        if ($this->type == 'db') {
            return $this->db->decode($data, $this->packed);
        }

        return $this->packed ? @unserialize($data) : $data;
    }
612397
public function decode($data)
    {
        if ($data !== null) {
            $data = gzdecode((string) $data, $this->options['length']);
            if ($data === false) {
                $data = null;
                $this->error = error_get_last()['message'] ?? 'Unknown';
            }
        }

        return $data;
    }
1185083
public static function decode(string $data): string
    {
        $decoded = base64_decode(strtr($data, '-_', '+/'), true);
        if (false === $decoded) {
            throw new InvalidArgumentException('Invalid data provided');
        }

        return $decoded;
    }
135666
protected function decodeJson($data) {
        if (strpos($data, 'callback') !== false) {
            $leftPos = strpos($data, '(');
            $rightPos = strrpos($data, ')');
            $data = substr($data, $leftPos + 1, $rightPos - $leftPos -1);
        }
        return Json::decode($data);
    }
1359591
public function decrypt($data)
    {
        $json = base64_decode($data);
        $data = json_decode($json);

        // check mac
        if ($this->hashCheck($data->iv, $data->value, $data->mac)) {

            $iv = base64_decode($data->iv);

            $data = openssl_decrypt($data->value, $this->method, $this->key, 0, $iv);

            return unserialize($data);

        }

        throw new Exception('Mac not match.');
    }
172679
public function decode($data)
    {
        $decoded = parent::decode($data);

        return 1 === count($decoded) ? reset($decoded) : 0;
    }
796437
public function decrypt($data)
    {
        try {
            return openssl_decrypt($data, self::$algorithm, self::$pass);
        } catch (\Exception $e) {
            return $data;
        }
    }
530185
public static List<AvPair> decode ( byte[] data ) throws CIFSException {
        List<AvPair> pairs = new LinkedList<>();
        int pos = 0;
        boolean foundEnd = false;
        while ( pos + 4 <= data.length ) {
            int avId = SMBUtil.readInt2(data, pos);
            int avLen = SMBUtil.readInt2(data, pos + 2);
            pos += 4;

            if ( avId == AvPair.MsvAvEOL ) {
                if ( avLen != 0 ) {
                    throw new CIFSException("Invalid avLen for AvEOL");
                }
                foundEnd = true;
                break;
            }

            byte[] raw = new byte[avLen];
            System.arraycopy(data, pos, raw, 0, avLen);
            pairs.add(parseAvPair(avId, raw));

            pos += avLen;
        }
        if ( !foundEnd ) {
            throw new CIFSException("Missing AvEOL");
        }
        return pairs;
    }
420957
public static function decodeData($data)
    {
        if (\is_array($data)) {
            foreach ($data as $key => $value) {
                $data[$key] = \urldecode($value);
            }

            return $data;
        }

        return \urldecode($data);
    }
954032
protected static function decode($data, array $context)
    {
        if ($context['base64_decode_url_safe']) {
            $data = static::getUrlSafeData($data);
        }

        $result = base64_decode($data, $context['base64_decode_strict']);

        if (false === $result) {
            static::throwDecodingException($data);
        }

        return $result;
    }
21285
function decode(string $data) {
        $msg = \json_decode($data, true);
        if($msg === null && \json_last_error() !== \JSON_ERROR_NONE) {
            throw new \CharlotteDunois\Yasmin\WebSocket\DiscordGatewayException('The JSON decoder was unable to decode the data. Error: '.\json_last_error_msg());
        }
        
        return $msg;
    }
92273
private function convertSerializedToArray($data)
    {
        $data = @unserialize($data);

        // Maybe the response was a serialized JSON string
        // So let's try to convert that to an array...
        if (is_string($data))
        {
            return $this->convertJsonToArray($data);
        }

        // It could be an object or an array of object
        // but we want a associative array, so use
        // JSON to encode it and then decode it properly...
        if ((is_object($data) or is_array($data)) and $json = $this->convertToJson($data))
        {
            return $this->convertJsonToArray($json);
        }

        return null;
    }
250067
public function decode($data)
    {
        $decoded    = '';
        $delimiters = "\n";
        $token      = strtok($data, $delimiters);

        while (false !== $token) {
            $decoded .= base64_decode($token);

            $token = strtok($delimiters);
        }

        return $decoded;
    }
1332609
public function decode($data)
    {
        if ($data[0] === "\x00" && $data[1] === "\x01") {
            throw new LzwException(
                'LZW flavour not supported.',
                LzwException::LZW_FLAVOUR_NOT_SUPPORTED
            );
        }

        $this->initsTable();

        $this->data = $data;
        $this->dataLength = \strlen($data);

        // Initialize pointers
        $this->bytePointer = 0;

        $this->nextData = 0;
        $this->nextBits = 0;

        $oldCode = 0;

        $uncompData = '';

        while (($code = $this->getNextCode()) !== 257) {
            if ($code === 256) {
                $this->initsTable();
                $code = $this->getNextCode();

                if ($code === 257) {
                    break;
                }

                $uncompData .= $this->sTable[$code];
                $oldCode = $code;

            } else {
                if ($code < $this->tIdx) {
                    $string = $this->sTable[$code];
                    $uncompData .= $string;

                    $this->addStringToTable($this->sTable[$oldCode], $string[0]);
                    $oldCode = $code;
                } else {
                    $string = $this->sTable[$oldCode];
                    $string .= $string[0];
                    $uncompData .= $string;

                    $this->addStringToTable($string);
                    $oldCode = $code;
                }
            }
        }

        return $uncompData;
    }