Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106994 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9048 invoked from network); 12 Sep 2019 20:23:07 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 12 Sep 2019 20:23:07 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 2E6122D1FE0 for ; Thu, 12 Sep 2019 10:59:04 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Thu, 12 Sep 2019 10:59:03 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id b13so16449650pfo.8 for ; Thu, 12 Sep 2019 10:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=tf2Z6Db7CWhVsq3R3FDwT0z8hNY31ZwxIh0gDH4dmR4=; b=lL1oi80fvNEHkl/bIu1ZCFsyYnMm3dXyhcOTx5pMl7bJ9lCrnt5iJVgrV+dGh+T3Zc 8JF+Yk5nPB95GafnefZy1V47GlE+pkXAfafu4LLaB0fvK7Pxegp5lNqRDDdDJSLda3s5 5m1PIzzTPtk2G38yD3LUU8cVCVvCiTpDiTykJtOu3y2/w8QbXG/AI9eQqvHWsYSbqMUl DK4iLf7/WxgEXxtOOYwTEFJaHDbbmK3TKPXp7UN2+3soy/30yUnMbC4XfFcJnWwp9oq2 nbyCCyzPPfOGxKroQna+TozeO/WjQz3x/KCp3SRMw5d0Aa6OksuEDkjSEWehsKrTsQLm F2cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=tf2Z6Db7CWhVsq3R3FDwT0z8hNY31ZwxIh0gDH4dmR4=; b=kPkXezhsVG9vi7ATig8cMCaXIMU6EGsh4zPTHkKnJVN9BZ0MmzSm86tkaU4zBv6x/W SjJAxKSa5+qZoQb4Ep6fAQlOLrFvjC89S5abgLvzfV/0mOuRs894Y3Uko+sGSgdeAWIv ZUFWDGzGTwaFjjrr7TfhbFF6IH8TzidUhlC3khwovl74u6I0951/zYlUMrtV+qGJDCdr YqKPcH/8br5YBcnPdr6UgcswUROK7DlXZMc/A8tZbZ75MaFoUEwIPRXtKX51E6VAT6C4 RoQG4w31CLQx8hIU5RL2A79hT/uSdbbEw17EbsU/GHo05QB8irnLRZg+Jqs11O37tyql Or3g== X-Gm-Message-State: APjAAAUQVF3Pw1KXfva1GYsZZxXJfoKDV8d9eXBEia45A7qvEzgiudEs 3wB+pPyIzwqMNvO0prCc1g4PBw== X-Google-Smtp-Source: APXvYqw2cDA4xVZv+5FIFDzgE+acl/Si+NXr8HVGSgGhZdIl1D/jyrke06wncYbJmsOsplC6istcyA== X-Received: by 2002:a63:bf01:: with SMTP id v1mr38445316pgf.278.1568311142530; Thu, 12 Sep 2019 10:59:02 -0700 (PDT) Received: from [192.168.101.137] (50-252-183-45-static.hfc.comcastbusiness.net. [50.252.183.45]) by smtp.gmail.com with ESMTPSA id x8sm7658096pgr.30.2019.09.12.10.58.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Sep 2019 10:59:00 -0700 (PDT) Message-ID: <31BD63BC-ACE0-4478-B241-E698D2D6F59C@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_35C53316-8856-4356-90E8-084A08D5A90F" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Date: Thu, 12 Sep 2019 10:58:58 -0700 In-Reply-To: Cc: PHP Internals List To: Lynn References: <076701d56978$86020910$92061b30$@php.net> <078e01d5697c$5512bc10$ff383430$@php.net> X-Mailer: Apple Mail (2.3445.104.11) X-Envelope-From: Subject: Re: [PHP-DEV] Changing fundamental language behaviors From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_35C53316-8856-4356-90E8-084A08D5A90F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 12, 2019, at 10:37 AM, Lynn wrote: >=20 > On Thu, Sep 12, 2019 at 7:22 PM Chase Peeler = wrote: >=20 >> There are valid reasons for not always initializing variables or = array >> keys. It might be a bad >> reason in your opinion, but others view it as perfectly acceptable. >>=20 >=20 > I recently had to fix a bug where a variable was renamed, caused a = merge > conflict and resulted in months long of changing a business process = with a > subtle bug, as null was not the intended initialized value. Whether or = not > people should initialize variables is debatable from a programming > perspective. =46rom a reader's perspective it's really important to = have > variables initialized with a default value, even if it's just null, to > prevent missing certain assignment branches and avoid bugs. =46rom my > perspective, this should've thrown an error, so we would've fixed it = the > same day. Now PHP simply broke our business process for months. >=20 > Yes, we hide notices, even in production as our logging server would = die > within a minute if we'd turn it on. Yes, this is a massive legacy code = base > where lots of tests are lacking. Can we change this? Sure, will take = years > though. Would we have benefited from PHP throwing an error in this = case? > Most certainly, would've saved us a lot of headache, and money. >=20 > You argue that it's a fundamental language change, I -and seemingly a = lot > of others- argue that this is more of a bug fix. Just a few weeks ago I was refactoring some particularly horrible code = developed by previously employed developers =E2=80=94 a code based that = has a 1400 line function and many other functions 100s of lines long, = and I added some initialization for variable and array elements prior to = their use. Unfortunately my changes broke the code because the original developer = using isset($var) as branching criteria. After finding this bug, I = realized that this code base uses that technique frequently. I am know = from lots of experience that this is a common technical among WordPress = plugins. If PHP8 were to change to require variables and/or array elements to be = initialized then this code base and any similar to it will be broken. = Companies with these code bases almost certainly will simply not upgrade = to PHP 8. Probably ever. BTW, prior to gaining this company as a client, the internal people felt = that the codebase needed to be completely rewritten rather than = incrementally refactored. And because rewriting would have been such a = large project they have been putting it off for several years. In their = case, we will be cleaning up the code base (although doing so will be = very costly for them.)=20 And I estimate there are a large number of similar scenarios in the wild = that do not currently have plans the people or the funds to clean up = their similar code. #jmtcw -Mike --Apple-Mail=_35C53316-8856-4356-90E8-084A08D5A90F--