Req #69980 [Com]: Support to private/protected const on classes
| From: | sean at siobud dot com | Date: | Wed, 19 Aug 2015 19:15:26 +0000 |
| Subject: | Req #69980 [Com]: Support to private/protected const on classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-195353@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69980&edit=1
ID: 69980
Comment by: sean at siobud dot com
Reported by: david dot proweb at gmail dot com
Summary: Support to private/protected const on classes
Status: Open
Type: Feature/Change Request
Package: Class/Object related
PHP Version: 7.0.0alpha2
Block user comment: N
Private report: N
New Comment:
This is a duplicate of https://bugs.php.net/bug.php?id=27022
Previous Comments:
------------------------------------------------------------------------
[2015-07-02 12:05:48] david dot proweb at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=69980&edit=1