RE: [PHP-DEV] [RFC] [Draft] Final constants

From: Date: Wed, 21 Apr 2021 09:13:19 +0000
Subject: RE: [PHP-DEV] [RFC] [Draft] Final constants
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-114085@lists.php.net to get a copy of this message
Can I ask why you use late static binding while you don't want your constant value to be changed/overridden by child classes? IMHO, self::FOO is all you need. Personally, I don't use late static binding with class constants since the coding standard rule I previously referenced forbids this, but I don't think a coding style rule should be our only possibility to disallow constant overriding. After learning about the strange behavior Nikita pointed out, final constants would be even more useful than what I initially thought. I agree we should fix the weird behavior but that’s another topic. My point is actually what’s your scenario for a final constant? If you want to make sure the value you access are not changed by child class, self:: can serve the purpose already. If you want to make sure child classes can access the original value, parent:: or ParentClassName:: can do the job as well. Regards, CHU Zhaowei

« previous php.internals (#114085) next »