Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119837 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 95950 invoked from network); 8 Apr 2023 20:47:17 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Apr 2023 20:47:17 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B31F01804D4 for ; Sat, 8 Apr 2023 13:47:16 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 8 Apr 2023 13:47:13 -0700 (PDT) Received: by mail-yb1-f180.google.com with SMTP id d3so23864597ybu.1 for ; Sat, 08 Apr 2023 13:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680986832; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ltHRwkCdISE6adurQkCyLLTqltsMJMhpzXWdeaKvR10=; b=lEAFeCOPFrydBxcImTYn/qnykRyd6YZTw+jjD02GAC6YeWFOo/jQsIdDZfnAvGBkTF syMWYKarTrN5/f2Tmb8m4xKL89RxdO1lwd5fENGhO2O08FRjCg3Xur1MUaqZFji96M1a jo4ZUI7h4JHAkETciLVApWvBgbgJdAZeYv0Ak9IHu0trbd/mX/gFvPjnAzTbP/FW+GeW lZXTsYoU7we8RK2yLXk++QE50gvL8U2BcO0VatzxVWrl4CYYq6vX3LFhH+BIjGqpRsIp vImbOPWpYSNkk3nAF1pZWaI2uEeX/i6W5KFpp9UfShywHJHb3apwbZd2sv/DQIz88Sbs FkYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680986832; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ltHRwkCdISE6adurQkCyLLTqltsMJMhpzXWdeaKvR10=; b=jF1xSqVn4snrnnGbLSX4tX4Fz7e5ut+sXNZWrVm3fxhleugcdSINcdryDOzxERVL8W 5uQebQ9xsJNmzFW06Xt1wFuZf+g8Xpto4jekIaPE4gJNoa3CiYfW2tVi7TgPqYCFRQOm cVMo3U0rcG3jBsPG1T0VfA+33b3e3007pIEigDzP3kFSu8ZaQIYwnv9ke2hGdwivkUNO SPH1kNQCBMeKgP25l/M6ZenHkkUwkw3lkLYxEUhWjusm4TimZpFMKr8B+tbesVpBBAXQ p5ugIR8zMJefN3K0bDcJBYsiIN2u7dLa2vl3kAgW8hddThyqqTKywgm2Tkkba4lSJzGT c04Q== X-Gm-Message-State: AAQBX9f3rUjeJ7Un0L4Uw2oIeYJFICh/G/0xrKPj0EyI08YgHyx/s2oK aNa9vO2FVa/vHE8MxMuYjFmYFtctDrrI7V81WtU= X-Google-Smtp-Source: AKy350Yd0nX2DD/b22iVPlQ1BC94kJmWWuSltK/LH+Hbh2LnfwCo2o3lWJl8rNvDioZx7Q1xpXoJqkuNb1WMwhZVtXk= X-Received: by 2002:a25:734f:0:b0:b71:addc:e19c with SMTP id o76-20020a25734f000000b00b71addce19cmr3156831ybc.8.1680986832352; Sat, 08 Apr 2023 13:47:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 8 Apr 2023 16:47:01 -0400 Message-ID: To: Kamil Tekiela Cc: Stephan Soller , internals@lists.php.net Content-Type: multipart/alternative; boundary="00000000000003ba1a05f8d93ffc" Subject: Re: [PHP-DEV] Future stability of PHP? From: dliebner@gmail.com (Dan Liebner) --00000000000003ba1a05f8d93ffc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I agree with the OP's sentiment here. If I was starting a codebase from scratch today, I'd probably go with Node. I find that writing modern JavaScript is way easier than writing PHP these days, and the breaking changes in newer PHP versions make writing code harder rather than easier. PHP is the foundation for many legacy codebases, and breaking old projects isn't really a great selling point of new PHP versions. Hopefully this scenario will affect enough people that 7.4 will continue to be maintained by some group of people into the foreseeable future. Best, Dan On Sat, Apr 8, 2023 at 4:28=E2=80=AFPM Kamil Tekiela = wrote: > Hi Stephan, > > Generally, PHP tries to keep as much backwards compatibility as possible. > Breaking changes are limited to minimum and done in the least obstructive > way possible. When a deprecation is introduced, you have at least 3 years > to update your code. > But PHP also tries to move forward and the language improves each year. W= e > certainly got many more features than breaking changes. Just think of mat= ch > expression, enums, attributes, constructor property promotion, new Random > API, readonly properties/classes, first-class callable, consistent errors > and many more. > The biggest improvement in PHP 7 and 8 was a comprehensive type system. > It's something that you don't have to use, therefore doesn't affect > existing code much, but makes development so much more enjoyable and less > bug-prone. I know I have discovered many bugs because of migration to PHP= 8 > and introduction of proper types. > And this is the direction PHP is going in. The language is still dynamic > and allows for taking the easy route, but new features focus on reducing > bugs by making the code's behaviour less surprising. > > If you try to adhere to clean code principles, upgrades should not be a > huge problem. Use static analysis and good tests. Learn and follow clean > code practices, e.g. SOLID. Use abstraction in your code; it's better to > change code only in one place than change it across hundreds of files. So= me > tools help you during migrations, such as Rector and phpcbf, but to use > them proficiently, your code needs to be free from surprises. Dynamic > properties are a very good example of surprising behaviour. By looking at > the definition of the class, you don't know what properties it has. If an= y > of the methods use undefined properties, both you and static analysers wi= ll > be surprised by this. > > There are certain things you should avoid in your code like fire. Not > because they might be removed from the language, but because they make yo= ur > code unclean and cause bugs. Here is my list: > - Arrays. Yes, they are a major feature of the language but also a major > pain in the... Use proper data structures, which may use arrays internall= y, > but don't use bare arrays in your code. Value objects and DTOs are > invaluable. > - Isset and empty. They are sometimes necessary and sometimes they are th= e > easiest choice, but they hide so many bugs. Every time you use any of the= m, > it should raise an immediate red flag. > - References. I don't understand why the language still has this feature. > Hack got rid of it and that was a very smart decision. You don't need > references. Use them almost never. > - Globals and superglobals. This should not need explaining. Pretty much = in > every language, these are pure evil. They make changes to the code an > experience similar to disarming a bomb. It's tempting to use $_GET, $_POS= T, > $_REQUEST anywhere in your code, but if you want to avoid bugs and > surprises, you'd better stay away from it. There should probably be at mo= st > one place in every project where these are used. > - extract() and compact(), and variable variables. These should only be > used in a very tightly controlled scope, and even then, their usage can b= e > contested. Ideally, variable variables should not exist in the language; = we > have arrays after all. > - Sanitizing filters. Sanitization is too ambiguous term to be useful. Wh= at > you should be using is validation and formatting. Validate your inputs to > make sure they are the type/value you expect. Format the output so that i= t > can't break the context it is in. > - Loose comparison. I have liked that about PHP in the past, but in recen= t > years I became a strong supporter of strict comparison. Why? Because "0" = =3D=3D > false. Forbid using loose comparison in your coding standard and forget > that it exists. Don't let the language make a fool out of you. You are th= e > developer and you know what type you expect. > > Following these guidelines will not only help you avoid bugs in your code > but also will make the upgrade process much less cumbersome. This and > adhering to the strictest level of the static analysis tool of your choic= e > is the recipe for success. > > Try to stay up to date with the changes. Every year when PHP releases a n= ew > version, go over the changelog and make an effort to learn and use new > features. Even if your production is 3 years behind, you can try these ou= t > in your development environment. > > PHP will move forward and add new features, but sometimes it must also > break some things to move forward. > > Kind Regards, > Kamil Tekiela > --00000000000003ba1a05f8d93ffc--