Re: Re: [RFC] [Concept] Class Constant visibility modifiers in PHP 7.1+
| From: | Stanislav Malyshev | Date: | Mon, 07 Sep 2015 07:02:36 +0000 |
| Subject: | Re: Re: [RFC] [Concept] Class Constant visibility modifiers in PHP 7.1+ | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88077@lists.php.net to get a copy of this message | ||
Hi!
> Funny you should propose this now, I was wanting this feature just the
> other day. This would be a useful addition, and clean up a strange
> inconsistency: why can methods and properties have visibility modifiers,
> but not constants?
Private and protected methods and properties are private for a reason -
they may be radically changed or gone when the code is changing, and
thus external code should not rely on them, and the way to ensure it is
to deny that code access to them. However, I have hard time seeing how
that would apply to constants - they shouldn't really change, and if
they do, they either shouldn't be constant, or something in your world
changed fundamentally (i.e. scientists discovered that PI actually
equals to 4). I wonder if you find in your code constant that you need
to hide because you foresee it changing - should it really be a constant
at all?
--
Stas Malyshev
smalyshev@gmail.com