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

From: Date: Wed, 13 Sep 2017 15:06:18 +0000
Subject: Bug->Doc #75202 [Nab->Ana]: Interfaces shouldn't be able to define a constructor
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14975@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: Not a bug +Status: Analyzed -Type: Bug +Type: Documentation Problem Package: Class/Object related PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > 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. Previous Comments: ------------------------------------------------------------------------ [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 (#14975) next »