diff --git a/composer.json b/composer.json index 401e5632..fd3973f0 100644 --- a/composer.json +++ b/composer.json @@ -40,12 +40,10 @@ }, "require-dev": { "laminas/laminas-coding-standard": "^3.0.1", - "laminas/laminas-json": "^3.7", "phpunit/phpunit": "^10.5.38", "webmozart/assert": "^1.11" }, "suggest": { - "laminas/laminas-json": "(^2.6.1 || ^3.0) To auto-deserialize JSON body content in AbstractRestfulController extensions, when json_decode is unavailable", "laminas/laminas-log": "^2.9.1 To provide log functionality via LogFilterManager, LogFormatterManager, and LogProcessorManager", "laminas/laminas-mvc-console": "laminas-mvc-console provides the ability to expose laminas-mvc as a console application", "laminas/laminas-mvc-i18n": "laminas-mvc-i18n provides integration with laminas-i18n, including a translation bridge and translatable route segments", diff --git a/src/Controller/AbstractRestfulController.php b/src/Controller/AbstractRestfulController.php index 2e1d717a..aa14de33 100644 --- a/src/Controller/AbstractRestfulController.php +++ b/src/Controller/AbstractRestfulController.php @@ -4,7 +4,6 @@ use Laminas\Http\Header\ContentType; use Laminas\Http\Request as HttpRequest; -use Laminas\Json\Json; use Laminas\Mvc\Exception; use Laminas\Mvc\Exception\DomainException; use Laminas\Mvc\Exception\InvalidArgumentException; @@ -17,10 +16,8 @@ use function array_key_exists; use function array_shift; use function call_user_func; -use function class_exists; use function count; use function explode; -use function function_exists; use function get_debug_type; use function is_array; use function is_callable; @@ -62,13 +59,7 @@ abstract class AbstractRestfulController extends AbstractController protected $identifierName = 'id'; /** - * Flag to pass to json_decode and/or Laminas\Json\Json::decode. - * - * The flags in Laminas\Json\Json::decode are integers, but when evaluated - * in a boolean context map to the flag passed as the second parameter - * to json_decode(). As such, you can specify either the Laminas\Json\Json - * constant or the boolean value. By default, starting in v3, we use - * the boolean value, and cast to integer if using Laminas\Json\Json::decode. + * Flag to pass to json_decode. * * Default value is boolean true, meaning JSON should be cast to * associative arrays (vs objects). @@ -76,7 +67,7 @@ abstract class AbstractRestfulController extends AbstractController * Override the value in an extending class to set the default behavior * for your class. * - * @var int|bool + * @var bool */ protected $jsonDecodeType = true; @@ -609,30 +600,15 @@ protected function processBodyContent(mixed $request) /** * Decode a JSON string. * - * Uses json_decode by default. If that is not available, checks for - * availability of Laminas\Json\Json, and uses that if present. - * - * Otherwise, raises an exception. + * Uses json_decode by default. * * Marked protected to allow usage from extending classes. * * @param string $string * @return mixed - * @throws Exception\DomainException If no JSON decoding functionality is available. */ protected function jsonDecode($string) { - if (function_exists('json_decode')) { - return json_decode($string, (bool) $this->jsonDecodeType); - } - - if (class_exists(Json::class)) { - return Json::decode($string, (int) $this->jsonDecodeType); - } - - throw new DomainException(sprintf( - 'Unable to parse JSON request, due to missing ext/json and/or %s', - Json::class - )); + return json_decode($string, (bool) $this->jsonDecodeType); } }