|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67778 Constructor overriding and derived classes
Submitted: 2014-08-05 17:05 UTC Modified: 2015-06-28 21:52 UTC
From: Assigned: stas (profile)
Status: Closed Package: PHP Language Specification
PHP Version: Irrelevant 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:
New email:
PHP Version: OS:


 [2014-08-05 17:05 UTC]

"Constructors can be overridden in a derived class by redeclaring them. However, an overriding constructor need not have the same signature as defined in the base class." This is not accurate. If there is no abstract decl for __construct in the inheritance hierarchy, then the derived class can use whatever signature it wants. If there is an abstract decl for __construct in the inheritance hierarchy, then the derived class's __construct method needs to match the signature of the abstract decl. 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-28 21:52 UTC]
Abstract is not an override, it's an implementation, since abstract is not a method definition, so there's nothing to override. You only override an existing method. I'll refine the language to emphasize this fact.
 [2015-06-28 21:52 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: stas
 [2015-06-28 21:52 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 14 19:01:28 2024 UTC