Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37022 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45479 invoked from network); 15 Apr 2008 11:28:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Apr 2008 11:28:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=arvids.godjuks@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=arvids.godjuks@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 66.249.92.169 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: arvids.godjuks@gmail.com X-Host-Fingerprint: 66.249.92.169 ug-out-1314.google.com Received: from [66.249.92.169] ([66.249.92.169:7764] helo=ug-out-1314.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 47/43-26778-D5194084 for ; Tue, 15 Apr 2008 07:28:30 -0400 Received: by ug-out-1314.google.com with SMTP id u40so668586ugc.29 for ; Tue, 15 Apr 2008 04:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=M9RsHvjQLbFXXyeNaI2B4rXc1oD1o/M2ZaENzxETnV0=; b=k7emMYlzwuQy6/PEmdslCTvS6nnmrmzCi5UIHcXWxlHuNgLAEXjMrQfHkZT5LsiU8zNjlS1KhZ2QHBMZFc/dTRFk8MyQ7dCuUGs/pvI/uiV7AiFTLbENT3IxrmkcaXTbfzcS8xfManG6HaQlsLhzu5L8ewKqBtPfVJulHdMWzpM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=INiVJVsafLhaflNW/LbZ2TlbdDg59O1eBlQ/LTE3SsVeh7Zn1fdA54W8b1EXmodzM00Zly5XhECTEOR6q2G66GbhXzahHWyg3ZRRCtYYaAv6xnM4H8I/Y8gPe5EFmL3bcHq41tyiXUdU0QwDG8lgTXFf47hFPee9guZt1MJxr8Y= Received: by 10.67.89.17 with SMTP id r17mr5318034ugl.4.1208258905896; Tue, 15 Apr 2008 04:28:25 -0700 (PDT) Received: by 10.66.219.9 with HTTP; Tue, 15 Apr 2008 04:28:25 -0700 (PDT) Message-ID: <9b3df6a50804150428qa27d31m20240b6f0ebaeb13@mail.gmail.com> Date: Tue, 15 Apr 2008 14:28:25 +0300 To: "Christian Schneider" Cc: "Lukas Kahwe Smith" , "Chris Stockton" , "PHP Developers Mailing List" In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_23435_26359946.1208258905888" References: <1207539695.5736.42.camel@pena> <37C655F0-D212-420C-9320-7953A69C5EDB@pooteeweet.org> <48036A0C.7070203@cschneid.com> <7356DD7D-2501-49CB-9428-758DCF674691@cschneid.com> <6A76B92D-3901-4A4E-975F-C7C0F36FD1D9@pooteeweet.org> <1208235938.8817.14.camel@sams-room> <9b3df6a50804150127h49548d34g72d2f0b5d7f6e884@mail.gmail.com> Subject: Re: [PHP-DEV] Return type hints From: arvids.godjuks@gmail.com ("Arvids Godjuks") ------=_Part_23435_26359946.1208258905888 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Christian Schneider We have 2 possibilities. * Throw an error * Make type conversion What to select is PHP developers team prerogative. About example - that's MySQL who is very tollerant, other databases may not threat well things like passing an ID to numeric field as string. That's bad style to me. If you have a numeric filed - pass numeric values. If you have character field - please pass strings. That's more like coding style and isn't related to this disscussion. And if you have a type-hinted language, then your ID will be integer anyway or your programm will segfault if you try to assing a string to int type variable. We are not talking about MySQL's capability to convert types itself and type hinting isn't related only to databases - i just took first example I could think of. About conversions - see how PHP converts types - that's written in the manual echo (int)42; -> 42 echo (int)"42foo"; -> 42 echo (int)"foo"; -> 0 echo (int)"foo42"; -> 0 At least on bad ID's like "foo" or "foo42" you will have 0 and usualy there are no ids with value 0 in databases, so you will get "No data avaliable" - that's my approach witch proved to be good one over the years. ------=_Part_23435_26359946.1208258905888--