Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:9387 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77202 invoked by uid 1010); 19 Apr 2004 16:34:13 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 77178 invoked from network); 19 Apr 2004 16:34:12 -0000 Received: from unknown (HELO mail.mbobo.org) (213.133.123.182) by pb1.pair.com with SMTP; 19 Apr 2004 16:34:12 -0000 Received: from localhost (localhost [127.0.0.1]) by mail.mbobo.org (Postfix) with ESMTP id C7C53575F5A; Mon, 19 Apr 2004 18:34:11 +0200 (CEST) Received: from mail.mbobo.org ([127.0.0.1]) by localhost (debian [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 10182-10; Mon, 19 Apr 2004 18:34:11 +0200 (CEST) Received: from greygoose (adsl-68-120-96-254.dsl.sntc01.pacbell.net [68.120.96.254]) by mail.mbobo.org (Postfix) with ESMTP id 2E78D575971; Mon, 19 Apr 2004 18:34:10 +0200 (CEST) To: , Date: Mon, 19 Apr 2004 09:31:10 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 In-Reply-To: <5.1.0.14.2.20040419112627.03efaa00@localhost> Thread-Index: AcQmC1s2FcJykLRjRrySYnFySSZx9gAIDOfw Message-ID: <20040419163410.2E78D575971@mail.mbobo.org> X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at mbobo.org Subject: RE: [PHP-DEV] Interface inheritance From: sterling@apache.org ("Sterling Hughes") References: <5.1.0.14.2.20040419112627.03efaa00@localhost> I agree. Interfaces are useless if you can't guarantee that a class actually implements them. Violating an interface is violating a contract and it should be an compile error - indeed, when coding I mostly rely on not properly implementing interfaces to be a compile error. -Sterling -----Original Message----- From: Zeev Suraski [mailto:zeev@zend.com] Sent: Monday, April 19, 2004 1:49 AM To: internals@lists.php.net Subject: [PHP-DEV] Interface inheritance All, Yesterday, someone complained that classes that implement interfaces succeed in doing so even when they don't satisfy the prototypes. While this does cause an E_STRICT message to be emitted, it would go unnoticed in most cases, as E_STRICT is off by default, in some cases - even when people think it's on. I believe that this behavior is wrong. I believe that classes should not be allowed to say they implement an interface X, unless they actually implement all of the methods in that interface with methods that are compatible with its prototypes. Reasoning: - Interfaces (and for that matter, abstract classes) are a new feature in PHP 5, used solely to enforce implementing classes to abide to the prototypes. There's no issue of downwards compatibility, and there's no other use case. - Without this, the whole mechanism of class type hints is rendered useless. With it, it gives users the full power of class type hints (and instanceof, for that matter) - because they always have the option of adding an interface for their base classes. Suggested behavior: Any method that implements (directly or indirectly) an interface method or an abstract method, will have implementation checks fully enforced, with an E_COMPILE_ERROR emitted in case of an error. Behavior for methods that override regular parent methods, that do not have interface/abstract prototypes, will not change (E_STRICT message). Comments welcome - we'd like to sort this out before RC2... Zeev -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php