php.net |  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
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: mark at fastmail dot net
New email:
PHP Version: OS:

 

 [2020-12-14 19:51 UTC] mark at fastmail dot net
Description:
------------
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:
---------------
<?php

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

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

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-14 19:57 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: Unknown/Other Function +Package: Reflection related
 [2020-12-14 19:57 UTC] requinix@php.net
|| 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] requinix@php.net
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: Wed Feb 28 13:01:27 2024 UTC