[wp-trac] [WordPress Trac] #58874: Code Modernization: Consider using the null coalescing operator.
WordPress Trac
noreply at wordpress.org
Sun Jul 23 15:44:32 UTC 2023
#58874: Code Modernization: Consider using the null coalescing operator.
-----------------------------------+---------------------
Reporter: costdev | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 6.4
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch 2nd-opinion | Focuses:
-----------------------------------+---------------------
Comment (by SergeyBiryukov):
Replying to [comment:4 jrf]:
> I also wonder why this should be changed for existing code (as it make
backports harder). What about just ''allowing it'' for ''new'' code and
for code ''which is being patched anyway'' ?
> That way, the impact on backports will be much more limited, while we
can still use the new shiny in code actually being worked on. 😁
I would very much prefer consistency in the code, i.e. using the same
pattern for the same thing across all codebase, to avoid confusion, or
adding a comment if that's not feasible in a particular place for some
reason.
In this case, using the null coalescing operator (`??`) anywhere in the
file appears to cause a parse error on PHP 5.6, so it would be trivial to
catch if it's accidentally backported to an older branch.
I think only allowing it for new code does not automatically make
backports easier, as some parts of new code can occasionally be backported
too as part of bug fixes or security fixes. So I believe the required PHP
version bump in 6.3 is something we'll have to keep in mind anyway when
doing backports, pretty much like with the previous version bump to PHP
5.6.20 in WP 5.2.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58874#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list