|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74261 ReflectionClassConstant not documented
Submitted: 2017-03-17 12:35 UTC Modified: 2017-08-20 14:40 UTC
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: Assigned: cmb (profile)
Status: Closed Package: Reflection related
PHP Version: 7.1.3 OS: *
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.
Bug Type:
New email:
PHP Version: OS:


 [2017-03-17 12:35 UTC]
As of PHP 7.1.0 it is possible to explicitly specify the
visibility of class constants. However,
ReflectionClass::getConstants() returns all constants as simple
associative array, and ::getConstant() returns a simple string, so
there is no way to find out which of the constants can be accessed
from outside the class. Therefore, it would be nice if an optional
$filter argument could be passed to ::getConstants() similar to

Another option would be to implement ReflectionConstant as
suggested in request #45569.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-17 12:43 UTC]
-Summary: getConstants() should accept filter argument +Summary: ReflectionClassConstant not documented -Type: Feature/Change Request +Type: Documentation Problem
 [2017-03-17 12:43 UTC]
We already have ::getReflectionConstant() and ::getReflectionConstants(), which return ReflectionClassConstant. Switching to doc bug.
 [2017-03-17 12:58 UTC]
-Assigned To: +Assigned To: cmb
 [2017-03-17 12:58 UTC]
Thanks, Nikita!
 [2017-05-13 13:31 UTC] sam dot ventimiglia at gmail dot com
 * @version php 7.1
 * @since 13-05-2017
 * @see
class ReflClass
    //different constant visibility's types

    const PUBLIC_CONST = 'implicity public';
    public const PUBLIC_EXP = 'explicity public';
    protected const PROTECTED_CONST = 'protected';
    private const PRIVATE_CONST = 'private';

    // use of it
    $oClass = new ReflectionClass('ReflClass');

    foreach ($oClass->getConstants() as $const){

    /* this produce */
    // string(16) "implicity public"
    // string(16) "explicity public"
    // string(9) "protected"
    // string(7) "private"
 [2017-05-21 18:11 UTC] tomas dot vot at gmail dot com
I have the same problem, method is not documented.

PHP (cli) (built: Mar  2 2017 10:40:28) ( NTS )
Ubutnu 17.04
 [2017-08-20 14:40 UTC]
Automatic comment from SVN on behalf of cmb
Log: Fix bug #74261: ReflectionClassConstant not documented
 [2017-08-20 14:40 UTC]
-Status: Assigned +Status: Closed
 [2020-02-07 06:06 UTC]
Automatic comment on behalf of cmb
Log: Fix bug #74261: ReflectionClassConstant not documented
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun May 29 09:05:45 2022 UTC