php.net |  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
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: cmb@php.net 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.
Password:
Status:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [2017-03-17 12:35 UTC] cmb@php.net
Description:
------------
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
::getMethods().

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-17 12:43 UTC] nikic@php.net
-Summary: getConstants() should accept filter argument +Summary: ReflectionClassConstant not documented -Type: Feature/Change Request +Type: Documentation Problem
 [2017-03-17 12:43 UTC] nikic@php.net
We already have ::getReflectionConstant() and ::getReflectionConstants(), which return ReflectionClassConstant. Switching to doc bug.
 [2017-03-17 12:58 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2017-03-17 12:58 UTC] cmb@php.net
Thanks, Nikita!
 [2017-05-13 13:31 UTC] sam dot ventimiglia at gmail dot com
/**
 * @version php 7.1
 * @since 13-05-2017
 * @see http://php.net/manual/en/reflectionclass.getconstants.php
 */
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){

        var_dump($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 7.1.2-4+deb.sury.org~yakkety+1 (cli) (built: Mar  2 2017 10:40:28) ( NTS )
Ubutnu 17.04
 [2017-08-20 14:40 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=342886
Log: Fix bug #74261: ReflectionClassConstant not documented
 [2017-08-20 14:40 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2020-02-07 06:06 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=cf616ef1f0bd14778a591210de8a231fa564e863
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