|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65215 SimpleXMLElement could register as implementing Countable
Submitted: 2013-07-07 05:19 UTC Modified: 2019-05-31 17:23 UTC
Avg. Score:3.9 ± 0.8
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:0 (0.0%)
From: ww dot galen at gmail dot com Assigned: cmb (profile)
Status: Closed Package: SimpleXML related
PHP Version: 5.5.0 OS:
Private report: No CVE-ID: None
 [2013-07-07 05:19 UTC] ww dot galen at gmail dot com
SimpleXMLElement is essentially a Countable (it matches the signature of the 
interface), but doesn't register as implementing it.

The attached (untested) patch should register SimpleXMLElement as a Countable if 
SPL is also being built. It does not cover the case where someone builds SPL as a 
shared extension (does anyone do that?).

Test script:
$x = new SimpleXMLElement('<?xml version="1.0"?><a><b/><c/></a>');
var_dump(count($x), $x instanceof Countable);

Expected result:

Actual result:


simplexml_countable.patch (last revision 2013-07-07 05:24 UTC by ww dot galen at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-31 17:23 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2019-05-31 17:23 UTC]
This request has been implemented[1], and SimpleXMLElement
implements Countable as of PHP 7.4.

[1] <;a=commit;h=bfc10978eff5793a68e7aeb6144b5a2a393833f3>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 20:01:30 2024 UTC