Final constants
I am a huge fan of using constants in PHP as I believe they are an excellent solution to avoid "magic strings" and "magic numbers" creeping into your code base and making them brittle, hard to refactor, and making typo related bugs an infuriatingly likely issue.
Constants provide a nice solution in that they are solid and predictable, and they cannot be accidentally or deliberately updated with new values – they are hardcoded.
One feature of PHP constants is that they can be overridden in child classes. This can be quite useful where you desire it, but it would also be quite common to desire that your constants are, well… constant.
For class properties and methods, we have had the ability to mark them as final
for quite some time. This means that it cannot be overridden in a child class and is a very useful way to ensure things remain robust and predictable.
Before PHP 8, the one place where constants could not be overridden...