Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83923 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75398 invoked from network); 26 Feb 2015 20:18:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2015 20:18:20 -0000 Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.223.181 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.223.181 mail-ie0-f181.google.com Received: from [209.85.223.181] ([209.85.223.181:42873] helo=mail-ie0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/5E-32582-68F7FE45 for ; Thu, 26 Feb 2015 15:18:19 -0500 Received: by iecrp18 with SMTP id rp18so20510471iec.9 for ; Thu, 26 Feb 2015 12:18:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc:content-type; bh=9/nEF5gvcixwohy3iMQOcPM3yJkkSHXjFVlOIXDuPUY=; b=hFB2PO8DC2wrTIRPXIvCR/WBNUfzsiZA7/Bf6uwpicEnBs5FsQvLxZgZZtL56yxnWk U7U7YX3cm+r2ILMXvjlU/eN42E0k0YzBIvaszricjzspUKrgylLTdTOtkQPFf8hgEpxk 0O3Xs9f09aAUS7VwN9+o9zVbQFwjt1/3EJ94LBefHmmZJKu9ecB9FHGxFe0VbL1HekGP ixnPeGowtKyEjdsQFwJ0u6WjAK0RQDyaIcLpsruT6gM0ySrECy2aGhdl0CbfmpzI8UB9 Nomxaw3HZesHKY2jFNNI5TF25u/zREfG39ODkjnGvR8ZjXf7EuXxuDTBOeTla4zAauzj s2qQ== X-Gm-Message-State: ALoCoQnQ7cYCZk97uRp1jHtgGpNOe09YUXXn0hUZT+icMANJVirodmIE95DnszNvgy6EEZyUjEKzV4MPonJsOd3Bs9hdwm6Uj3Aq5C02EojDkCiSqNlo9ibUO0PTttYdYf5jh4sqP5uGh0RxO1bYbuMotK1V4BXNiw== X-Received: by 10.43.103.8 with SMTP id dg8mr11722278icc.18.1424981891860; Thu, 26 Feb 2015 12:18:11 -0800 (PST) References: <3d639901ae85227b219e7ee59b3140fe@mail.gmail.com> In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQGwbbdURx2shUG2o7Zj2Ywptu8MnAHNhHseASj3TG8CBU/YnAHY8IsNAja8iU2c+saa4A== Date: Thu, 26 Feb 2015 22:18:11 +0200 Message-ID: <2a8b6b586398939a6cc6e5ad0ed67924@mail.gmail.com> To: Mike Willbanks Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: RE: [PHP-DEV] A different user perspective on scalar type declarations From: zeev@zend.com (Zeev Suraski) > -----Original Message----- > From: Mike Willbanks [mailto:pencap@gmail.com] > Sent: Thursday, February 26, 2015 9:46 PM > To: Anthony Ferrara > Cc: Dan Ackroyd; Zeev Suraski; Theodore Brown; internals@lists.php.net > Subject: Re: [PHP-DEV] A different user perspective on scalar type > declarations > > 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/a4e23a10d4ee > ea5fd9fe8916859a07430b94cf42/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. Can you explain that in a bit more detail? What's the data flow exactly, in both directions? Thanks! Zeev