Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106789 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 11658 invoked from network); 29 Aug 2019 09:55:50 -0000 Received: from unknown (HELO mail.gna.ch) (62.12.172.119) by pb1.pair.com with SMTP; 29 Aug 2019 09:55:50 -0000 Received: from [10.0.1.55] (77-56-180-37.dclient.hispeed.ch [77.56.180.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id D5FF62094C; Thu, 29 Aug 2019 09:28:10 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: Date: Thu, 29 Aug 2019 09:28:10 +0200 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <59C63919-5D79-4F80-ADFB-022DFD78662A@cschneid.com> References: To: =?utf-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= X-Mailer: Apple Mail (2.3445.104.11) Subject: Re: [PHP-DEV] [RFC] Reclassifying engine warnings From: cschneid@cschneid.com (Christian Schneider) Am 29.08.2019 um 08:22 schrieb Alexandru P=C4=83tr=C4=83nescu = : > When you write code, in a "productive" way that you mention, it's = perfectly > fine if you write it for you and for now. >=20 > But most often, we write code for the future generations of developers = that > could be less skilled, for the future you that might have less = context. > Also, code will evolve in time and bugs will eventually apear. In my > opinion and maybe you can agree, some of these bugs could be avoided = if > variable definition before reading would be enforced. ... and that's why Zeev suggests a strict mode for people who want it = that way. Side-note: Which brings us back to the discussion about the downsides of = language modes but as similar topics keep on popping up (although by the = same people) you are slowly convincing me that going down that road is = the best compromise. > For most of the developers and businesses using PHP, that is a trade = they > want to enforce but can't or does not know how to do it. That "most developers" is highly subjective depending on who you ask. And yes, you can easily turn undefined variables into exceptions right = now (even globally), just use set_error_handler(function($errno, $errstr) { if (preg_match('/^Undefined variable/', $errstr)) throw new Exception($errstr); return false; }, E_NOTICE); > I am for a default with more things enforced and maybe only allowed = them > based on declares, not the other way around. Breaking code first and making migration harder instead of offering a = clean migration path where developers opt-in to a new mode. - Chris