Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81636 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20756 invoked from network); 2 Feb 2015 19:24:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2015 19:24:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=ua.san.alex@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ua.san.alex@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.180 as permitted sender) X-PHP-List-Original-Sender: ua.san.alex@gmail.com X-Host-Fingerprint: 209.85.223.180 mail-ie0-f180.google.com Received: from [209.85.223.180] ([209.85.223.180:35071] helo=mail-ie0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 98/12-34915-1DECFC45 for ; Mon, 02 Feb 2015 14:24:02 -0500 Received: by mail-ie0-f180.google.com with SMTP id rl12so19842045iec.11 for ; Mon, 02 Feb 2015 11:23:59 -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:content-transfer-encoding; bh=7FlW6wmW8TMbDhvvhqU0oG1C68RWSyVreWwHI7/+rv4=; b=BrJ0/1u5gjUPBQxRwx6Ukv75hUtIz3oWOE9oVwMW7aY/k9a4/JhACD+m+cIHmLsaij mIJ8v6d5Ig7anf4qTMcxRhbHNlnDC7AfZ9lOfTfXF3Ayzntemr7vougrz3DTpckwt8Q2 vf7hvCGxgdXf//UZ8RTscF/4QBhlsPTbU0wTKLt9PN2YsnqL79KkoibgVcyCmRAiPYUz GuM9JXUT/0mCC3n6pqTKgP5XoZNxoOK20bW+P0l2L/JSQGv67kan005NlbkYL2LgSEN6 K9QUmcvvIAZXDabE5rItDm9b7wn1eYK9CShJarJPCLXbW0pAwxDAWYuZ5kHB6Gr5LFOL nTPg== MIME-Version: 1.0 X-Received: by 10.50.32.71 with SMTP id g7mr13776329igi.4.1422905039207; Mon, 02 Feb 2015 11:23:59 -0800 (PST) Received: by 10.50.93.3 with HTTP; Mon, 2 Feb 2015 11:23:59 -0800 (PST) In-Reply-To: <2AABD912-C2A3-4877-8B40-8E391B2BE45F@ajf.me> References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <1E54E93F-8CE1-469F-BE1F-DD2F1DF76E39@ajf.me> <5175DE01-ADC9-4A0B-8343-820C53B30054@ajf.me> <2AABD912-C2A3-4877-8B40-8E391B2BE45F@ajf.me> Date: Mon, 2 Feb 2015 21:23:59 +0200 Message-ID: To: Andrea Faulds Cc: Dmitry Stogov , PHP Internals List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: ua.san.alex@gmail.com ("S.A.N") 2015-02-02 21:12 GMT+02:00 Andrea Faulds : > Hi Dmitry, > >> On 2 Feb 2015, at 18:22, Dmitry Stogov wrote: >> >> So, one of the advantages of strict type hinting is the ability to catch= potential errors. >> For example when we pass 67 to setBody(string $message). > > Yes, that sort of thing is easily caught by strict type checks. They=E2= =80=99re also able to catch things that are sometimes okay for weak hints, = sometimes not. For example, some *but not all* strings are accepted for int= eger and float parameters, and some *but not all* floats are accepted for i= nteger parameters. Strict checks make this much simpler and not dependant o= n the value: either some type is accepted, or it isn=E2=80=99t. > > Because of that, strict types can actually be effectively analysed ahead-= of-time by static analysers, IDEs and so on, and so you can catch some type= s of errors while editing your code, without even needing to run it. This i= s quite a powerful feature. Nikita might have more to say on that. > > Thanks. > -- > Andrea Faulds > http://ajf.me/ > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > Strict type checking, has its advantages. We all external data convert to native PHP types. The database we use option MYSQLI_OPT_INT_AND_FLOAT_NATIVE. Inputs are validated and converted to native PHP types. In Redis data are stored as serialize string. In our API we may require strict adherence to type because the integer as strings $id =3D "123" to impossible, i need catch these as logical error. But I also fully endorse, cast without loss of accuracy, because it gives you more options and less of a problem for those who do not have the conversion of external data. Not to discuss endlessly two options, it is reasonable send to voting the Strict type checking, voting will be fail :), then will be easier to discuss technical issues as do korektno cast without losing data, good luck!