On 09/07/2015 08:43 AM, Sean DuBois wrote:
On Sun, Sep 06, 2015 at 06:47:56PM +0100, Andrea Faulds wrote:
Hi Sean,

Sean DuBois wrote:
I am starting this discussion to get peoples opinion on the overall feature, 
and find someone
who would be interested in watching over my progress and making sure I
do the right things to hopefully get this merged.

The PHP bug tracker contains a few simple entries for a adding visibility 
modifiers to class constants.
https://bugs.php.net/bug.php?id=27022

I would be the one implementing this, and have a basic working version already 
(that
takes shortcuts like reusing property_info) but it works!
https://github.com/Sean-Der/php-src/compare/master...bug-69980-class-constants#diff-6231c13c8582758f41a5e2a015e3b5c5R1
There are cases where runtime/compile time checks pass/fail incorrectly,
but working on that now.

This change would involve breaking the API, but wouldn't involved any
language breaking changes. All current const declarations would just
default to public and keep the same behavior.
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?

I'd love to see this in PHP. Are you going to write an RFC?

Thanks!
--
Andrea Faulds
http://ajf.me/

Just one of those things that you you wish you had, but then end up
solving with other things (static properties) so we will see how long it
takes me to blunder through it :)

Reeze Xia started an RFC, but didn't have time to finish it. We talked
over GitHub and I will be taking it over fully.
https://wiki.php.net/rfc/class_const_visibility

I am just waiting on RFC Karma, after I get that I will start filling it in!
I really like this feature but please make sure it doesn't break BC on usage of Reflection::getConstant(s). For example I'm using this for an implementation of constant based enumerations:
(https://github.com/marc-mabe/php-enum/blob/master/src/Enum.php#L277)

Marc


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

Reply via email to