Doc #73195 [Ana]: ReflectionClass::getMethod() filter arguments doesn't accept combinations
| From: | cmb@php.net | Date: | Thu, 29 Sep 2016 09:43:42 +0000 |
| Subject: | Doc #73195 [Ana]: ReflectionClass::getMethod() filter arguments doesn't accept combinations | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-13961@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73195&edit=1
ID: 73195
Updated by: cmb@php.net
Reported by: grgtvs at gmail dot com
Summary: ReflectionClass::getMethod() filter arguments
doesn't accept combinations
Status: Analyzed
Type: Documentation Problem
Package: Reflection related
Operating System: GNU/Linux
PHP Version: Irrelevant
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Unfortunately, using the complement (~) can't work without causing
a considerable BC break. For instance,
~IS_PUBLIC would
basically translate to `IS_STATIC | IS_FINAL | IS_ABSTRACT |
IS_PROTECTED | IS_PRIVATE`, so static public methods would be
returned, what is not desired.
The attached patch would change the semantics of bitwise
disjunction of the filter, so that all given flags would be
required. For instance, IS_PUBLIC | IS_PROTECTED would never
match.
So all we can do (at least for now) is to improve the docs.
Previous Comments:
------------------------------------------------------------------------
[2016-09-28 16:37:16] cmb@php.net
> Do you have karma, cmb?
Yes. I'll have a closer look at the issue, and check that the
change doesn't break anything else. If all works well, I'll treat
this as a bug, and apply to PHP-5.6+.
------------------------------------------------------------------------
[2016-09-28 16:29:09] johannes@php.net
I believe this was designed to do only "positive" filtering. If we get negation to work I
believe we should do this and add an example to the docs. Do you have karma, cmb?
------------------------------------------------------------------------
[2016-09-28 15:49:17] cmb@php.net
The following patch has been added/updated:
Patch Name: 73195
Revision: 1475077757
URL: https://bugs.php.net/patch-display.php?bug=73195&patch=73195&revision=1475077757
------------------------------------------------------------------------
[2016-09-28 15:48:59] cmb@php.net
The issue is not the logical disjunction (|), but rather the
negation (~) in combination with the fact, that getMethods()
simply checks, whether the logical conjunction (&) of the given
filter value and the stored value is non-zero. Even if there were
no hidden flags (but there are), ~ReflectionMethod::IS_PUBLIC
would catch final methods, for instance.
I'm not sure whether that is a bug, or just a documentation issue.
Anyhow, the fix appears to be trivial (see the attached
73195.patch).
Johannes, as you're listed as mainter of ext/reflection, what do
you think?
------------------------------------------------------------------------
[2016-09-28 10:05:11] grgtvs at gmail dot com
This seems just to be an undocumented issue not a bug
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=73195
--
Edit this bug report at https://bugs.php.net/bug.php?id=73195&edit=1