Skip to content

Commit 300591e

Browse files
committed
refactor: apply suggestion
1 parent c96e1b0 commit 300591e

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

app/Config/Format.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ class Format extends BaseConfig
6464

6565
/**
6666
* --------------------------------------------------------------------------
67-
* JSON Formatters Depth
67+
* Maximum depth for JSON encoding.
6868
* --------------------------------------------------------------------------
6969
*
70-
* Additional options to adjust default depth JSON Encode.
70+
* This value determines how deep the JSON encoder will traverse nested structures.
7171
*/
72-
public int $jsonDepthOptions = 512;
72+
public int $jsonEncodeDepth = 512;
7373
}

system/Format/JSONFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function format($data)
4141
$options |= JSON_PRETTY_PRINT;
4242
}
4343

44-
$result = json_encode($data, $options, $config->jsonDepthOptions ?? 512);
44+
$result = json_encode($data, $options, $config->jsonEncodeDepth ?? 512);
4545

4646
if (! in_array(json_last_error(), [JSON_ERROR_NONE, JSON_ERROR_RECURSION], true)) {
4747
throw FormatException::forInvalidJSON(json_last_error_msg());

user_guide_src/source/changelogs/v4.7.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Changes
8585
*******
8686

8787
- **Cookie:** The ``CookieInterface::EXPIRES_FORMAT`` has been changed to ``D, d M Y H:i:s \G\M\T`` to follow the recommended format in RFC 7231.
88-
- **Format:** The ``Format::$jsonDepthOptions`` options to change default behavior JSON Encode.
88+
- **Format:** Added support for configuring ``json_encode()`` maximum depth via ``Config\Format::$jsonEncodeDepth``.
8989

9090
************
9191
Deprecations

user_guide_src/source/outgoing/api_responses.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ format both XML and JSON responses:
4949

5050
.. literalinclude:: api_responses/003.php
5151

52-
.. note:: Since ``v4.7.0``, you can change the default JSON formatting depth by editing **app/Config/Format.php**. The ``$jsonDepthOptions`` value defines the maximum depth, with a default of ``512``.
52+
.. note:: Since ``v4.7.0``, you can change the default JSON encoding depth by editing **app/Config/Format.php** file. The ``$jsonEncodeDepth`` value defines the maximum depth, with a default of ``512``.
5353

5454
This is the array that is used during :doc:`Content Negotiation </incoming/content_negotiation>` to determine which
5555
type of response to return. If no matches are found between what the client requested and what you support, the first

0 commit comments

Comments
 (0)