Bug #73195 [NEW]: ReflectionClass::getMethod() filter arguments doesn't accept combinations
From: grgtvs at gmail dot com
Operating system: GNU/Linux
PHP version: Irrelevant
Package: Reflection related
Bug Type: Bug
Bug description:ReflectionClass::getMethod() filter arguments doesn't accept combinations
Description:
------------
It seems that when using filters argument with combinations of the
constants ReflectionMethod::IS_STATIC, ReflectionMethod::IS_PUBLIC,
ReflectionMethod::IS_PROTECTED, ReflectionMethod::IS_PRIVATE,
ReflectionMethod::IS_ABSTRACT, ReflectionMethod::IS_FINAL -
e.g $reflectionClassObj->getMethod(~ReflectionMethod::IS_PUBLIC)
or `$reflectionClassObj->getMethod(ReflectionMethod::IS_PUBLIC &
~ReflectionMethod::IS_STATIC)` etc.
the method tends to return every method as it would do without defining
any filters.
I've tried this on PHP 5.5.9 as well as at 7.0.8 and the result is the
same.
Test script:
---------------
class MyClass {
final public function iamFinalPublic()
{
}
public function iamPublic()
{
}
}
function testReflection()
{
$refl = new ReflectionClass(MyClass::class);
$methods = $refl->getMethods(~ReflectionMethod::IS_PUBLIC);
return count($methods);
}
echo testReflection();
Expected result:
----------------
0
Actual result:
--------------
2
--
Edit bug report at https://bugs.php.net/bug.php?id=73195&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73195&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73195&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73195&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73195&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73195&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73195&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73195&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73195&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73195&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73195&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73195&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73195&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73195&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73195&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73195&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73195&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73195&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73195&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73195&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73195&r=mysqlcfg
Thread (1 message)
- grgtvs at gmail dot com