Doc #74261 [Com]: ReflectionClassConstant not documented
| From: | sam dot ventimiglia at gmail dot com | Date: | Sat, 13 May 2017 13:31:41 +0000 |
| Subject: | Doc #74261 [Com]: ReflectionClassConstant not documented | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-14687@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74261&edit=1
ID: 74261
Comment by: sam dot ventimiglia at gmail dot com
Reported by: cmb@php.net
Summary: ReflectionClassConstant not documented
Status: Assigned
Type: Documentation Problem
Package: Reflection related
Operating System: *
PHP Version: 7.1.3
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
/**
* @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"
Previous Comments:
------------------------------------------------------------------------
[2017-03-17 12:58:19] cmb@php.net
Thanks, Nikita!
------------------------------------------------------------------------
[2017-03-17 12:43:57] nikic@php.net
We already have ::getReflectionConstant() and ::getReflectionConstants(), which return
ReflectionClassConstant. Switching to doc bug.
------------------------------------------------------------------------
[2017-03-17 12:35:12] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74261&edit=1