Skip to content

Commit 8768adc

Browse files
author
Michael Kühn
committed
removed check for availability of json constants
The check for the availability of JSON_UNESCAPED_SLASHES is redundant because we already require php >= 5.5 in composer.json and the constant was introduced in PHP 5.4. Also an check for the availability of ext-json was added to ensure functions like json_encode() and the json constants are available.
1 parent 5f7043e commit 8768adc

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"require": {
3030
"php": ">=5.5",
31+
"ext-json": "*",
3132
"zendframework/zend-eventmanager": "~2.3",
3233
"zendframework/zend-http": "~2.3",
3334
"zendframework/zend-json": "~2.3",

src/ApiProblemResponse.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ApiProblemResponse extends Response
2323
*
2424
* @var int
2525
*/
26-
protected $jsonFlags = JSON_PARTIAL_OUTPUT_ON_ERROR;
26+
protected $jsonFlags;
2727

2828
/**
2929
* @param ApiProblem $apiProblem
@@ -34,9 +34,7 @@ public function __construct(ApiProblem $apiProblem)
3434
$this->setCustomStatusCode($apiProblem->status);
3535
$this->setReasonPhrase($apiProblem->title);
3636

37-
if (defined('JSON_UNESCAPED_SLASHES')) {
38-
$this->jsonFlags |= constant('JSON_UNESCAPED_SLASHES');
39-
}
37+
$this->jsonFlags = JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR;
4038
}
4139

4240
/**

0 commit comments

Comments
 (0)