[wp-trac] [WordPress Trac] #43374: PHP 7.2 Warning: count(): Parameter must be an array or an object that implements Countable in /wp-includes/theme.php on line 356

WordPress Trac noreply at wordpress.org
Wed Feb 21 23:22:03 UTC 2018


#43374: PHP 7.2 Warning: count(): Parameter must be an array or an object that
implements Countable in /wp-includes/theme.php on line 356
-----------------------------+------------------------------
 Reporter:  burlingtonbytes  |       Owner:
     Type:  defect (bug)     |      Status:  closed
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Themes           |     Version:  4.9.4
 Severity:  minor            |  Resolution:  duplicate
 Keywords:                   |     Focuses:
-----------------------------+------------------------------

Comment (by jrf):

 > If $wp_theme_directories should always be an array, then this
 conditional addresses the issue more comprehensively:
 > `if ( empty($wp_theme_directories) || ( is_array($wp_theme_directories)
 && count($wp_theme_directories) <= 1 ) ) {`

 Yes, however, now you're using a superfluous condition as the `empty()` is
 not needed is you first do an `is_array()`. Rewriting to the below would
 be simpler: (presuming `$wp_theme_directories` is always defined,
 otherwise an `isset()` would still be needed)

 `if ( ! is_array( $wp_theme_directories ) || count( $wp_theme_directories
 ) <= 1 ) ) {`

 > I may be missing something but I do not believe #42814 addresses this.

 AFAIK ticket #42814 is intended as the master ticket for these type of
 warnings, so I would suggest continuing the discussion there.

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


More information about the wp-trac mailing list