php.net |  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
Votes:7
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ww dot galen at gmail dot com
New email:
PHP Version: OS:

 

 [2013-07-07 05:19 UTC] ww dot galen at gmail dot com
Description:
------------
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:
---------------
<?php
$x = new SimpleXMLElement('<?xml version="1.0"?><a><b/><c/></a>');
var_dump(count($x), $x instanceof Countable);


Expected result:
----------------
int(2)
bool(true)


Actual result:
--------------
int(2)
bool(false)


Patches

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

Pull Requests

History

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

[1] <http://git.php.net/?p=php-src.git;a=commit;h=bfc10978eff5793a68e7aeb6144b5a2a393833f3>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC