Re: [RFC] Static class
| From: | Tim Düsterhus | 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 internals+get-124099@lists.php.net to get a copy of this message | ||
Hi
On 6/29/24 17:56, Bilge wrote:
You understood that correctly. The forward compatibility argument brought forward by the other participants is not really useful either, because consider the following:- Why is it a class-level flag and not an attribute (similar to theI 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#[Override]attribute in PHP 8.3) ?
#[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