|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #66688 Direct invokation of a static method inside an abstract class
Submitted: 2014-02-10 18:51 UTC Modified: 2018-04-08 17:45 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: nikola at petkanski dot com Assigned:
Status: Suspended Package: Class/Object related
PHP Version: 5.4.25 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: nikola at petkanski dot com
New email:
PHP Version: OS:


 [2014-02-10 18:51 UTC] nikola at petkanski dot com
From manual page:

Invoking static method of abstract class should be removed.

What interfaces are?
- A mean to ensure all implementation have the same methods implemented.

What is an abstract class?
- It is a interface that can also include some concrete methods.

Is it right for the developer to be able to invoke a static method of an interface?
- I think not.

The GoF teach us to rely on abstract classes and interfaces to hide differences between subclasses from clients.
- Interface defines an object’s use (protocol)
- Implementation defines particular policy

I don't think one should be able to call some abstract logic that is defined inside an abstract class, without even inheriting the class itself.

This post from the mailing list seem relevant:

Perhaps there are some reasons behind this behavior. However, the language evolves and I think it is time for this one to go.

Test script:

Expected result:
It should display an error that one cannot invoke abstract class methods.

Actual result:
It just works, while it should not.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-04-08 17:45 UTC]
-Status: Open +Status: Suspended
 [2018-04-08 17:45 UTC]
This appears to be rather a feature request than a doc bug.

However, changing this behavior[1] would require the RFC
process[2] due to huge BC break.  Please go ahead and start it!
For the time being I'm suspending this ticket.

[1] <>
[2] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 03:01:28 2024 UTC