php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #27022 Class constant has no visibility modificator
Submitted: 2004-01-23 12:47 UTC Modified: 2015-12-23 19:55 UTC
Votes:27
Avg. Score:4.6 ± 0.6
Reproduced:25 of 25 (100.0%)
Same Version:3 (12.0%)
Same OS:16 (64.0%)
From: andrey@php.net Assigned: seander (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.0 OS: *
Private report: No CVE-ID: None
 [2004-01-23 12:47 UTC] andrey@php.net
Description:
------------
It is not possible to use visibility modificator like public/protected/private on a class constant.

Reproduce code:
---------------
php -r "class fubar { protected const some_const = 123; }"

Actual result:
--------------
PHP Parse error:  parse error, unexpected T_CONST, expecting T_VARIABLE in Command line code on line 1

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-21 19:38 UTC] johannes@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2011-09-15 09:01 UTC] pulzarraider at gmail dot com
It would be great if php will have private/protected constants inside classes. It's very important feature for every real object programming language. If it would be available, the status of PHP, as a programming language, will grow.
 [2015-01-08 22:40 UTC] ajf@php.net
-PHP Version: 5CVS-2004-01-23 (dev) +PHP Version: 7.0
 [2015-01-08 22:40 UTC] ajf@php.net
This looks reasonable, bumping version.
 [2015-08-19 19:14 UTC] sean at siobud dot com
This seems to be a dupe of https://bugs.php.net/bug.php?id=69980

I started working on this, and will open a PR against php-src in the next couple of days. I don't intended on it getting merged anytime soon, but it is fun to work on.
 [2015-12-23 19:55 UTC] seander@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: seander
 [2015-12-23 19:55 UTC] seander@php.net
This was merged and available in master, the first release that will have it is (7.1)

thanks!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC