Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34401 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32499 invoked by uid 1010); 4 Jan 2008 13:22:23 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 32484 invoked from network); 4 Jan 2008 13:22:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2008 13:22:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=sam@sambarrow.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sam@sambarrow.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain sambarrow.com from 205.234.132.11 cause and error) X-PHP-List-Original-Sender: sam@sambarrow.com X-Host-Fingerprint: 205.234.132.11 scottsdale.servershost.net Received: from [205.234.132.11] ([205.234.132.11:51125] helo=scottsdale.servershost.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 98/40-29353-D033E774 for ; Fri, 04 Jan 2008 08:22:22 -0500 Received: from [98.172.154.66] (port=51811 helo=[10.200.100.14]) by scottsdale.servershost.net with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.68) (envelope-from ) id 1JAmV8-00084X-11; Fri, 04 Jan 2008 07:22:18 -0600 To: Alain Williams Cc: Gregory Beaver , internals Mailing List In-Reply-To: <20080104105558.GC7861@mint.phcomp.co.uk> References: <477DB7BF.10201@chiaraquartet.net> <20080104105558.GC7861@mint.phcomp.co.uk> Content-Type: text/plain Date: Fri, 04 Jan 2008 08:20:47 -0500 Message-ID: <1199452847.15292.92.camel@sbarrow-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Antivirus-Scanner: Clean mail though you should still use an Antivirus X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - scottsdale.servershost.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - sambarrow.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] type hinting From: sam@sambarrow.com (Sam Barrow) On Fri, 2008-01-04 at 10:55 +0000, Alain Williams wrote: > On Thu, Jan 03, 2008 at 10:36:15PM -0600, Gregory Beaver wrote: > > Hi all, > > > > As someone who has dealt with many scripts written by others as well as > > many of my own in a large-scale project (PEAR). I can say with absolute > > certainty that scalar type hints would not make my job easier. > > > > In fact, it would make it harder. Many of the functions I work with > > require varied input and almost always require some kind of validation > > of that input. A built-in procedure that would either end execution > > with a fatal error or suddenly jump execution to a global error handler > > that has no idea of the context in which the error was triggered is > > almost as useful to me as a PHP extension that runs the pump on an > > You are missing the point. > If you want your function to take an argument of arbitrary type, then > you simply don't give a type hint[**] > > [**] I suppose that we might implement the type hint 'mixed' which would > have the same effect as no type hint. Some people might like this from > the 'internal documentation' point of view. I was thinking about this, a "mixed" type hint which doesn't do anything. Would be very easy to add. > > Where is the increased value? Saving a few keystrokes of validation? > > No. You still need to validate the input for range, or is_numeric() or > > No. The point is NOT to save input ($_GET, etc) validation -- that will > still need to be done; the point is to help pick up programming errors > where you accidentally get the type wrong. > > Granted: some idiots will use it as cheap input validation, but it is difficult > to help some people. Exactly. This is not intended for $_REQUEST stuff. This is intended for internal function interaction, configuration variables, etc. All post/get data is inputted as strings, so this doesn't apply there.