[wp-trac] [WordPress Trac] #51553: PHP 8.0: code improvements to allow for named parameters in function calls
WordPress Trac
noreply at wordpress.org
Wed Dec 2 14:06:07 UTC 2020
#51553: PHP 8.0: code improvements to allow for named parameters in function calls
-------------------------------------------------+-------------------------
Reporter: jrf | Owner: (none)
Type: task (blessed) | Status: new
Priority: normal | Milestone: Future
| Release
Component: General | Version:
Severity: normal | Resolution:
Keywords: php8 has-patch 2nd-opinion dev- | Focuses: coding-
feedback needs-docs needs-codex | standards
-------------------------------------------------+-------------------------
Changes (by azaozz):
* keywords: php8 needs-dev-note has-patch => php8 has-patch 2nd-opinion
dev-feedback needs-docs needs-codex
* milestone: 5.7 => Future Release
Comment:
Replying to [comment:12 jrf]:
> I'd suggest taking that one step further and would like to recommend
very explicitly stating that "WP will NOT support named parameters for the
time being and that it will be announced when this will be supported at a
later point in time".
This!! By far the most prudent approach for the time being.
Of course this will have to be reviewed again in a year or two, when PHP
8.0+ becomes more "mainstream".
> Task 1 is already finished for all WP native classes. See the attached
patch I created four weeks ago.
Looking at https://github.com/WordPress/wordpress-develop/pull/612/files,
the changes there make the code less self-documenting, less
intuitive/readable.
True, picking good, intuitive, helpful function, var, param, arg, etc.
names when writing core is probably one of the hardest tasks. Been feeling
"stuck" at that pretty often :)
Not claiming that WP has the best, most helpful, self-documenting names,
but they are pretty good in most cases. Renaming instances of `WP_Post`,
`WP_Term`, `WP_Comment`, `WP_Theme`, `WP_User`, etc. from `$post`,
`$page`, `$category`, `$tag`, `$comment`, `$user`, etc. to `$item` or
`$data_object` is a big step backwards, and frankly the trade-off doesn't
look acceptable imho.
A new language feature that demands or requires reduced/diminished code
readability should simply be rejected, especially if the benefits are
somewhat limited, and it brings a lot of back-compat
problems/considerations.
Changing this to future-release in the hope that more acceptable
patterns/ways to handle this may emerge once PHP 8.0 is widely used.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51553#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list