php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67777 Method overriding and derived classes
Submitted: 2014-08-05 17:01 UTC Modified: 2014-11-27 10:44 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: joelm@php.net Assigned:
Status: Closed Package: PHP Language Specification
PHP Version: Irrelevant 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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: joelm@php.net
New email:
PHP Version: OS:

 

 [2014-08-05 17:01 UTC] joelm@php.net
Description:
------------
https://github.com/php/php-langspec/blob/master/spec/14-classes.md#general

"Methods and properties from a base class can be overridden in a derived class by redeclaring them with the same signature defined in the base class." This is not accurate. When a derived class overrides a method, if there is no abstract decl (either abstract decl in an abstract parent or a decl in an implemented interface) in the inheritance hierarchy then whatever signature you want can be used for the derived method. If there is an abstract decl in the inheritance hierarchy, then the derived method's signature must match the signature of the abstract decl. 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-05 17:04 UTC] joelm@php.net
-Summary: Overriding and derived classes +Summary: Method overriding and derived classes
 [2014-11-27 10:44 UTC] jpauli@php.net
Is this a PHP bug ?
 [2014-11-27 13:01 UTC] cmbecker69 at gmx dot de
> When a derived class overrides a method, if there is no abstract
> decl (either abstract decl in an abstract parent or a decl in an
> implemented interface) in the inheritance hierarchy then
> whatever signature you want can be used for the derived method.

In this case, however, the derived class doesn't *override* a
method, but rather it *introduces* a new method.
 [2015-06-28 21:48 UTC] stas@php.net
Automatic comment on behalf of smalyshev@gmail.com
Revision: http://git.php.net/?p=php-langspec.git;a=commit;h=a763e15f705de443d1529e50e479bf86c5f0d7be
Log: Fix bug #67777
 [2015-06-28 21:48 UTC] stas@php.net
-Status: Open +Status: Closed
 [2015-06-28 23:20 UTC] stas@php.net
Automatic comment on behalf of smalyshev@gmail.com
Revision: http://git.php.net/?p=php-langspec.git;a=commit;h=a763e15f705de443d1529e50e479bf86c5f0d7be
Log: Fix bug #67777
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jan 29 08:03:34 2022 UTC