Skip to content

Commit

Permalink
Added missing polyfill for json_last_error_msg.
Browse files Browse the repository at this point in the history
  • Loading branch information
vimishor committed Jan 10, 2017
2 parents 3580460 + 7ed4d06 commit 00feb80
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## 0.8.2 / 2017-01-10

### Fixed:
- Added missing polyfill for "json_last_error_msg".

## 0.8.1 / 2016-05-08

### Fixed:
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"ext-curl": "*"
},
"autoload": {
"psr-0": { "Bitbucket\\": "lib/" }
"psr-0": { "Bitbucket\\": "lib/" },
"files": ["polyfill-55.php"]
},
"scripts": {
"test": "vendor/bin/phpunit"
Expand Down
2 changes: 1 addition & 1 deletion lib/Bitbucket/API/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Client extends ClientListener implements ClientInterface
'api_versions' => array('1.0', '2.0'), // supported versions
'format' => 'json',
'formats' => array('json', 'xml'), // supported response formats
'user_agent' => 'bitbucket-api-php/0.8.1 (https://bitbucket.org/gentlero/bitbucket-api)',
'user_agent' => 'bitbucket-api-php/0.8.2 (https://bitbucket.org/gentlero/bitbucket-api)',
'timeout' => 10,
'verify_peer' => false
);
Expand Down
34 changes: 34 additions & 0 deletions polyfill-55.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Copyright 2015 - 2016 Alexandru Guzinschi <[email protected]>
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/

/**
* Provides functions unavailable in PHP releases prior to v5.5
*/
if (PHP_VERSION_ID < 50500) {
if (!function_exists('json_last_error_msg')) {
function json_last_error_msg()
{
switch (json_last_error()) {
case JSON_ERROR_NONE:
return 'No error';
case JSON_ERROR_DEPTH:
return 'Maximum stack depth exceeded';
case JSON_ERROR_STATE_MISMATCH:
return 'State mismatch (invalid or malformed JSON)';
case JSON_ERROR_CTRL_CHAR:
return 'Control character error, possibly incorrectly encoded';
case JSON_ERROR_SYNTAX:
return 'Syntax error';
case JSON_ERROR_UTF8:
return 'Malformed UTF-8 characters, possibly incorrectly encoded';
default:
return 'Unknown error';
}
}
}
}

0 comments on commit 00feb80

Please sign in to comment.