Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77127 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82324 invoked from network); 10 Sep 2014 02:01:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Sep 2014 02:01:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=pencap@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pencap@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.173 as permitted sender) X-PHP-List-Original-Sender: pencap@gmail.com X-Host-Fingerprint: 209.85.223.173 mail-ie0-f173.google.com Received: from [209.85.223.173] ([209.85.223.173:34683] helo=mail-ie0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/D8-08634-C01BF045 for ; Tue, 09 Sep 2014 22:01:49 -0400 Received: by mail-ie0-f173.google.com with SMTP id x19so2658017ier.4 for ; Tue, 09 Sep 2014 19:01:45 -0700 (PDT) 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; bh=BIJRP18jkdOLrDdXWSuEY86/RyqIThKio/Fhi8uJk74=; b=l/7TT/IsSaT2zPYrNtnxlwYbfaSko3CwIItAyvUZDgfIDKRH29cd+G6e464RduN/+k 6uWHe2ppa6Bh70qFTpYbgv0j+FGjuxlZorIACcX+Pv7XVem2gv1ZRFA+km1zUQJmcwAU MCjCmuaLQ3wjLbffSGIT4oehQvlTIt5LDvKfk4fmQFCth7yEclFXmT3m9SDL+kTg+QV7 9Y2eBmwoT5tTNb3uZDyL4CLHJ7XnUd3ScxJdWM09Byom173x8PDZc6SC0kx/29qITH4S jTi3OauWNsJZeWOMxYFjWyQJqvi+XhZqRXJ+n4R6pG3c3tyMCdIPssECjUirnabMXQ3G wqBQ== MIME-Version: 1.0 X-Received: by 10.50.82.98 with SMTP id h2mr36288972igy.26.1410314505058; Tue, 09 Sep 2014 19:01:45 -0700 (PDT) Received: by 10.50.85.230 with HTTP; Tue, 9 Sep 2014 19:01:45 -0700 (PDT) In-Reply-To: <540F8DAA.5090202@sugarcrm.com> References: <004d01cfcc63$e7e3ac40$b7ab04c0$@tutteli.ch> <3DB7DEC9-2F99-4DDB-95A9-70455E4BABCB@ajf.me> <540F8DAA.5090202@sugarcrm.com> Date: Tue, 9 Sep 2014 21:01:45 -0500 Message-ID: To: Stas Malyshev Cc: Andrea Faulds , Robert Stoll , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0111b2c61881390502ac6ffa Subject: Re: [PHP-DEV] make casts more strict in PHP 7 From: pencap@gmail.com (Mike Willbanks) --089e0111b2c61881390502ac6ffa Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > Hi! > > > No, no it would not. PHP=E2=80=99s explicit casts cannot fail, and ther= e is > > absolutely no good reason to change this. If people want strict > > casting, we can add new functions or operators for that specifically. > > But to break explicit casts and make them sometimes fail would cause > > innumerable bugs and backwards-compatibility ideas. > > I agree. If the developer explicitly states they want conversion, it > should be conversion. For implicit casts, some tightening may be ok, but > for explicit ones I think it would bring much more headaches than it's > worth. > Precisely, it would cause a vast amount of headaches for many projects. Think of user input where you are expecting an integer and it must be a positive integer (which would ultimately be a string); it is much faster to do a quick check such as: $foo =3D (int) $_GET['foo']; if ($foo > 0) { .... } I'd personally not have to wrap more items around it due to a notice or warning. --089e0111b2c61881390502ac6ffa--