Bug #78248 [Opn->Wfx]: ReflectionClass::getMethods() filters as ANY not ALL bitmap fields

From: Date: Thu, 04 Jul 2019 08:01:43 +0000
Subject: Bug #78248 [Opn->Wfx]: ReflectionClass::getMethods() filters as ANY not ALL bitmap fields
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221631@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 Updated by: nikic@php.net Reported by: zerkms at zerkms dot ru Summary: ReflectionClass::getMethods() filters as ANY not ALL bitmap fields -Status: Open +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: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#221631) next »