Doc #75202 [Ana->Csd]: Interfaces shouldn't be able to define a constructor

From: Date: Wed, 13 Sep 2017 15:08:03 +0000
Subject: Doc #75202 [Ana->Csd]: Interfaces shouldn't be able to define a constructor
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14976@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: cmb@php.net Reported by: kelunik@php.net Summary: Interfaces shouldn't be able to define a constructor -Status: Analyzed +Status: Closed Type: Documentation Problem Package: Class/Object related PHP Version: Irrelevant Assigned To: cmb Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2017-09-13 15:07:44] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&revision=343082 Log: Fixed bug #75202 (Interfaces shouldn't be able to define a constructor) We document that interfaces allow constructors to be declared. ------------------------------------------------------------------------ [2017-09-13 15:06:17] cmb@php.net > In case it's decided that this is not a bug, this bug can serve > as documentation of it not being a bug. Switching to doc issue. ------------------------------------------------------------------------ [2017-09-13 14:12:40] nikic@php.net 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. ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#14976) next »