|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80515 The behavior of ReflectionClass::getMethods() changed in 7.4
Submitted: 2020-12-14 19:51 UTC Modified: 2020-12-14 20:16 UTC
From: mark at fastmail dot net Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 7.4.13 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
30 - 6 = ?
Subscribe to this entry?

 [2020-12-14 19:51 UTC] mark at fastmail dot net
Specifying logically ORed filter arguments results in "and" behavior in 7.3, but results in "or" behavior in 7.4.  The provided test script returns both methods in 7.4, but only the first method in 7.3.  Should this change be added to the "Backward Incompatible Changes" page?

Test script:

class A{
    static function one(){}
    function two(){}

$class = new ReflectionClass(A::class);

var_dump($class->getMethods(ReflectionMethod::IS_PUBLIC || ReflectionMethod::IS_STATIC));


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-14 19:57 UTC]
-Status: Open +Status: Not a bug -Package: Unknown/Other Function +Package: Reflection related
 [2020-12-14 19:57 UTC]
|| is *boolean* OR
| is *bitwise* OR

You should have been using the latter.
 [2020-12-14 20:13 UTC] mark at fastmail dot net
Thanks very much for pointing that mistake out.  I suppose that means the behavior of "$reflectionClass->getMethods(true)" is really what changed.  I have noticed that undocumented "features" are sometimes mentioned in "Backward Incompatible Changes", but I'm guessing this wouldn't be a common/risky enough case to make the list.
 [2020-12-14 20:16 UTC]
Actually what changed was the value of the constants.

In 7.3, IS_PUBLIC=256 and IS_STATIC=1, thus true == 1 == IS_STATIC.
In 7.4, IS_PUBLIC=1 and IS_STATIC=16, thus true == 1 == IS_PUBLIC.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Feb 29 18:01:31 2024 UTC