#59630 closed defect (bug) (fixed)
wp_json_encode(): rename parameters for parity with PHP Core
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.5 | Priority: | normal |
Severity: | normal | Version: | 4.1 |
Component: | General | Keywords: | has-patch |
Focuses: | coding-standards | Cc: |
Description
The wp_json_encode()
is a wrapper for the PHP native json_encode()
function with some extra safety checks.
I propose to rename the $data
parameter in the wp_json_encode()
function and associated functions to $value
and the $options
parameter to $flags
for parity with the parameter names used in PHP Core (principle of least surprise).
Ref: https://www.php.net/manual/en/function.json-encode.php
Change History (5)
This ticket was mentioned in PR #5493 on WordPress/wordpress-develop by @jrf.
15 months ago
#1
- Keywords has-patch added
#2
follow-up:
↓ 3
@
15 months ago
- Version changed from trunk to 4.1
Changing the Version to 4.1.0 which introduced wp_json_encode()
with these parameter names.
#3
in reply to:
↑ 2
@
15 months ago
Replying to hellofromTonya:
Changing the Version to 4.1.0 which introduced
wp_json_encode()
with these parameter names.
Thanks @hellofromTonya !
On that note: it may well be that the parameter names at the time of introduction were in line with PHP Core.
PHP Core has renamed a lot of parameters to better names in the run up to the release of PHP 8.0 in anticipation of supporting named parameters.
It is not inconceivable that these parameters were renamed in PHP Core as part of that exercise.
#4
@
14 months ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 57130:
@SergeyBiryukov commented on PR #5493:
14 months ago
#5
Thanks for the PR! Merged in r57130.
The
wp_json_encode()
is a wrapper for the PHP nativejson_encode()
function with some extra safety checks.This commit renames the
$data
parameter in thewp_json_encode()
function and associated functions to$value
and the$options
parameter to$flags
for parity with the parameter names used in PHP Core (principle of least surprise).Ref: https://www.php.net/manual/en/function.json-encode.php
Trac ticket: https://core.trac.wordpress.org/ticket/59630