Bug #78248 [Wfx]: ReflectionClass::getMethods() filters as ANY not ALL bitmap fields
| From: | zerkms at zerkms dot ru | Date: | Thu, 04 Jul 2019 08:11:51 +0000 |
| Subject: | Bug #78248 [Wfx]: ReflectionClass::getMethods() filters as ANY not ALL bitmap fields | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-221632@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78248&edit=1
ID: 78248
User updated by: zerkms at zerkms dot ru
Reported by: zerkms at zerkms dot ru
Summary: ReflectionClass::getMethods() filters as ANY not ALL
bitmap fields
Status: Wont fix
Type: Bug
Package: Reflection related
Operating System: any
PHP Version: 7.3.6
Block user comment: N
Private report: N
New Comment:
> 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 &.
Previous Comments:
------------------------------------------------------------------------
[2019-07-04 08:01:43] nikic@php.net
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 04:14:44] zerkms at zerkms dot ru
Description:
------------
As always with bitmap filtering the items should be checked to satisfy all bitfields, not any of
those
Test script:
---------------
<?php
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) {
var_dump($method);
}
Expected result:
----------------
object(ReflectionMethod)#3 (2) {
["name"]=>
string(3) "two"
["class"]=>
string(3) "Foo"
}
Actual result:
--------------
object(ReflectionMethod)#2 (2) {
["name"]=>
string(3) "one"
["class"]=>
string(3) "Foo"
}
object(ReflectionMethod)#3 (2) {
["name"]=>
string(3) "two"
["class"]=>
string(3) "Foo"
}
object(ReflectionMethod)#4 (2) {
["name"]=>
string(5) "three"
["class"]=>
string(3) "Foo"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78248&edit=1