php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65044 Unable to filter using RelectionClass::getMethods
Submitted: 2013-06-16 10:09 UTC Modified: 2016-01-16 13:14 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: aik dot bold at gmail dot com Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 5.4.16 OS: Slackware 13 x64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: aik dot bold at gmail dot com
New email:
PHP Version: OS:

 

 [2013-06-16 10:09 UTC] aik dot bold at gmail dot com
Description:
------------
I'm trying to get all public, but not static methods of a class using following 
code:

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

This however returns all public methods. It happens because of values of used 
constants:

ReflectionMethod::IS_PUBLIC - 256 (decimal) and 100000000 (binary)
ReflectionMethod::IS_STATIC - 1 (decimal) and 000000001 (binary)

This way binary subtraction doesn't really do a thing.

I suppose these constant values are designed to expand method range returned and 
not narrow down it instead.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-15 00:48 UTC] felipe@php.net
-Package: filter +Package: Reflection related
 [2016-01-16 13:14 UTC] danack@php.net
-Status: Open +Status: Not a bug
 [2016-01-16 13:14 UTC] danack@php.net
You have discovered that bit-flag operations do not behave the same as logic operations.

There no way to filter with the bit flags to just get the non-static methods. You will need to filter them yourself with !$reflectionMethod->isStatic() for all of the methods that match `$class->getMethods(ReflectionMethod::IS_PUBLIC)`
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC