> On 25 Jan 2017, at 09:48, Scott Arciszewski <sc...@paragonie.com> wrote:
> 
> All,
> 
> Given that we can now declare a class constant as public, protected, or
> private, can we also declare them final in 7.2?
> 
> https://3v4l.org/rJG0V
> 
> Ideally, this code would error on line 18 rather than 15.
> 
> Scott Arciszewski
> Chief Development Officer
> Paragon Initiative Enterprises <https://paragonie.com>

In my book, ideally, there would be no class constant inheritance as inherited 
constants don't really make sense when they are known at compile time. People 
often use this feature in order to get things like this to work:

    class LibLevelClass {
        const FOO = "default";
        public function doSomething() {
            echo "the value of FOO is: " . static::FOO;
        }
    }

    class ExtensionClass {
        const FOO = "custom";
    }

But this approach is error prone due to untyped nature of constants (one could 
override the constant with an array value). In the end this inheritance is 
always unnecessary.


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to