Skip to content

Commit 00feb80

Browse files
committed
Added missing polyfill for json_last_error_msg.
2 parents 3580460 + 7ed4d06 commit 00feb80

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## 0.8.2 / 2017-01-10
6+
7+
### Fixed:
8+
- Added missing polyfill for "json_last_error_msg".
9+
510
## 0.8.1 / 2016-05-08
611

712
### Fixed:

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"ext-curl": "*"
2929
},
3030
"autoload": {
31-
"psr-0": { "Bitbucket\\": "lib/" }
31+
"psr-0": { "Bitbucket\\": "lib/" },
32+
"files": ["polyfill-55.php"]
3233
},
3334
"scripts": {
3435
"test": "vendor/bin/phpunit"

lib/Bitbucket/API/Http/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Client extends ClientListener implements ClientInterface
3333
'api_versions' => array('1.0', '2.0'), // supported versions
3434
'format' => 'json',
3535
'formats' => array('json', 'xml'), // supported response formats
36-
'user_agent' => 'bitbucket-api-php/0.8.1 (https://bitbucket.org/gentlero/bitbucket-api)',
36+
'user_agent' => 'bitbucket-api-php/0.8.2 (https://bitbucket.org/gentlero/bitbucket-api)',
3737
'timeout' => 10,
3838
'verify_peer' => false
3939
);

polyfill-55.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright 2015 - 2016 Alexandru Guzinschi <alex@gentle.ro>
4+
*
5+
* This software may be modified and distributed under the terms
6+
* of the MIT license. See the LICENSE file for details.
7+
*/
8+
9+
/**
10+
* Provides functions unavailable in PHP releases prior to v5.5
11+
*/
12+
if (PHP_VERSION_ID < 50500) {
13+
if (!function_exists('json_last_error_msg')) {
14+
function json_last_error_msg()
15+
{
16+
switch (json_last_error()) {
17+
case JSON_ERROR_NONE:
18+
return 'No error';
19+
case JSON_ERROR_DEPTH:
20+
return 'Maximum stack depth exceeded';
21+
case JSON_ERROR_STATE_MISMATCH:
22+
return 'State mismatch (invalid or malformed JSON)';
23+
case JSON_ERROR_CTRL_CHAR:
24+
return 'Control character error, possibly incorrectly encoded';
25+
case JSON_ERROR_SYNTAX:
26+
return 'Syntax error';
27+
case JSON_ERROR_UTF8:
28+
return 'Malformed UTF-8 characters, possibly incorrectly encoded';
29+
default:
30+
return 'Unknown error';
31+
}
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)