|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65044 Unable to filter using RelectionClass::getMethods
Submitted: 2013-06-16 10:09 UTC Modified: 2016-01-16 13:14 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: aik dot bold at gmail dot com Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 5.4.16 OS: Slackware 13 x64
Private report: No CVE-ID: None
 [2013-06-16 10:09 UTC] aik dot bold at gmail dot com
I'm trying to get all public, but not static methods of a class using following 

$methods = $class->getMethods(ReflectionMethod::IS_PUBLIC & ~ 

This however returns all public methods. It happens because of values of used 

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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-15 00:48 UTC]
-Package: filter +Package: Reflection related
 [2016-01-16 13:14 UTC]
-Status: Open +Status: Not a bug
 [2016-01-16 13:14 UTC]
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)`
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 02 18:01:26 2023 UTC