Req #71271 [Wfx]: Allow final abstract class {}
| From: | andreas at dqxtech dot net | Date: | Mon, 04 Jan 2016 05:50:49 +0000 |
| Subject: | Req #71271 [Wfx]: Allow final abstract class {} | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-198392@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71271&edit=1
ID: 71271
User updated by: andreas at dqxtech dot net
Reported by: andreas at dqxtech dot net
Summary: Allow final abstract class {}
Status: Wont fix
Type: Feature/Change Request
Package: Class/Object related
PHP Version: 7.0.2RC1
Block user comment: N
Private report: N
New Comment:
It seems this is the discussion:
https://github.com/php/php-src/pull/923
Previous Comments:
------------------------------------------------------------------------
[2016-01-04 05:43:10] andreas at dqxtech dot net
Is there any discussion I could have a look at, that explains why the RFC was discarded by most
participants?
Also, what I propose is not really the same, it is much simpler: Allow the combination of the two
keywords, with the regular natural consequences.
abstract: Cannot instantiate.
final: Cannot inherit.
I do NOT propose that a final + abstract class should only have static members.
I think it would be a bad idea to enforce this on the language level.
On the other hand, an IDE could very well notify people about the pointlessness of non-static
methods within a final abstract class.
Unlike the RFC, this simple proposal adds no confusion and no magic. Everything will behave as one
would expect.
------------------------------------------------------------------------
[2016-01-04 05:31:18] requinix@php.net
The idea was considered and declined. https://wiki.php.net/rfc/abstract_final_class
------------------------------------------------------------------------
[2016-01-04 05:21:15] andreas at dqxtech dot net
Description:
------------
It should be allowed to make a class both final and abstract, to make it a place for static methods.
There is no good reason to not allow this.
It is already possible to achieve the same or a similar effect with final + a private constructor.
But this is unnecessarily verbose.
Test script:
---------------
<?php
abstract final class C {
static function foo() {}
}
Expected result:
----------------
should work just fine.
Actual result:
--------------
Fatal error: Cannot use the final modifier on an abstract class
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71271&edit=1