Skip to content

Commit da35fa2

Browse files
committed
Fixed bug #77772
1 parent a467a89 commit da35fa2

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2019, PHP 7.2.18
44

5+
- Reflection:
6+
. Fixed bug #77772 (ReflectionClass::getMethods(null) doesn't work). (Nikita)
7+
58
04 Apr 2019, PHP 7.2.17
69

710
- Core:

ext/reflection/php_reflection.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4246,15 +4246,14 @@ ZEND_METHOD(reflection_class, getMethods)
42464246
reflection_object *intern;
42474247
zend_class_entry *ce;
42484248
zend_long filter = 0;
4249-
int argc = ZEND_NUM_ARGS();
4249+
zend_bool filter_is_null = 1;
42504250

42514251
METHOD_NOTSTATIC(reflection_class_ptr);
4252-
if (argc) {
4253-
if (zend_parse_parameters(argc, "|l", &filter) == FAILURE) {
4254-
return;
4255-
}
4256-
} else {
4257-
/* No parameters given, default to "return all" */
4252+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
4253+
return;
4254+
}
4255+
4256+
if (filter_is_null) {
42584257
filter = ZEND_ACC_PPP_MASK | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL | ZEND_ACC_STATIC;
42594258
}
42604259

@@ -4442,15 +4441,14 @@ ZEND_METHOD(reflection_class, getProperties)
44424441
reflection_object *intern;
44434442
zend_class_entry *ce;
44444443
zend_long filter = 0;
4445-
int argc = ZEND_NUM_ARGS();
4444+
zend_bool filter_is_null = 1;
44464445

44474446
METHOD_NOTSTATIC(reflection_class_ptr);
4448-
if (argc) {
4449-
if (zend_parse_parameters(argc, "|l", &filter) == FAILURE) {
4450-
return;
4451-
}
4452-
} else {
4453-
/* No parameters given, default to "return all" */
4447+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
4448+
return;
4449+
}
4450+
4451+
if (filter_is_null) {
44544452
filter = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC;
44554453
}
44564454

ext/reflection/tests/bug77772.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #77772: ReflectionClass::getMethods(null) doesn't work
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
public $prop;
8+
public function method() {}
9+
}
10+
11+
$rc = new ReflectionClass(Test::class);
12+
foreach ($rc->getMethods(null) as $method) {
13+
var_dump($method->getName());
14+
}
15+
foreach ($rc->getProperties(null) as $prop) {
16+
var_dump($prop->getName());
17+
}
18+
19+
?>
20+
--EXPECT--
21+
string(6) "method"
22+
string(4) "prop"

0 commit comments

Comments
 (0)