Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36903 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24402 invoked from network); 9 Apr 2008 13:21:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Apr 2008 13:21:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=cschneid@cschneid.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=cschneid@cschneid.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain cschneid.com from 195.141.85.117 cause and error) X-PHP-List-Original-Sender: cschneid@cschneid.com X-Host-Fingerprint: 195.141.85.117 uf1.search.ch Linux 2.6 Received: from [195.141.85.117] ([195.141.85.117:43611] helo=smtp.rim.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/CB-04949-6C2CCF74 for ; Wed, 09 Apr 2008 09:21:12 -0400 Received: from localhost (localhost [127.0.0.1]) by rolig.search.ch (Postfix) with ESMTP id 46EE5DB3F3; Wed, 9 Apr 2008 15:21:07 +0200 (CEST) Received: from smtp.rim.ch ([127.0.0.1]) by localhost (search.ch [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 24890-03; Wed, 9 Apr 2008 15:21:04 +0200 (CEST) Received: from [192.168.1.72] (ultrafilter-i [192.168.85.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by rolig.search.ch (Postfix) with ESMTP id 50B0D24D4AA; Wed, 9 Apr 2008 15:21:04 +0200 (CEST) Message-ID: <47FCC2BF.10400@cschneid.com> Date: Wed, 09 Apr 2008 15:21:03 +0200 User-Agent: Thunderbird 1.5.0.12 (X11/20060911) MIME-Version: 1.0 To: Derick Rethans CC: PHP Developers Mailing List References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at search.ch Subject: Re: Missing signature violation warnings suck. From: cschneid@cschneid.com (Christian Schneider) Derick Rethans wrote: > I've been working on some code, while developing on PHP 5.3. The code > resembles the following structure: > > interface ezcSearchQuery > { > public function limit( $limit, $offset = '' ); > } > > class ezcSearchFindQuerySolr implements ezcSearchQuery > { > public function limit( $limit = 10, $offset = 0 ) > { > $this->limit = $limit; > $this->offset = $offset; > } > } > ?> > > No problems at all while development, no warnings, no errors. Now when I > deployed this on a PHP 5.2 machine it bombed out, with the following > *correct* message: I disagree, the error message with 5.2 was wrong IMHO, see below for reason. > Fatal error: Declaration of ezcSearchFindQuerySolr::limit() must be > compatible with that of ezcSearchQuery::limit() in /tmp/tmp/index.php on > line 11 > > And this really sucks. I made a mistake in my code (wrongly implemented > interface) and I get no warning (not even E_STRICT)... and then deploy Can you elaborate in how your implementation is wrong? ezcSearchFindQuerySolr accepts the same arguments ezcSearchQuery does so it is a valid implementation of the interface. Every user of the ezcSearchQuery interface can be given an instance of ezcSearchFindQuerySolr and it will work, so the http://en.wikipedia.org/wiki/Liskov_substitution_principle is fulfilled. This principle does not mean that all users of a specific implementation have to be able to be given another implementation of the interface and be happy with it. You can e.g. have class ezcOrderedSearchQuery implements ezcSearchQuery { public function limit( $limit, $offset = 0, $order = "ASC" ) { ... } } class ezcFilteredSearchQuery implements ezcSearchQuery { public function limit( $limit, $offset = 0 ) { ... } public function filter( $filter ) { } } ... which are in the same boat: ezcOrderedSearchQuery and ezcFilteredSearchQuery can be used as ezcSearchQuery but not necessarily the other way around. - Chris