Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48829 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82801 invoked from network); 18 Jun 2010 16:18:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2010 16:18:30 -0000 Authentication-Results: pb1.pair.com header.from=mls@pooteeweet.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=mls@pooteeweet.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pooteeweet.org from 188.40.37.16 cause and error) X-PHP-List-Original-Sender: mls@pooteeweet.org X-Host-Fingerprint: 188.40.37.16 hq1.backendmedia.com Linux 2.6 Received: from [188.40.37.16] ([188.40.37.16:60641] helo=hq1.backendmedia.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/73-59924-55C9B1C4 for ; Fri, 18 Jun 2010 12:18:29 -0400 Received: from localhost (unknown [127.0.0.1]) by hq1.backendmedia.com (Postfix) with ESMTP id 826C2200C194; Fri, 18 Jun 2010 16:18:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at backendmedia.com Received: from hq1.backendmedia.com ([127.0.0.1]) by localhost (hq1.backendmedia.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 87eb7FowzO6t; Fri, 18 Jun 2010 18:18:31 +0200 (CEST) Received: from [192.168.0.151] (217-162-131-234.dclient.hispeed.ch [217.162.131.234]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: mls@pooteeweet.org) by hq1.backendmedia.com (Postfix) with ESMTPSA id D56E3200C187; Fri, 18 Jun 2010 18:18:30 +0200 (CEST) Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii In-Reply-To: <914262a8630e5f4b80217ffbf0e49901@localhost> Date: Fri, 18 Jun 2010 18:18:23 +0200 Cc: internals@lists.php.net Content-Transfer-Encoding: 7bit Message-ID: <93A01763-2224-4AAD-B6EA-4F24DD611B94@pooteeweet.org> References: <4C1A6B47.4060702@mohiva.com> <4C1A7400.6010800@sugarcrm.com> <16FA8F9A-E36B-4057-BBCC-D6CC9C8D6D8B@php.net> <3C5F598B-3E72-4959-B774-2FD62C1BC99F@pooteeweet.org> <914262a8630e5f4b80217ffbf0e49901@localhost> To: Christian Kaps X-Mailer: Apple Mail (2.1081) Subject: Re: [PHP-DEV] Type hinting From: mls@pooteeweet.org (Lukas Kahwe Smith) On 18.06.2010, at 18:13, Christian Kaps wrote: > On Fri, 18 Jun 2010 16:28:31 +0200, Lukas Kahwe Smith > wrote: >> On 18.06.2010, at 16:13, Melanie Rhianna Lewis wrote: >> >>> >>> >>> On 17 Jun 2010, at 20:14, Stas Malyshev wrote: >>> >>>> Hi! >>>> >>>>> I know the discussion is about scalar type hints. But what is with a >>>>> object type hint as base for all objects? >>>> >>>> When it makes sense to accept any object, regardless of the class, but >>>> not other types? I wonder if it's really a common use-case. >>> >>> Its useful in some patterns. For example suppose you have a pattern >>> where a class wraps another class. The wrapped class could be *any* >>> class if you're modify the behaviour of some default methods (say doing >>> something like a decorator pattern). Having a type hint that > recognises >>> object vs non objects is useful. >> >> >> isnt this what interfaces are for? >> >> regards, >> Lukas Kahwe Smith >> mls@pooteeweet.org > > Sure, you can create an empty interface for this scenario but only for > self defined classes. All PHP classes can't used with this interface. and you seriously need type hints for this use case? regards, Lukas Kahwe Smith mls@pooteeweet.org