Doc #80515 [Nab]: The behavior of ReflectionClass::getMethods() changed in 7.4
| From: | requinix@php.net | Date: | Mon, 14 Dec 2020 20:16:43 +0000 |
| Subject: | Doc #80515 [Nab]: The behavior of ReflectionClass::getMethods() changed in 7.4 | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-18261@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80515&edit=1
ID: 80515
Updated by: requinix@php.net
Reported by: mark at fastmail dot net
Summary: The behavior of ReflectionClass::getMethods()
changed in 7.4
Status: Not a bug
Type: Documentation Problem
Package: Reflection related
Operating System: Windows
PHP Version: 7.4.13
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2020-12-14 20:13:03] 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 19:57:20] requinix@php.net
|| is *boolean* OR
| is *bitwise* OR
You should have been using the latter.
------------------------------------------------------------------------
[2020-12-14 19:51:28] 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));
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80515&edit=1