Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34452 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29089 invoked by uid 1010); 4 Jan 2008 19:07:58 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 29068 invoked from network); 4 Jan 2008 19:07:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2008 19:07:57 -0000 Authentication-Results: pb1.pair.com header.from=sam@sambarrow.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sam@sambarrow.com; spf=permerror; 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:48929] helo=scottsdale.servershost.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3C/8F-63281-7048E774 for ; Fri, 04 Jan 2008 14:07:56 -0500 Received: from [98.172.154.66] (port=37693 helo=[10.200.100.14]) by scottsdale.servershost.net with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.68) (envelope-from ) id 1JArtQ-0003tQ-2Q; Fri, 04 Jan 2008 13:07:44 -0600 To: Stanislav Malyshev Cc: internals Mailing List In-Reply-To: <477E822E.30108@zend.com> References: <477DB7BF.10201@chiaraquartet.net> <20080104105558.GC7861@mint.phcomp.co.uk> <477E5649.2080104@chiaraquartet.net> <1199466070.15292.140.camel@sbarrow-desktop> <1199466701.15292.149.camel@sbarrow-desktop> <477E7AC3.20009@zend.com> <1199472405.15292.181.camel@sbarrow-desktop> <477E822E.30108@zend.com> Content-Type: text/plain Date: Fri, 04 Jan 2008 14:06:09 -0500 Message-ID: <1199473569.15292.195.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:59 -0800, Stanislav Malyshev wrote: > > Not necessarily, if you have a function that performs a generic > > operation on any object. As for resources you are right, it might be > > Like what? I don't know many operations that are good for any object and > only object and need special function to perform them. Actually, > excluding scenarios like serialization and RPC (which should take care > of other types too so irrelevant here) I can't think of any right now. > > ideal to have "mysql resource" rather than just "resource", but just > > having the "resource" type hint is better than having no type hint. > > No, it's not better. Having GD image instead of mysql connection is not > better than having integer in any way. It would just produce different > error message, so what? That's actually very true. > > This is one that I find very useful, much more than it may seem. I use > > scalar for any type of post/get input, printed output, or DB > > interaction, as objects/arrays/resources cannot be printed or stored in > > a database in a standardized way. > > If you need serialization/printing, you have serialize() and > __toString() with respective handlers. If you reimplementing them and > using scalar restrictions, you most probably do it wrong. Ok but if someone inputs an array in the query string i have a problem with that. And I said standardized way, ie bool true outputs as "1", float 5.20 outputs as "5.2". For objects, toString is a standardized output but serialization is not, and for arrays no standardized output exists.