Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123779 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 01CD71A009C for ; Mon, 24 Jun 2024 09:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719220167; bh=2Z2bAnqT5ICgtz+TsWWc2HbZrtwvMtIlcp/moOlr2Kg=; h=References:In-Reply-To:From:Date:Subject:To:From; b=bSxtf29jkaImnc3Ul9xzXv5d0TFkLZsvKkqJi4tSjyNm2AsSL6j+EqXaQpBBIztg+ fAT4h4D2Bx6Fokd9GZAZEqvPRRUEEhfxfKt8aP/DROxjPcAEvyIMyhSh0kNqPFgPjr Ry4RInVcJjl1qrPjwe8YsqWLSQXwA8mi3EZFDP1fMqnvuhgAHnQquwi7qG0RtsbVsW A+998ADh8ltp1oeBbs1kxXQDBRmd47BCi09rHXufSFoBLQLJMSdwo8k6pG9W7TLDZd XSB+X+rr7eTN0/ACCa9Xb+MfkCoVxe30asXVwolFLzPopq3bqbySXg4gYAMyjqDrsW rMzr4vNqLEyow== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0EDC8180038 for ; Mon, 24 Jun 2024 09:09:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 24 Jun 2024 09:09:26 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-dfe1aa7cce2so3833510276.1 for ; Mon, 24 Jun 2024 02:08:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech.net; s=google; t=1719220090; x=1719824890; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bIxj8LKaLRAWFUbampz6o2trDlFMXyQWhJxMdqM/0k0=; b=cZUl+zb5moFc9iBY3MrmHZF2R57i5xYWLPa4HCgVXHgcUbh/3W9t7HFVpWLIL78/aV CVxEzswT4RagKBoTbaK1uqj50+QYVVALGCMhSC2/l4ytSnHY3hcrFjjQEeLX952IL/Nw k4210tBX7lsUY+AXEX0XCdr06tnaKesuEihyroLKUME+MvyXS44q76DvrTOhkjHDOe90 0kXYCaLVP2OJoGIWcbcPkX97cGRQ6ZQoo9p33L14nQe4gFR3sHXrHxFZ1Jd10dQFpZjf R+d7Y4pdBVxBpZlJPqND9tx2PbfFLwXWQxKkWNd9zgg0koKPg2SVvo+LNdl/28FO7lk4 XfnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719220090; x=1719824890; h=content-transfer-encoding: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=bIxj8LKaLRAWFUbampz6o2trDlFMXyQWhJxMdqM/0k0=; b=cCUzRK9Kvwqb5p0PFTCpIww5qypRWHLs+/jl/mkKeIXwyf4BIg5IElUh5puq16RqLc XOHVSrpZ+a4ArZx5Ix13NIFUTItWZlF+03JTvBNFg/CbJMSJ50qGuxXUbHEXIgavza4M 7O7hCOzNEajXlH3f6UJ5g0DxnFVjt9hDN9c5Z2FazzxP2HoKNi25V324p2Mm8Wr6VL4p pFiHDBBp1gyE6ExIfPKxJKjJggiMTYHYKtXUdveJRbcpdo4beVyXB25we2opu3+XMo4k SPySD7bU59b3egka9BLwS6leZgqmfe9UbQBaknn8p1MYicMAUIQD0R5gSZv0aLXGzaND njmA== X-Gm-Message-State: AOJu0Ywpvn/w2DO0Zzy1Ze6korFC6v9nrQMMFpEU7o0bZDnHdAXO+HXk Z/qsb4KP9JVS9FNToMbCUa3y2rH8aqPH3COQ4dAneY1URJnM+YLRueBf7YZuVowq6/AxmyxhEu/ Htc0gf8vdsqq3JUEnmCCNZeidMZPxPhTk2AMmu0n3Tz0S5ClWw7ajpqS1 X-Google-Smtp-Source: AGHT+IHF43wiTagfe7PZ/6IQY0PzcdD1v7VOULfUdkrWg2oQsPOoWoORSG9uB8StzHFldbKjt/4Y5atGchGD5/ZrYFY= X-Received: by 2002:a25:b217:0:b0:dfa:7251:72f4 with SMTP id 3f1490d57ef6-e0303ed5488mr3476081276.8.1719220089650; Mon, 24 Jun 2024 02:08:09 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <88D83E92-94BE-4548-B398-8F5C74765FFD@gmail.com> In-Reply-To: <88D83E92-94BE-4548-B398-8F5C74765FFD@gmail.com> Date: Mon, 24 Jun 2024 11:07:58 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Static class To: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: andreas@dqxtech.net (Andreas Hennings) > I am pleased to present my first RFC: Static class To recap my opinion from the other thread: I generally support the idea to have a label to slap on all-static classes, to make that contract more explicit. The goal is not to promote a specific use of the language, but to add clarity to what already exists. Since my last response on the other thread, I warmed up more to namespaced floating functions, thanks Larry :) At the same time I don't see static methods and all-static classes fully going away soon, so I still support them having a label. But... > Why is it a class-level flag and not an attribute (similar to the `#[Ove= rride]` attribute in PHP 8.3) ? I don't know that it needs to be a language keyword. An attribute would be ok for me, or even just a doc tag with phpstan. In fact maybe a feature request with phpstan could be a starting point. > One question our razor cannot answer is whether static member declaration= s still require the static keyword in a static class. Marking a class reado= nly makes marking properties with the same optional, thus one might argue s= tatic should follow suit. However, I opine it should not. Unlike readonly, = which typically applies to properties declared near the head of the class (= by convention) where the same mark is also applied, static members appear t= hroughout the full length of the class body. That is, it should be apparent= when jumping anywhere into a static class that its members are static, wit= hout having to check the class declaration. I prefer that the static keyword be required on the members. This supports the common use case of incremental refactoring, where methods are moved from one class to another, or a git merge where one branch adds the class-level static keyword, while another commit adds another method. > We cannot remove features from a static class that would otherwise be pre= sent in a standard class. I think I get the intent of this statement, but I don't really vibe with the wording. I would say we should limit the scope of a modifier keyword to its essence. And we should not remove features that are already being used in classes that would naturally qualify for the class-level static modifier.