Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58299 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95436 invoked from network); 28 Feb 2012 22:56:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Feb 2012 22:56:43 -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 Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: arvids.godjuks@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:49103] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F7/AC-36673-AAB5D4F4 for ; Tue, 28 Feb 2012 17:56:43 -0500 Received: by wibhj13 with SMTP id hj13so265842wib.29 for ; Tue, 28 Feb 2012 14:56:40 -0800 (PST) Received-SPF: pass (google.com: domain of arvids.godjuks@gmail.com designates 10.180.95.1 as permitted sender) client-ip=10.180.95.1; Authentication-Results: mr.google.com; spf=pass (google.com: domain of arvids.godjuks@gmail.com designates 10.180.95.1 as permitted sender) smtp.mail=arvids.godjuks@gmail.com; dkim=pass header.i=arvids.godjuks@gmail.com Received: from mr.google.com ([10.180.95.1]) by 10.180.95.1 with SMTP id dg1mr42966666wib.21.1330469800353 (num_hops = 1); Tue, 28 Feb 2012 14:56:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=oXqlXOOHq0LhaUtLGKbg7+9Igj5cVHS5egMy6iin1nY=; b=Z3jUfFYw6uj08p8TqF3Yi/IxlMttI2a2pil3i0H3UXFamqSh/LhhxwNX8SS+l3Qzp8 h9eJUguzf79IfhxM4XrOWQGmtVR16IdtATv/BdN902d3KlSnBDz3/EyVWDvHFw3FjWim PsDl4YKwoaLjIRPxRgOjucMnSBzNvrsmoyrx4= Received: by 10.180.95.1 with SMTP id dg1mr34139997wib.21.1330469800229; Tue, 28 Feb 2012 14:56:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.117.1 with HTTP; Tue, 28 Feb 2012 14:56:20 -0800 (PST) In-Reply-To: References: <1330357150.2159.30.camel@guybrush> <4F4C1324.2040905@gmail.com> Date: Wed, 29 Feb 2012 00:56:20 +0200 Message-ID: To: Simon Schick Cc: Michael Morris , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Scalar type hinting From: arvids.godjuks@gmail.com (Arvids Godjuks) Hi, Simon. Actually I also advocated for notices/warnings on conversion with data loss= . What just has to be done - the rule table when notices/warnings are thrown. What I have in mind is no variable type hinting at all. What I want to see is function/method type hinting. And, because the zval actually has type in it, you actually already weakly type hint the variable anyway: $a =3D 1; echo gettype($a); // integer $a =3D (int)"1"; echo gettype($a); // integer $a =3D (string)1; echo gettype($a); // string And so on. This part is in the language, just has different syntax. So no-no-no from me on this: int $a =3D 1; int $a =3D "1"; It just duplicates the functionality. And I don't like the strict int $a =3D 1; I have already explained why it's not a good idea from the technical standpoint. So what I want is this: function int test(int $a, int $b) { return $a * $b; } test(1, 2); // 2; test("1", 2); // 2 test("1aaa", 2); // E_NOTICE or E_TYPE and result 2 test(array(2), 2); // E_RECOVERABLE_ERROR - just like with array type hint = now. It's really what the most people want. Simple, easy to pick up (object and array already have this) and is just optional. I purpose to deal with this and when it works and is released to the wild then see if more strictness even is needed. I think this simple weak type hinted functionality will suffice. ---------- Forwarded message ---------- From: Simon Schick Date: 2012/2/28 Subject: Re: [PHP-DEV] Scalar type hinting To: Arvids Godjuks =D0=9A=D0=BE=D0=BF=D0=B8=D1=8F: Michael Morris , in= ternals@lists.php.net Hi, Arvids I do understand your arguments ... For me personally it's mostly to separate between string and numbers. A string to number transformation is most-likely not without loosing something ... This is most likely the reason why I want to have a E_STRICT or E_NOTICE if something like that happens. Same appears to a transformation of a number to Boolean. I don't really care how variables are handled in the very inner part of the php-core as long as it's effective ;) As you're talking about serialization ... that's right ... If you're serializing an array containing strict variables would require a change. Here you'll have a big downwards-compatibility-break ... We can do this discussion endless ... but I think you got the point why I want something like this. Until now I trusted my IDE (PhpStorm) that's reading the PhpDoc of a function and marking it as warning if I try to put in an integer whereas the documentation says that this function expects a string (or an error if it should be an object or array). Bye Simon