Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106720 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 51929 invoked from network); 28 Aug 2019 14:25:13 -0000 Received: from unknown (HELO mail-lf1-f46.google.com) (209.85.167.46) by pb1.pair.com with SMTP; 28 Aug 2019 14:25:13 -0000 Received: by mail-lf1-f46.google.com with SMTP id v16so1891918lfg.11 for ; Wed, 28 Aug 2019 04:57:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jZOS1ZTVralfdj77tWoW3p3QyntGBGizt9yzpWoZctI=; b=Ya7dc6JwjUMe06BvqoSMP3E/7riPz0RzK6iAF7vo8wdV/lQyy5oStWELCD4Zcv3bYV r4qEAJcDHxlTb0TbNZ44dzWpllG+fNP/LMWBe/ikGk1ryXp4g1FZv0qNFsli4GoOX3P2 FOLwV1tNMB6Qv65h3kicoz3quHbH5P9Kf+EJcHVJmVWctMpSCLnAZyP9vtUTbJOjG1AF nNRLsu3y0SvsOSHiydq58FaskOJIAXt7EwuIORTowYlWZDl5KJTheyOBoXrCdsxh15Y8 FPNO/yrmqrCRvtU6e+hNvqkpb9P++jqSvd6kymXrWhPUaZp6TfZSdJMpx4TC4E8W5S6t VsFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jZOS1ZTVralfdj77tWoW3p3QyntGBGizt9yzpWoZctI=; b=fURgeZ9DxWgDc0XIaNnG8L5K6Sn/l1kAunrtqbmwNi9ATJqTaaNIElW/ITB1SChBSB RmGZV0ti0VxtOUAk+mz0+tIW2CXyKmeBdlSvZhbICRGYSgH3xJlqZ9TRkRWF51ns6ueA TIu5Hs66iU6KRzr9CA6uFImsMaa4Nlfh8dSAGorG0KFQ8+C9RmLyVtC3KQFM8cZkvqRx RT9M2TGfqn12MtkGaab8nDVGWuFmVj5N5DKw3/OaTK2hZvb3w01OnuOa6pzOkfmA0f75 5hCp2suKX+0EaL86LrNjheKloA6GOPJA4N2D+MWX3P0aol8ZPRdunlu5gcoIp2uKZ7aB 3Zvg== X-Gm-Message-State: APjAAAV0ejItHMAIwY8E1hEb8xRK+9687v5lNJVQrpSFZrzP958gLU8l 4elzIEmgN456uNlZKIYa4q1EiLXIqw0x9vH+57g= X-Google-Smtp-Source: APXvYqxwAPuerMiXNMYIW7mM7U2RQY1EgagbEBs69I4+L4Un1fjh4OkQduH6I6UaDH3qDRb6DKNvlCbaX/APukUCWhU= X-Received: by 2002:a19:cb46:: with SMTP id b67mr2471415lfg.154.1566993441242; Wed, 28 Aug 2019 04:57:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 28 Aug 2019 13:57:04 +0200 Message-ID: To: Lynn Cc: Zeev Suraski , PHP internals Content-Type: multipart/alternative; boundary="0000000000006e41c605912c1734" Subject: Re: [PHP-DEV] [RFC] Reclassifying engine warnings From: nikita.ppv@gmail.com (Nikita Popov) --0000000000006e41c605912c1734 Content-Type: text/plain; charset="UTF-8" On Wed, Aug 28, 2019 at 1:46 PM Lynn wrote: > > > > This argument makes sense for arrays and objects (and I don't promote >> undefined index/property to exceptions for that reason), but I don't think >> it holds any water for simple variables. Writing @$counts[$key]++ is a >> lazy >> way to count values and avoid ugly boilerplate for if >> (isset($counts[$key])) { $counts[$key]++; } else { $counts[$key] = 1; }. >> But @$foo++ is just a really bad way of writing either $foo++ or $foo = 1. >> Outside of variable variables, the concept of a conditionally defined >> variable just doesn't make a lot of sense. >> > > The variables are not conditionally declared on purpose, but as it's code > written 15~20 years ago, maintained, copy-pasted over and over and never > reviewed, there's a lot of issues that remain that my trigger an error > exception if this proposal is passed without migration path. > To be clear, this was in response to Zeev's particular argument, which I don't think is valid. I am aware that accesses to undefined variables are a thing in legacy code. However, I feel pretty strongly that converting any of these to deprecations is not a good idea. While there's certainly different views on this, I've seen it often enough deprecation warning are considered an even lower error level than notices (imagine my surprise when PEAR stopped working completely in PHP 8 because nobody ever saw the hundreds of suppressed deprecations). We could throw a deprecation in addition, but I think this will make the development experience really suck for anyone who is not actively working on a migration right now (imagine seeing lots of warnings/notices during development twice). I think it would be better to register an error handler that matches the cases that will throw and can then log those. I'd be happy to provide an implementation if you think this would be useful for your use-case. Also has the nice advantage that you can start using it right now and don't have to wait until you upgrade to a release that has deprecations. Nikita > > ``` > // a.php > if ($someCondition) { // comes from another file, never used, can't verify > existance > $foo = 'foo'; > } > > // b.php > $bar = 'bar'; > > // scenario1.php > include 'a.php'; // this would crash > include 'b.php'; > > echo $foo . $bar; // this would crash if the include didn't yet > > // scenario2.php > $someCondition = true; > > include 'a.php'; // this would not crash > include 'b.php'; > > echo $foo . $bar; // this would not crash > ``` > > The problem with the above legacy code, which we sadly have spread through > a spaghetti of thousands of files, is that if it starts throwing errors > with no migration path, we simply can't update without spending possibly > weeks debugging and trying to find scenarios where this might trigger. Now > I'm not sure, but if I would've used `include_once` and combine this with > function/class scopes (people loved to do that in our legacy code), all > hell breaks loose and it will be nearly impossible to find the cases. > > All I'm asking is for a clear upgrade path with deprecations so that my > code can be safely migrated over time, rather than have it crash with the > next version. Compared to easy to fix. By having it throw deprecations which we can easily log to a > specific file, we can gather and fix the cases when we have time to spend > on technical debt, and by the time the warning will turn into an error > exception, we'll have fixed probably 90%+ of the cases, making the upgrade > possible. > > Regards, > Lynn van der Berg > --0000000000006e41c605912c1734--