[wp-trac] [WordPress Trac] #43583: Introduce new PHP cross-version compat function `is_countable()`

WordPress Trac noreply at wordpress.org
Sat May 5 16:26:06 UTC 2018


#43583: Introduce new PHP cross-version compat function `is_countable()`
-------------------------------------------------+-------------------------
 Reporter:  jrf                                  |       Owner:
                                                 |  SergeyBiryukov
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  4.9.6
Component:  General                              |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-dev-  |     Focuses:
  note needs-refresh                             |
-------------------------------------------------+-------------------------
Changes (by jrf):

 * keywords:  has-patch has-unit-tests needs-dev-note dev-feedback => has-
     patch has-unit-tests needs-dev-note needs-refresh


Comment:

 @ayeshrajans Thank you for this additional input and the updated patch.

 I've just read up on the latest discussion threads about this in php-src
 and other polyfills and agree this case should be covered by the WP compat
 polyfill.

 While hard-coding the class names is not pretty, it does seem the only
 viable way to cover this properly at this time.

 Regarding the updated patch:
 * The `is_object()` check is superfluous.
 * The `\` to indicate the global namespace for the interface/class names
 needs to be removed. WP still supports PHP 5.2 and this would cause a
 parse error for PHP 5.2.
 * Making this a proper multi-line `return` with one condition on each line
 seems prudent for readability as the line is getting quite long.
 * I'd like to suggest adding an additional unit test covering
 `ResourceBundle` as this is currently not covered by any test.

 https://github.com/symfony/polyfill/pull/119/files looks like a quite
 clean version of what I'm suggesting.

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


More information about the wp-trac mailing list