Skip to content

Commit

Permalink
Fixed bug #77772
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Mar 22, 2019
1 parent a467a89 commit da35fa2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2019, PHP 7.2.18

- Reflection:
. Fixed bug #77772 (ReflectionClass::getMethods(null) doesn't work). (Nikita)

04 Apr 2019, PHP 7.2.17

- Core:
Expand Down
26 changes: 12 additions & 14 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -4246,15 +4246,14 @@ ZEND_METHOD(reflection_class, getMethods)
reflection_object *intern;
zend_class_entry *ce;
zend_long filter = 0;
int argc = ZEND_NUM_ARGS();
zend_bool filter_is_null = 1;

METHOD_NOTSTATIC(reflection_class_ptr);
if (argc) {
if (zend_parse_parameters(argc, "|l", &filter) == FAILURE) {
return;
}
} else {
/* No parameters given, default to "return all" */
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
return;
}

if (filter_is_null) {
filter = ZEND_ACC_PPP_MASK | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL | ZEND_ACC_STATIC;
}

Expand Down Expand Up @@ -4442,15 +4441,14 @@ ZEND_METHOD(reflection_class, getProperties)
reflection_object *intern;
zend_class_entry *ce;
zend_long filter = 0;
int argc = ZEND_NUM_ARGS();
zend_bool filter_is_null = 1;

METHOD_NOTSTATIC(reflection_class_ptr);
if (argc) {
if (zend_parse_parameters(argc, "|l", &filter) == FAILURE) {
return;
}
} else {
/* No parameters given, default to "return all" */
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
return;
}

if (filter_is_null) {
filter = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC;
}

Expand Down
22 changes: 22 additions & 0 deletions ext/reflection/tests/bug77772.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
Bug #77772: ReflectionClass::getMethods(null) doesn't work
--FILE--
<?php

class Test {
public $prop;
public function method() {}
}

$rc = new ReflectionClass(Test::class);
foreach ($rc->getMethods(null) as $method) {
var_dump($method->getName());
}
foreach ($rc->getProperties(null) as $prop) {
var_dump($prop->getName());
}

?>
--EXPECT--
string(6) "method"
string(4) "prop"

0 comments on commit da35fa2

Please sign in to comment.