|  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
 [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-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 02 19:01:27 2023 UTC