xiaohutai / jsonapi

[Bolt Extension] JSON API for Bolt CMS
https://market.bolt.cm/view/bolt/jsonapi
MIT License
55 stars 18 forks source link

PHP 5.5 compatibility in version 2.2.1 #39

Closed jadwigo closed 6 years ago

jadwigo commented 7 years ago

The statements in https://github.com/xiaohutai/jsonapi/blob/v2.2.1/src/Helpers/APIHelper.php#L379-L383 and https://github.com/xiaohutai/jsonapi/blob/v2.2.1/src/Response/ApiResponse.php#L58-L62 are not compatible with PHP 5.5

The could be replace by:

        $headers = $this->config->getHeaders();
        if (!empty($headers) && is_array($headers)) {
            foreach ($headers as $header => $value) {
                $this->headers->set($header, $value);
            }
        }
                // Handle replacements.
                $replacements = $this->config->getReplacements();
                if (!empty($replacements)) {
                    foreach ($replacements as $from => $to) {
                        $item = str_replace($from, $to, $item);
                    }
                }
xiaohutai commented 6 years ago

Danke schön! Sorry for the late reply, fixed in https://github.com/xiaohutai/jsonapi/commit/34477f9dfa10d7a9f2c9e440329cf8065fe34895