Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123778 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 074B31A009C for ; Mon, 24 Jun 2024 08:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719217722; bh=rMce8k9mhzUwIiU0E3btyXHj3fnUjfAtGg801+XOTBg=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=R3s+2KfA7CiP6iitW+nHFMTsq2HlfcUSItTXQzvwJW2LhXsWUa8eT/CmBQEo4hdXm lafQ8+DpC3GkhZwlUfISIP6w539qS2yGAYD7hKv6Y76OvXxixa1rqbExO8PuKz5/aL Ud/HZYlGgPL1q3egmKqRHeRgA1om+k1UUvkoXBs+g6q24fDQbJSaAg8Tew0a+KDzoy HrAB0+NhUvwz/H7XEjnhx3UC9i4P6J9rtmuZdVTYxw9qC8bcm0VjFxwMAx6xEISRK3 XdjCYajRVQWcYWhMc3eBbg+yi1WXYUo2dfeFzv+0EVZ9gTIZej7FAzFld06h0n8N5O 5wXqsEkd6qr+w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 368D718007E for ; Mon, 24 Jun 2024 08:28:42 +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,FREEMAIL_FROM, 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-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 08:28:41 +0000 (UTC) Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-421b9068274so35526135e9.1 for ; Mon, 24 Jun 2024 01:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719217644; x=1719822444; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=rMce8k9mhzUwIiU0E3btyXHj3fnUjfAtGg801+XOTBg=; b=HgPArRTdCIx/kMFSdtzYTeQB+x4KIAFZ1zE/TsSM6TEr969qYewWMd6jPDHBLC2Nuo AwzJ7pBj5nCC+aOHMr8c8mcFzA6x4OC/m9gtZU9hrUD9LLFzZYX6iXGjsA1RHdGkt5cY 0fvb+71YpNnVJvS4bRyOCPuKWO6Q44Rhw81cYori/1WIcKW8nMYYpun7i6gVSYOqWtz7 KVGTVPVRkb/GZxg7NbcwyW5OiNVGtVALhzVbBz2W/n+caTPZq1xYMNrpugoG25mHdECR 8dCP1WB7hAeRcLul1E8HoARZYkKk//J69ix+L3QX50M+QJnaX+AmztK70LcfUHco+hHn mItA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719217644; x=1719822444; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rMce8k9mhzUwIiU0E3btyXHj3fnUjfAtGg801+XOTBg=; b=QDzRScK1mDmxS09PUEpsb578lveJERINUryyKz4s5NDuBrGN+Qji4bJ8W1AQeL6y1M cOnJaZZcNlr9OGlQCKrGBS2lQFC2uuZ/9xiORWgc7nrn20mIy+8XDUWSuZZL/sjQ1CdC Yo/nuk/6mCi5/La5r2LanZmsLeKzKPNJfhGYIQX0X9XUF3L5qtEu9pY9mGgNN1Zv3GIN TAT5wgDrbW/38zUpu96aSmmMnHa/3finrRm2/sS58XlXQnwgnr2GNqNureYn3Zd4nXv+ kvxF4Z3e/LRMIkOHyv/bFJYH/AZnW03dqcUQUB3rRTjowQhPyK19hUZbPyUujlfKlhM3 nMIw== X-Gm-Message-State: AOJu0YwZufETZ3Ss1vJDcQ33BnUF+5wj6Dgx2gYR7a+/euymb2J+Hq2k Tuz/LtVLD2wcPP9T8kyZ1mf8EzmgylSxhQXkcbaVPc1r0pwRNQgoaPk34g== X-Google-Smtp-Source: AGHT+IF8ZmlBs1LbzYzpG6gGcKjLYUccs8W9b+YyX+kl2Vah9NQ3v1vauLcpIti7u5ji3+ccuh2lLA== X-Received: by 2002:a7b:c418:0:b0:424:8c80:2f9f with SMTP id 5b1f17b1804b1-4248c80317emr27465175e9.5.1719217644236; Mon, 24 Jun 2024 01:27:24 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366387cf44asm9281396f8f.26.2024.06.24.01.27.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jun 2024 01:27:23 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: [PHP-DEV] [RFC] Static class In-Reply-To: Date: Mon, 24 Jun 2024 10:27:12 +0200 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: <88D83E92-94BE-4548-B398-8F5C74765FFD@gmail.com> References: To: Bilge X-Mailer: Apple Mail (2.3774.600.62) From: claude.pache@gmail.com (Claude Pache) > Le 24 juin 2024 =C3=A0 01:10, Bilge a =C3=A9cri= t : >=20 > Hi Internals! >=20 > I am pleased to present my first RFC: Static class = . >=20 > This work is based on the previous discussion thread on this list of = the same name, and hopefully captured all the relevant details, = notwithstanding anything unanticipated that may present itself during = the implementation. Let me know if you feel anything important has been = missed. I am aware it omits to mention specifics about messages so = emitted when runtime or compile-time errors occur, but I anticipate this = can be hashed out in the PR, unless consensus indicates otherwise. >=20 > I am aware this idea is not supported by everyone, but there seemed to = be enough positive voices for it to be worth a shot. I'd like to get a = better idea of where people might stand when it comes down to a vote, = now there is a formal RFC, so we know whether it's worth completing the = implementation, although any sentiments so proffered are of course not a = commitment to vote any particular way and nobody should feel compelled = to speak to that unless comfortable. Looking forward to feedback! >=20 > Cheers, > Bilge Hi, A general remark: I appreciate that a static class does not impose = arbitrary restrictions (like: implicitly `final`) on the class beyond = what is meaningful for staticness. On the other side, I don=E2=80=99t = think that we should support markers that are technically possible, but = semantically meaningless, like the `readonly` marker on class. ----- Some more specific remarks: * In the intro: =E2=80=9CA static class is a class whose members = (properties and methods) are all static=E2=80=9D. One of the most = important point is missing, namely: It is meaningless for a static class = to have instances. * In the =E2=80=9CProposal=E2=80=9D section, it should be stated = explicitly that any attempt to construct an instance, not only with = `new`, but also with any of the `ReflectionClass::newInstance*()` = methods, or with `unserialize()`, or with whatever other mean, shall = fail. ----- Should a static class be marked `readonly` or `abstract`? I think not, = because those have no real semantic meaning for static class; their = effects on static members are only consequences of their intended = meaning on non-static class: * Unless/until the `readonly` marker may be applied to static = properties, the only effect of such a keyword, is that it would prevent = the creation of static properties. I don=E2=80=99t know if that = restriction is useful, but in case it would be used for that purpose, it = would be hijacking the `readonly` marker for a something it wasn=E2=80=99t= intended for. * The main purpose of the `abstract` keyword is to prevent a class to be = instantiated, which (in case of static class) is more semantically = described by the `static` marker. Beyond that, it just allows to declare = a method that, if implemented by a subclass, should have a compatible = signature. Most notably, it does not prevent the other static members of = the class to be used directly. ---- The RFC says that a static class may extend a class not explicitly = marked as static, but with no instance member. This is not sound, = because a class with no instance members is not necessarily static. The = most obvious example is `stdClass` (which has no member at all, even if = their instances may have properties). =E2=80=94Claude