Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29905 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74885 invoked by uid 1010); 29 May 2007 22:47:43 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 74870 invoked from network); 29 May 2007 22:47:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 May 2007 22:47:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain php.net from 85.214.94.56 cause and error) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Received: from [85.214.94.56] ([85.214.94.56:43818] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/DA-10662-E8DAC564 for ; Tue, 29 May 2007 18:47:42 -0400 Received: from baumbart.mbo (dslb-084-063-023-012.pools.arcor-ip.net [84.63.23.12]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 6F0FF1B3613; Wed, 30 May 2007 00:47:39 +0200 (CEST) Date: Wed, 30 May 2007 00:47:47 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <95336619.20070530004747@marcus-boerger.de> To: Emil Ivanov CC: internals@lists.php.net In-Reply-To: <57.79.10662.276AC564@pb1.pair.com> References: <57.79.10662.276AC564@pb1.pair.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] function overriding and class inheritance From: helly@php.net (Marcus Boerger) Hello Emil, learn inheritance rules! And besides PHP follows strict is_a rules. Even if PHP weren't following strict is_a rules: Every Work2 is a Work1 so and so any place that uses with Work1 objects can take Work2 objects. Now "$o->f1($c);" might be using a $o being a work1 or a work2. That means either f1(C1) or f1(C2). The more general one is C1. So Work2::f1(C2) must be wrong becasue it no longer accepts C1. But following is_a rules (even non strict) it needs to. So the code must be wrong. If you need a book to understand the rules I could direct you but I don't recomment reading it really.... best regards marcus Wednesday, May 30, 2007, 12:17:20 AM, you wrote: > Hi, > I'll try get straight to the point: > class C1 {} > class C2 extends C1 {} > abstract class Work1 { > public function f1(C1 $c); > } > class Work2 extends Work1 { > public function f1(C2 $c); > } > Here I get an an error regarding the prototype missmatch. > Wouldn't it be nice to be able to tighted the requirement - C2 is still C1? > Regards, > Emil Ivanov Best regards, Marcus