php.net |  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
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: michaelduff at yahoo dot com
New email:
PHP Version: OS:

 

 [2012-08-18 19:36 UTC] michaelduff at yahoo dot com
Description:
------------
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?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-21 05:47 UTC] laruence@php.net
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] laruence@php.net
-Status: Open +Status: Duplicate
 [2012-11-24 16:06 UTC] laruence@php.net
dup to #46684
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC