Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82936 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61857 invoked from network); 17 Feb 2015 09:27:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2015 09:27:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain lerdorf.com designates 209.85.192.178 as permitted sender) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.192.178 mail-pd0-f178.google.com Received: from [209.85.192.178] ([209.85.192.178:39749] helo=mail-pd0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/C1-46567-69903E45 for ; Tue, 17 Feb 2015 04:27:52 -0500 Received: by pdjy10 with SMTP id y10so42516593pdj.6 for ; Tue, 17 Feb 2015 01:27:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=IwTJDndqQQDkZbNG9PoK69W38eN9fPjlPiUrozVOtqk=; b=BC96GVZJ65ENVs28V9m8QB8ScbR0tGfdU0omO6E9rvmo9DMrBVaeQ2oFVpxa67G8IZ UGxridsF6GV/u5p9ywuTRMkUgkxxJy9IzV9NFDPfG+cGhnfqYrgFbYzxlNpV52aVgvtF 79HSKED4AMsFgMx3Ym94chLNC9WxlmXqzyxNCr+gKh6NDrDQumF6XeXg2MMY6hxNfPlr wgT2rIAWpY9fQsqEvqLdBui6G/VSrEXDXICyLctIHl0dkACZU7Hj7IfFWKwkyaG5JbuC pQ62DMJc3aVOrOL4po0bxQJ/+7JVZUFZnHLzDRW6A3n6ioLQ66xq75ScxjYB0CiCnUbk i8QA== X-Gm-Message-State: ALoCoQn7eHYvIQoWXmjNqOAWfiIS+i8YBxe/rQpeaKWPkX3xy8KlrJyfDVjzrouEfOFZ7fsuTtHt X-Received: by 10.66.148.196 with SMTP id tu4mr46582973pab.125.1424165267687; Tue, 17 Feb 2015 01:27:47 -0800 (PST) Received: from [192.168.200.14] (c-50-131-44-225.hsd1.ca.comcast.net. [50.131.44.225]) by mx.google.com with ESMTPSA id nw2sm17090055pdb.43.2015.02.17.01.27.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Feb 2015 01:27:46 -0800 (PST) Message-ID: <54E30991.80108@lerdorf.com> Date: Tue, 17 Feb 2015 01:27:45 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Benjamin Eberlei CC: PHP internals References: <011801d04a07$83ab1c00$8b015400$@php.net> <016f01d04a3a$e9183220$bb489660$@php.net> <54E290E5.3020508@lerdorf.com> <54E2AD88.6040206@lerdorf.com> <54E2FA57.6050009@lerdorf.com> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="anPLOqkqBORkVh3AlTqC7HInQSCuVkI4J" Subject: Re: [PHP-DEV] Reviving scalar type hints From: rasmus@lerdorf.com (Rasmus Lerdorf) --anPLOqkqBORkVh3AlTqC7HInQSCuVkI4J Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/17/2015 01:11 AM, Benjamin Eberlei wrote: > I think curl_setopt is a misleading example in the typehinting > discussion, because > this kind of API does not benefit from it. The third argument depends > on the second argument and requires a "generic" type in code: >=20 > curl_setopt(resource $ch, int $option, mixed $data); >=20 > It won't be possible to change this (or any similar API) with strict > type hints.=20 >=20 > The code to convert a boolean $data to integer in the VERIFYPEER case i= s > manually > implemented and therefore subject to the implementors design decisions.= Sure, I realize this, but it is the bool->int coercion example that is always brought up. A static analysis type checker would have trouble catching this, but both PHP and Hack apply that coercion at runtime: case CURLOPT_SSL_VERIFYHOST: if(Z_BVAL_PP(zvalue) =3D=3D 1) { The runtime could say, hey, I am in strict mode here and you are passing me an array of strings which I am coercing to a boolean. Not cool. -Rasmus --anPLOqkqBORkVh3AlTqC7HInQSCuVkI4J Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlTjCZEACgkQlxayKTuqOuAWfwCfYFair7VGiwV9aYCWrak+4rwv cW4An0zCnFb3dpaKZ+tRAwQFBcfKcCWs =uaiv -----END PGP SIGNATURE----- --anPLOqkqBORkVh3AlTqC7HInQSCuVkI4J--