[wp-trac] [WordPress Trac] #56499: count() used in the loop condition

WordPress Trac noreply at wordpress.org
Fri Sep 2 14:29:21 UTC 2022


#56499: count() used in the loop condition
-------------------------------------+-------------------------------
 Reporter:  krunal265                |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Administration           |     Version:  6.0
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  coding-standards
-------------------------------------+-------------------------------

Comment (by SergeyBiryukov):

 Hi there, welcome back to WordPress Trac! Thanks for the ticket.

 Do you get any PHPCS warnings from this file? When running WPCS checks for
 WordPress core with the default [source:tags/6.0/phpcs.xml.dist
 phpcs.xml.dist] file, `wp-admin/includes/dashboard.php` appears to pass
 all the checks successfully in my testing. Could you clarify how you run
 the PHPCS checks?

 As noted above, the `$comments` array is changed inside the loop, so the
 value needs to be recalculated on each iteration, and the patch may not
 work as expected. That said, I agree that the condition could probably be
 simplified.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56499#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list