Skip to content

Commit 7d78dab

Browse files
committed
Removed abandoned laminas-json
Per PHP documentation, json_decode is always available starting with PHP 8.0 "As of PHP 8.0.0, the JSON extension is a core PHP extension, so it is always enabled." Reference: https://www.php.net/manual/en/json.installation.php Signed-off-by: Mathias Berchtold <[email protected]>
1 parent 5c5087e commit 7d78dab

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

composer.json

-2
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@
4040
},
4141
"require-dev": {
4242
"laminas/laminas-coding-standard": "^3.0.1",
43-
"laminas/laminas-json": "^3.7",
4443
"phpunit/phpunit": "^10.5.38",
4544
"webmozart/assert": "^1.11"
4645
},
4746
"suggest": {
48-
"laminas/laminas-json": "(^2.6.1 || ^3.0) To auto-deserialize JSON body content in AbstractRestfulController extensions, when json_decode is unavailable",
4947
"laminas/laminas-log": "^2.9.1 To provide log functionality via LogFilterManager, LogFormatterManager, and LogProcessorManager",
5048
"laminas/laminas-mvc-console": "laminas-mvc-console provides the ability to expose laminas-mvc as a console application",
5149
"laminas/laminas-mvc-i18n": "laminas-mvc-i18n provides integration with laminas-i18n, including a translation bridge and translatable route segments",

src/Controller/AbstractRestfulController.php

+6-21
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Laminas\Http\Header\ContentType;
66
use Laminas\Http\Request as HttpRequest;
7-
use Laminas\Json\Json;
87
use Laminas\Mvc\Exception;
98
use Laminas\Mvc\Exception\DomainException;
109
use Laminas\Mvc\Exception\InvalidArgumentException;
@@ -62,21 +61,15 @@ abstract class AbstractRestfulController extends AbstractController
6261
protected $identifierName = 'id';
6362

6463
/**
65-
* Flag to pass to json_decode and/or Laminas\Json\Json::decode.
66-
*
67-
* The flags in Laminas\Json\Json::decode are integers, but when evaluated
68-
* in a boolean context map to the flag passed as the second parameter
69-
* to json_decode(). As such, you can specify either the Laminas\Json\Json
70-
* constant or the boolean value. By default, starting in v3, we use
71-
* the boolean value, and cast to integer if using Laminas\Json\Json::decode.
64+
* Flag to pass to json_decode.
7265
*
7366
* Default value is boolean true, meaning JSON should be cast to
7467
* associative arrays (vs objects).
7568
*
7669
* Override the value in an extending class to set the default behavior
7770
* for your class.
7871
*
79-
* @var int|bool
72+
* @var bool
8073
*/
8174
protected $jsonDecodeType = true;
8275

@@ -609,10 +602,7 @@ protected function processBodyContent(mixed $request)
609602
/**
610603
* Decode a JSON string.
611604
*
612-
* Uses json_decode by default. If that is not available, checks for
613-
* availability of Laminas\Json\Json, and uses that if present.
614-
*
615-
* Otherwise, raises an exception.
605+
* Uses json_decode by default. If that is not available, raises an exception.
616606
*
617607
* Marked protected to allow usage from extending classes.
618608
*
@@ -626,13 +616,8 @@ protected function jsonDecode($string)
626616
return json_decode($string, (bool) $this->jsonDecodeType);
627617
}
628618

629-
if (class_exists(Json::class)) {
630-
return Json::decode($string, (int) $this->jsonDecodeType);
631-
}
632-
633-
throw new DomainException(sprintf(
634-
'Unable to parse JSON request, due to missing ext/json and/or %s',
635-
Json::class
636-
));
619+
throw new DomainException(
620+
'Unable to parse JSON request, due to missing ext/json'
621+
);
637622
}
638623
}

0 commit comments

Comments
 (0)