Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83915 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58961 invoked from network); 26 Feb 2015 19:14:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2015 19:14:18 -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.220.48 as permitted sender) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.220.48 mail-pa0-f48.google.com Received: from [209.85.220.48] ([209.85.220.48:43828] helo=mail-pa0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 48/1B-32582-8807FE45 for ; Thu, 26 Feb 2015 14:14:18 -0500 Received: by paceu11 with SMTP id eu11so16125480pac.10 for ; Thu, 26 Feb 2015 11:14:13 -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=dbazK4pO5hSLoPn23h2TUcgiQqSQd6b2lRsnmiYo+tI=; b=lHo0mFWJBoKeI7JWiCrPzROIF/EMB6Yux+hBu9vBlLzgzFpEluatycDTzoGf9XlPhu 5ogy/cM3lct0L94//+CSJYHftGDFsw6mejHW0G9lYQlgHwFgiemlcBg0RsfUgrejApvQ m6LfNIxb3CZHjJTYAw0jiM1rnsQHLhBwn537/fCup0gK5r9Iklp9pzU6h7gDWSFZY2Pb IgwI8TK9pyT5+rv4MaLM5Kvz31yJTFB+v55yQZPN7E7/9fZWobZ7pKjyJshYVU3LxMo9 02VeSIo/l3fJpYa+5zT/56VMxRzg2m5TjZI8SwYWBrWhWrIdHfNQrbNlnY+xmhCzko44 pvzw== X-Gm-Message-State: ALoCoQlIoRldCdF8SKb1Th+Avfk16Nu1Xr1R6U033c+D8CnjJ4h8ZJtrUSFeQ8R/8LyFc13VGdnO X-Received: by 10.70.129.135 with SMTP id nw7mr17143850pdb.165.1424978053761; Thu, 26 Feb 2015 11:14:13 -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 y12sm1740719pdk.46.2015.02.26.11.14.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Feb 2015 11:14:12 -0800 (PST) Message-ID: <54EF7082.1030707@lerdorf.com> Date: Thu, 26 Feb 2015 11:14:10 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Dan Ackroyd , Zeev Suraski CC: Theodore Brown , "internals@lists.php.net" References: <3d639901ae85227b219e7ee59b3140fe@mail.gmail.com> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8CSieLVNm3q7jjix5nD5kwcDFNxFwaHOg" Subject: Re: [PHP-DEV] A different user perspective on scalar type declarations From: rasmus@lerdorf.com (Rasmus Lerdorf) --8CSieLVNm3q7jjix5nD5kwcDFNxFwaHOg Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/26/2015 10:49 AM, Dan Ackroyd wrote: > In most applications, the part of the code that is exposed to the > outside world and has to convert strings or unknown types into known > types is a very small layer at the outside edge of the application. >=20 > The vast majority of code written for non-trivial applications has no > contact with the outside world. Instead it only communicates to other > layers inside the application where the types required are fully > known, and so the parameters passed should already be in the correct > type. And so type coercion is at best unneeded, and usually not > wanted. Looking through some very large code bases I am involved with this argument falls down on two main points: 1. There is a lot of data coming from memcache/mysql/pgsql as strings that is not typed. 2. There are quite a few objects being shuffled around interchangeably with strings and making use __toString magic. Type coercion is needed in both cases here. This is in the backend code far for user input. It would take a whole lot of refactoring to be able to turn on strict for this code. Especially getting rid of all use of __toString objects. It would require force-casts to make this backend code work in strict mode and then we are back to square one. -Rasmus --8CSieLVNm3q7jjix5nD5kwcDFNxFwaHOg 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 iEYEARECAAYFAlTvcIMACgkQlxayKTuqOuAGlgCcD+hCnxj/C2Xs52KFL05Fs/Fo wnEAoImFfmiPWQoIPhDnHmbSLtPJTgvs =Z0Lt -----END PGP SIGNATURE----- --8CSieLVNm3q7jjix5nD5kwcDFNxFwaHOg--