[wp-trac] [WordPress Trac] #61860: PHPCS: Empty FOREACH statement detected
WordPress Trac
noreply at wordpress.org
Mon Aug 12 20:42:36 UTC 2024
#61860: PHPCS: Empty FOREACH statement detected
-------------------------------+------------------------------
Reporter: dhruvang21 | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Formatting | Version: 4.2.3
Severity: normal | Resolution:
Keywords: changes-requested | Focuses: docs
-------------------------------+------------------------------
Comment (by SergeyBiryukov):
@jrf @TobiasBg Since this code only runs when `$replace_pairs` has a
single element, and we have a [source:tags/6.6.1/src/wp-
includes/compat.php#L399 polyfill for array_key_first()] that also uses a
foreach loop, how about this instead?
{{{
$needle = array_key_first( $replace_pairs );
$replace = reset( $replace_pairs );
}}}
Might clarify any future confusion.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61860#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list