Re: [RFC] Static class

From: Date: Sun, 30 Jun 2024 14:31:19 +0000
Subject: Re: [RFC] Static class
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi

On 6/29/24 17:56, Bilge wrote:
- Why is it a class-level flag and not an attribute (similar to the #[Override] attribute in PHP 8.3) ?
I believe Tim already answered this, and I understood his reasoning to be that keywords are used when they modify behaviour in a way that is meaningful for the consumer of that class. Or to put it another way, attributes are purely informational. For me personally, introducing an
You understood that correctly. The forward compatibility argument brought forward by the other participants is not really useful either, because consider the following:
    #[StaticClass]
    class Foo {
        public static function myFunc() { }
    }
    class Bar extends Foo {
        public function myNonStaticFunc() { }
    }
This would work fine in PHP 8.3, but break when upgrading to PHP 8.4! By using a keyword it is guaranteed that the code only runs on PHP versions that will reliably enforce all the constraints, preventing this gotcha during a PHP version upgrade. Best regards Tim Düsterhus

Thread (71 messages)

« previous php.internals (#124099) next »