Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed abandoned laminas-json #178

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 6 additions & 22 deletions src/Controller/AbstractRestfulController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +16,6 @@
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;
Expand Down Expand Up @@ -62,21 +60,15 @@ 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).
*
* Override the value in an extending class to set the default behavior
* for your class.
*
* @var int|bool
* @var bool
*/
protected $jsonDecodeType = true;

Expand Down Expand Up @@ -609,10 +601,7 @@ 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. If that is not available, raises an exception.
*
* Marked protected to allow usage from extending classes.
*
Expand All @@ -626,13 +615,8 @@ protected function jsonDecode($string)
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
));
throw new DomainException(
matbech marked this conversation as resolved.
Show resolved Hide resolved
'Unable to parse JSON request, due to missing ext/json'
);
}
}