Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81407 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 245 invoked from network); 30 Jan 2015 09:14:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jan 2015 09:14:35 -0000 Authentication-Results: pb1.pair.com header.from=ml@anderiasch.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ml@anderiasch.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain anderiasch.de designates 81.169.138.148 as permitted sender) X-PHP-List-Original-Sender: ml@anderiasch.de X-Host-Fingerprint: 81.169.138.148 ares.art-core.org Received: from [81.169.138.148] ([81.169.138.148:44307] helo=ares.art-core.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/A0-31101-67B4BC45 for ; Fri, 30 Jan 2015 04:14:31 -0500 Received: from parabellum.local (p5093a1a9.dip0.t-ipconnect.de [80.147.161.169]) by ares.art-core.org (mail.art-core.org) with ESMTPSA id AD7ED2EE008; Fri, 30 Jan 2015 10:14:26 +0100 (CET) Message-ID: <54CB4B70.6060900@anderiasch.de> Date: Fri, 30 Jan 2015 10:14:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Thunderbird/36.0a2 MIME-Version: 1.0 To: Yasuo Ohgaki , =?UTF-8?Q?C=c3=a9sar_Rodas?= CC: "internals@lists.php.net" References: <54CB13A4.9060900@rodas.me> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Is it a good idea to have a "strict" mode? From: ml@anderiasch.de (Florian Anderiasch) On 01/30/2015 06:36 AM, Yasuo Ohgaki wrote: > Hi Cesar, > > On Fri, Jan 30, 2015 at 2:16 PM, César Rodas wrote: > >> I'm wondering if it would be a good idea to have a `strict` mode in PHP. >> Many language have them and it is a good idea. >> >> I think it should be a bit different in PHP, it should encourage the >> following things: >> >> - Avoid deprecated things, it should throw an exception. >> - Avoid explicit conversions of undefined constants to strings. >> - Anything else that could make run-time slower *or* bad practice. >> >> ```php >> "use strict"; >> >> var_dump(FOOBAR); // should throw an exception, undefined constant. >> ``` >> > > We have error_reporting INI for this purpose. > Users may be strict or lazy for errors by the INI setting. > I don't think it's a good idea to have a strict mode at all. I'd prefer any language to be strict and unambiguous enough from the start. Adding strict mode after the fact is just a band aid. PHP's error reporting level isn't that bad, but if you're ignoring legacy code there's hardly a reason not to develop to the strictest standard possible. ~Florian