Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83919 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68134 invoked from network); 26 Feb 2015 19:45:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2015 19:45:42 -0000 Authentication-Results: pb1.pair.com header.from=pencap@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pencap@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.181 as permitted sender) X-PHP-List-Original-Sender: pencap@gmail.com X-Host-Fingerprint: 209.85.223.181 mail-ie0-f181.google.com Received: from [209.85.223.181] ([209.85.223.181:41074] helo=mail-ie0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/FC-32582-5E77FE45 for ; Thu, 26 Feb 2015 14:45:41 -0500 Received: by iecrd18 with SMTP id rd18so20047315iec.8 for ; Thu, 26 Feb 2015 11:45:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=xw7j63H+9zVxCcHi7sskoJWWeGhvAJCRyoN5E7csaxs=; b=sBwvoVOln1ZOnvLhKr+Nqoxt/Io+7VeSFWEanXki1+rdkFGRiQovYZFznqOWYBRvNF knOGEaEH8smuuN0up7ZH2DjiDInO7bP2addeeOKDIGcGO5Av3F9sLUB0peaFEdHkw06J vKXmzpGenUeO+z/RD0XZ2aPCn34SJctMKr5vn+RgMZji8LA4OV6XkRgyi79r8L/2TOho kuVkWz9aXxqrvZm8paQgv/ePcm1uPoHCw2eApyYg9sqRNPwNutyieAM8q4ZLbUnxxNzJ 1/dei5sajG0HIY6j+0IJAflNLEHBY2FtvzjP3BmQgyYkNcj3hkEQ8lXHjTtRCkn1GxKd STnQ== MIME-Version: 1.0 X-Received: by 10.50.36.104 with SMTP id p8mr14039522igj.16.1424979938731; Thu, 26 Feb 2015 11:45:38 -0800 (PST) Received: by 10.64.125.33 with HTTP; Thu, 26 Feb 2015 11:45:38 -0800 (PST) In-Reply-To: References: <3d639901ae85227b219e7ee59b3140fe@mail.gmail.com> Date: Thu, 26 Feb 2015 13:45:38 -0600 Message-ID: To: Anthony Ferrara Cc: Dan Ackroyd , Zeev Suraski , Theodore Brown , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e01182faa0f6cc4051002ffa3 Subject: Re: [PHP-DEV] A different user perspective on scalar type declarations From: pencap@gmail.com (Mike Willbanks) --089e01182faa0f6cc4051002ffa3 Content-Type: text/plain; charset=UTF-8 Anthony, On Thu, Feb 26, 2015 at 1:29 PM, Anthony Ferrara wrote: > Mike, > > One point of clarification: > > > This is true, however, the types that you are receiving back form a > > multitude of data sources might be in a mixed format (databases for > example > > often provide representation back as a string, non-json based web > services > > provide mainly as a string, etc). While I know what my data looks like > > and I know I am always going to get a "string" integer back I do not want > > to have to type cast this each and every time. Or that I have a boolean > > integer representation that is in a string... You get the point. Sure, > I > > could certainly go in and take 5 minutes and cast each one but I'm not > > certain why the purpose is there... It specifically changes the > > determination that PHP is a weakly typed language and all of a sudden I > now > > need to care that my string integer boolean is not actually a boolean. > > It's funny that you bring up boolean... > > With the current coercive proposal, you will still need to worry about > the types: https://wiki.php.net/rfc/coercive_sth#coercion_rules For some unbeknown reason I was inside of my head going ok, i have a string integer so that would make an integer and then it would make a boolean. Thank you for pointing out my obvious miss there :) > > > Passing boolean(false) where an integer is expected will generate an > error. This is a common practice, specifically around internal > functions. Example: > > https://github.com/sebastianbergmann/phpunit/blob/a4e23a10d4eeea5fd9fe8916859a07430b94cf42/src/Util/ErrorHandler.php#L58 > > So yes, you'll still need to go in and cast each one **in both RFCs** > (or handle the errors properly). > This is certainly a common case, actually quite often for database purposes do we need to handle booleans to integer conversions which my integer comes back as a string (depending on which extension of course) and which type field it is. > > The difference is with the dual-mode RFC you can choose not to have to > cast and keep everything as-is today (or more specifically, you need > to explicitly choose strict mode). And you can have user-land behave > identically to internals **in both cases**. > > Anthony > Mike --089e01182faa0f6cc4051002ffa3--