Bug #65044 [Opn->Nab]: Unable to filter using RelectionClass::getMethods
| From: | danack@php.net | Date: | Sat, 16 Jan 2016 13:14:08 +0000 |
| Subject: | Bug #65044 [Opn->Nab]: Unable to filter using RelectionClass::getMethods | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-198713@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65044&edit=1
ID: 65044
Updated by: danack@php.net
Reported by: aik dot bold at gmail dot com
Summary: Unable to filter using RelectionClass::getMethods
-Status: Open
+Status: Not a bug
Type: Bug
Package: Reflection related
Operating System: Slackware 13 x64
PHP Version: 5.4.16
Block user comment: N
Private report: N
New Comment:
You have discovered that bit-flag operations do not behave the same as logic operations.
There no way to filter with the bit flags to just get the non-static methods. You will need to
filter them yourself with !$reflectionMethod->isStatic() for all of the methods that match
$class->getMethods(ReflectionMethod::IS_PUBLIC)
Previous Comments:
------------------------------------------------------------------------
[2013-06-16 10:09:34] aik dot bold at gmail dot com
Description:
------------
I'm trying to get all public, but not static methods of a class using following
code:
$methods = $class->getMethods(ReflectionMethod::IS_PUBLIC & ~
ReflectionMethod::IS_STATIC);
This however returns all public methods. It happens because of values of used
constants:
ReflectionMethod::IS_PUBLIC - 256 (decimal) and 100000000 (binary)
ReflectionMethod::IS_STATIC - 1 (decimal) and 000000001 (binary)
This way binary subtraction doesn't really do a thing.
I suppose these constant values are designed to expand method range returned and
not narrow down it instead.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65044&edit=1