|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73981 __construct not being called on extensions of DOM base classes
Submitted: 2017-01-23 18:13 UTC Modified: 2018-07-27 12:24 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: work at timothytown dot com Assigned:
Status: Verified Package: DOM XML related
PHP Version: 7.1.1 OS: windows
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: work at timothytown dot com
New email:
PHP Version: OS:


 [2017-01-23 18:13 UTC] work at timothytown dot com
When a class is registered to a DOMDocument via the registerNodeClass method, the assigned class is used to instance the return object from the DOMDOcument. However, the construct method of that class is not called. 

Test script:
class SillyTestClass extends DOMElement{
    public $foo=null;
    public function __construct($name,$value=null,$namespace=null){
        echo "calling child construct....";
    public function sayHello(){
        echo "Why, hello there!";

$doc=new DOMDocument();

//THIS IS STILL NULL:( Never set by construct, no message saying construct was called either  
echo $doc->documentElement->firstChild->foo; 

Expected result:
output "calling child construct..." //printed from child _construct
output "Why, hello there!" //printed from child method sayHello()
output "bar" //the value of child property after being assigned in constructor

Actual result:
//only the sayHello() method fires; construct doesn't happen
Why, hello there;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-24 11:30 UTC]
-Package: *General Issues +Package: DOM XML related
 [2018-07-27 12:24 UTC]
-Status: Open +Status: Verified
 [2018-07-27 12:24 UTC]
Confirmed: <>.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jan 28 06:01:26 2021 UTC