Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123950 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 392D71ADE49 for ; Thu, 27 Jun 2024 18:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719512003; bh=koq0wesa2pIMV5KeEpMmyvEVW7lvHiaNEmc/161kdCw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Las87MySG7bjFrNs1ecxPR6DueUiQtwJANaLG6eure6R3lghPHdDswk6dvc7hdiB5 DXD5HGzXEGWFh8l168NHZ1jN5K8mAT6rW0NPapKmRjronRFUy3ibsWdDK66tDqGvtS Rq5uoANP08lG60WwSt9GGRG5Z+DxOJS85yV+fYUrgTuR+VeJpVnIXmPVUnAh1cdtj5 ffx23dP+pw5wnd6fviWAFi6xKb3cwFp+vYRy2CgNt9kvOx7GbZIThMhK7s5a+5r+Zq af1rDP7b4huWonvFxmRqLGezFGKeG+/DOSLsJEjq+G24kmid1PM8i2gDe9a+dM9H74 28Xah7538mOcQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8A47B180F6F for ; Thu, 27 Jun 2024 18:13:21 +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,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 chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Thu, 27 Jun 2024 18:13:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1719511918; bh=fgP1s5oMG8gtSSgsoDvgflvgHUZGQ4WLPbjVPo2WAJE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=NTBl+FvveVyTgGhH9v+OyKt2mRofcf4Ko0iA79D6otiVzNM5moBJn4/SfGMs0veAO OQTpiv7HrptmTKbGgdN18WwyWAN7Oa/R5Y8XzfthOC2xcuBtAivuLTqT8k0/BYxIpx 72arWJ8oOy1N2CHZVxBGg7HF6TMjM4q8BwTBAQeuc5OvTGwHL87eQrRR5aLPHhmU+/ qvB6hpdFHLmfTu9UHOzfQ8IyGQoXPb3i5Z76j32pAcP7iTi6SJ7etCa8+QwtjuKHDd CBLrqgXSQBLFgp+hrjTUaiQvSxW1faQvcdiChGMRrGY2GI/KPwAE/IWQQs4lcK76LR 9HpJtO730Bm8w== Message-ID: <554ffb9e-35c5-466e-aace-0501eee3d0bd@bastelstu.be> Date: Thu, 27 Jun 2024 20:11:57 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] Static class To: Ayesh Karunaratne , Bilge Cc: php internals References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 6/24/24 09:53, Ayesh Karunaratne wrote: > Personally, I think this will be a useful feature. Just like we have > `readonly` properties and `readonly` classes, I don't see why we can't > have static methods. I also saw in the draft PR that it does not > require a lot of changes to the engine to have this. > > I'd like to propose to add some more information and points addressed > in the RFC. This is of course merely a suggestion, but it's something > I was thinking when reading the RFC. > > - Why is it a class-level flag and not an attribute (similar to the > `#[Override]` attribute in PHP 8.3) ? To quote myself from the #[\Override] RFC: > This RFC proposes an attribute instead of a keyword, because contrary to other modifiers (e.g. visibility) that are part of the method signature, the attribute does not affect behavior or compatibility for users that further extend a given class and neither does it affect users that call the method. It is purely an assistance to the author of a given class. > Marking a class as 'static' *does* affect how the class may be used and thus the static-ness is part of the public API. Therefore it should be a keyword. Everything else would also be inconsistent with final classes effectively making all members final and readonly classes making all members readonly. > - Can a subclass extend a static parent class without using the > `static` keyword in the subclass? This will avoid a lot of BC issues > if a library decides to declare classes as static. It should not. See: readonly classes. I also believe that static classes should be implictly final. Given that no objects of such a class can exist, they cannot be exchanged by a different class anyways and inheritance is not meant for code reuse. Best regards Tim Düsterhus