[PHP-BUG] Req #69980 [NEW]: Support to private/protected const on classes

[email protected] ("david dot proweb at gmail dot com")
Newsgroups php.standards
Message-ID <[email protected]>
From:             david dot proweb at gmail dot com
Operating system: 
PHP version:      7.0.0alpha2
Package:          PHP Language Specification
Bug Type:         Feature/Change Request
Bug description:Support to private/protected const on classes

Description:
------------
Currently, const defined in classes are always public. I suggest allow
private/protected it. It'll allow I define my own private/protected
constants inside my class, without need create a static
private/protected property to store this kind of data.

Currently:

    class Test 
    {
        private static $VERSION_MATCH = '/^\d+\.\d+$/';
        public static function match($version) 
        {
            return preg_match(self::$VERSION_MATCH, $version);
        }
    }

After implementation:

    class Test 
    {
        private const VERSION_MATCH = '/^\d+\.\d+$/';
        public static function match($version) 
        {
            return preg_match(self::VERSION_MATCH, $version);
        }
    }

Imagine that I don't want that this const be public.

    class_statement:
        variable_modifiers property_list ';'
 ~    | class_member_modifier T_CONST class_const_list ';'
      | T_USE name_list trait_adaptations
      | method_modifiers function returns_ref identifier '('
parameter_list ')'
            return_type backup_doc_comment method_body;

 +  class_member_modifier:
 +      /* empty */
 +    | T_PUBLIC
 +    | T_PROTECTED
 +    | T_PRIVATE
 +    | T_FINAL;


-- 
Edit bug report at https://bugs.php.net/bug.php?id=69980&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=69980&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=69980&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=69980&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=69980&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=69980&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=69980&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=69980&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=69980&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=69980&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=69980&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=69980&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=69980&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=69980&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69980&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=69980&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=69980&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=69980&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69980&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=69980&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=69980&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.