|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78248 ReflectionClass::getMethods() filters as ANY not ALL bitmap fields
Submitted: 2019-07-04 04:14 UTC Modified: 2019-07-04 08:11 UTC
From: zerkms at zerkms dot ru Assigned:
Status: Wont fix Package: Reflection related
PHP Version: 7.3.6 OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: zerkms at zerkms dot ru
New email:
PHP Version: OS:


 [2019-07-04 04:14 UTC] zerkms at zerkms dot ru
As always with bitmap filtering the items should be checked to satisfy all bitfields, not any of those

Test script:

class Foo
    public function one() {}
    static public function two() {}
    static protected function three() {}

$class = new ReflectionClass(Foo::class);

$methods = $class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC);

foreach ($methods as $method) {

Expected result:
object(ReflectionMethod)#3 (2) {
  string(3) "two"
  string(3) "Foo"

Actual result:
object(ReflectionMethod)#2 (2) {
  string(3) "one"
  string(3) "Foo"
object(ReflectionMethod)#3 (2) {
  string(3) "two"
  string(3) "Foo"
object(ReflectionMethod)#4 (2) {
  string(5) "three"
  string(3) "Foo"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-07-04 08:01 UTC]
-Status: Open +Status: Wont fix
 [2019-07-04 08:01 UTC]
I'm not sure which behavior is "right" here (both are useful depending on context and the current one matches the semantics of the bitwise operation), but this is a long-standing documented behavior that cannot be changed.
 [2019-07-04 08:11 UTC] zerkms at zerkms dot ru
> and the current one matches the semantics of the bitwise operation

unless it's never the case: I'm not sure I ever seen bitmap filters that implement `ANY` semantics.

I can pass an integer value with no bitwise `|`, or can assemble the number using the bitwise `&`.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Apr 22 11:01:25 2021 UTC