|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62858 Please remove 'final' restriction on SimpleXMLElement::__construct
Submitted: 2012-08-18 19:36 UTC Modified: 2012-11-24 16:06 UTC
From: michaelduff at yahoo dot com Assigned:
Status: Duplicate Package: SimpleXML related
PHP Version: 5.4.6 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: michaelduff at yahoo dot com
New email:
PHP Version: OS:


 [2012-08-18 19:36 UTC] michaelduff at yahoo dot com
The __construct() method on SimpleXMLElement is marked 'final', which prevents extension of the class for, say, XML-format-specific objects which augment otherwise empty incoming XML data.

The current workaround is to use __get and __set and company (which unfortunately means <?= $obj instanceof SimpleXMLElement ?> fails), and which is much slower -- or to use a static factory method which forces some XML in there (which is syntactically ugly imo.)

Not to shoot my request in the foot, but I forsee possible issues with these functions:

- simplexml_import_dom ( $node [, $class_name ] )
- simplexml_load_file ( string $filename [, string $class_name ] ... )
- simplexml_load_string ( string $data [, string $class_name ] ... )

However, perhaps it would suffice to require 'a compatible function signature' rather than to mark it final?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-21 05:47 UTC]
there must be some reason for the author mark the constructor as final, like some 
work must be done before any user access to it.
 [2012-11-24 15:01 UTC] anthon dot pang at gmail dot com
Dupe of #46684
 [2012-11-24 16:06 UTC]
-Status: Open +Status: Duplicate
 [2012-11-24 16:06 UTC]
dup to #46684
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue May 30 18:03:41 2023 UTC