[wp-trac] [WordPress Trac] #43583: Introduce new PHP cross-version compat function `is_countable()`
WordPress Trac
noreply at wordpress.org
Sat May 5 14:47:17 UTC 2018
#43583: Introduce new PHP cross-version compat function `is_countable()`
-------------------------------------------------+-------------------------
Reporter: jrf | Owner:
| SergeyBiryukov
Type: enhancement | Status: closed
Priority: normal | Milestone: 4.9.6
Component: General | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests commit | Focuses:
needs-dev-note dev-feedback |
-------------------------------------------------+-------------------------
Changes (by ayeshrajans):
* keywords: has-patch has-unit-tests commit needs-dev-note => has-patch
has-unit-tests commit needs-dev-note dev-feedback
Comment:
I maintain a standalone PHP polyfill for the `is_countable` function, and
Craig, who was involved in the PHP RFC to bring this function to PHP 7.3
opened a PR there about an edge-case: https://github.com/Ayesh
/is_countable-polyfill/pull/4
Turns out PHP classes added by extensions can internally implement a
`count_elements` handler that allows PHP engine to successfully return a
value without triggerring any warnings, which makes all objects from that
class are countable.
I tested this with a compiled php-src master.
The attached patch updates the is_countable compat code and expand its
test coverage for this edge-case. As of now, `SimpleXMLElement` and
`ResourceBundle` from Intl extension are the only classes that implement
this handler. The patch is loosely based on https://github.com/Ayesh
/is_countable-polyfill/commit/d8c20caa4abd8ef8de5128d3a62d4ee385f51174.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43583#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list