|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-07-02 18:23 UTC] requinix@php.net
-Package: PHP Language Specification
+Package: Class/Object related
[2015-08-19 19:15 UTC] sean at siobud dot com
[2015-08-19 19:21 UTC] nikic@php.net
-Status: Open
+Status: Duplicate
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 13:00:01 2025 UTC |
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;