Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37074 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61699 invoked from network); 17 Apr 2008 15:41:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2008 15:41:47 -0000 Authentication-Results: pb1.pair.com header.from=cschneid@cschneid.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=cschneid@cschneid.com; spf=permerror; 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:55393] helo=smtp.rim.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/EB-05127-9BF67084 for ; Thu, 17 Apr 2008 11:41:46 -0400 Received: from localhost (localhost [127.0.0.1]) by rolig.search.ch (Postfix) with ESMTP id 8B79F3F693C; Thu, 17 Apr 2008 17:41:42 +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 20929-07; Thu, 17 Apr 2008 17:41:40 +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 42D663F6937; Thu, 17 Apr 2008 17:41:40 +0200 (CEST) Message-ID: <48076FB3.1040303@cschneid.com> Date: Thu, 17 Apr 2008 17:41:39 +0200 User-Agent: Thunderbird 1.5.0.12 (X11/20060911) MIME-Version: 1.0 To: Felipe Pena CC: internals@lists.php.net References: <46ccd1ab0804170742g142ed562t4f03339da549a820@mail.gmail.com> In-Reply-To: <46ccd1ab0804170742g142ed562t4f03339da549a820@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at search.ch Subject: Re: [RFC] Strict type hints (parameter and return value) From: cschneid@cschneid.com (Christian Schneider) Felipe Pena wrote: > Well, thinking better about the behavior of type hinting, i decided to > change the proposal for strict type. I.e. don't accept numeric string > as an intenger, etc. While it is now consistent with is_int() it means we end up with strict but also stupid interfaces and hence lots of silly type conversions in application code using such a function. This is especially annoying as you normally have very few implementations of a function but lots of code calling it. You basically 'progressed' from function foo($x) { $x = (int)$x; ... } # One place where type is ensured or converted foo(42); foo(CONSTANT_42); foo($x); foo($db->x); to function foo(int $x) { ... } foo(42); foo((int)CONSTANT_42); # If you are not 100% about type foo((int)$x); # If you are not 100% about type foo((int)$db->x); # DBs normally return strings - Chris