php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #27926 No access-modified constants
Submitted: 2004-04-08 20:43 UTC Modified: 2006-04-03 12:39 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: jevon at jevon dot org Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.0.0RC1 OS: XP SP1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jevon at jevon dot org
New email:
PHP Version: OS:

 

 [2004-04-08 20:43 UTC] jevon at jevon dot org
Description:
------------
It doesn't appear that you can change the access modifiers on constants - are they public by default? It seems to make more sense to be able to define access modifiers on constants (since you can with every other component in classes). Consistency?

Reproduce code:
---------------
<?php
class Foo {
  const a = 1;
  public const b = 2;
  private const c = 3;

  static function bar() {
    return c;
  }
}

echo Foo::a;
echo Foo::b;
echo Foo::c;
echo Foo::bar();
?>

Expected result:
----------------
1
2
ERROR: Cannot access a private constant 'c'
3

Actual result:
--------------
Parse error: parse error, unexpected T_CONST, expecting T_VARIABLE in C:\Web\construct\php\php5test\test10.php on line 4
PHP Parse error: parse error, unexpected T_CONST, expecting T_VARIABLE in C:\Web\construct\php\php5test\test10.php on line 4 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-03 12:39 UTC] tony2001@php.net
Duplicate of bug #27022.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 15:01:31 2024 UTC