Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48828 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81362 invoked from network); 18 Jun 2010 16:13:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2010 16:13:40 -0000 Authentication-Results: pb1.pair.com header.from=christian.kaps@mohiva.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=christian.kaps@mohiva.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain mohiva.com designates 78.46.69.5 as permitted sender) X-PHP-List-Original-Sender: christian.kaps@mohiva.com X-Host-Fingerprint: 78.46.69.5 zucker.schokokeks.org Received: from [78.46.69.5] ([78.46.69.5:51543] helo=zucker.schokokeks.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CB/23-59924-03B9B1C4 for ; Fri, 18 Jun 2010 12:13:38 -0400 Received: from roundcube.schokokeks.org (localhost [::ffff:127.0.0.1]) (AUTH: LOGIN christian.kaps@mohiva.com, TLS: TLSv1/SSLv3,256bits,AES256-SHA) by zucker.schokokeks.org with esmtp; Fri, 18 Jun 2010 18:13:33 +0200 id 0000000000018010.000000004C1B9B2D.00006016 Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Date: Fri, 18 Jun 2010 18:13:33 +0200 To: internals@lists.php.net In-Reply-To: <3C5F598B-3E72-4959-B774-2FD62C1BC99F@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> Message-ID: <914262a8630e5f4b80217ffbf0e49901@localhost> X-Sender: christian.kaps@mohiva.com User-Agent: RoundCube Webmail/0.3.1 X-Mime-Autoconverted: from 8bit to 7bit by courier 0.64 Subject: Re: [PHP-DEV] Type hinting From: christian.kaps@mohiva.com (Christian Kaps) 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.