Bug #75202 [Opn->Nab]: Interfaces shouldn't be able to define a constructor
| From: | nikic@php.net | Date: | Wed, 13 Sep 2017 14:12:41 +0000 |
| Subject: | Bug #75202 [Opn->Nab]: Interfaces shouldn't be able to define a constructor | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211131@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75202&edit=1
ID: 75202
Updated by: nikic@php.net
Reported by: kelunik@php.net
Summary: Interfaces shouldn't be able to define a constructor
-Status: Open
+Status: Not a bug
Type: Bug
Package: Class/Object related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
While constructors are generally exempt from LSP, enforcing consistent constructor signatures can be
useful in some contexts, e.g. for use by factories. This is an intentional feature and will not be
dropped.
Previous Comments:
------------------------------------------------------------------------
[2017-09-13 13:45:58] cmb@php.net
I think this issue should be discussed in internals, Niklas.
------------------------------------------------------------------------
[2017-09-13 09:34:40] kelunik@php.net
Description:
------------
Interfaces shouldn't be able to enforce a signature for
__construct. Parent
classes can't enforce that either, for classes there's no compatibility check, but
interfaces have them.
See https://3v4l.org/mSPL5 vs. https://3v4l.org/RYdFG
This is related to #50302 which I believe is a bug, even if it has been closed as not being one.
In case it's decided that this is not a bug, this bug can serve as documentation of it not
being a bug.
Expected result:
----------------
Probably a compile time error, that the interface defines __construct.
Actual result:
--------------
The interface is defined with __construct and the signature enforced in classes implementing it.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75202&edit=1