summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-03-22 12:39:27 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-03-22 12:39:27 +0100
commitda35fa2cb8d454c8e797067e28e647030a5fe5df (patch)
treed3026ce5809d0325560986b7854d808582660ed4 /ext/reflection
parenta467a89f167e9e03b4acc4bd9b1430e0d52133fa (diff)
downloadphp-git-da35fa2cb8d454c8e797067e28e647030a5fe5df.tar.gz
Fixed bug #77772
Diffstat (limited to 'ext/reflection')
-rw-r--r--ext/reflection/php_reflection.c26
-rw-r--r--ext/reflection/tests/bug77772.phpt22
2 files changed, 34 insertions, 14 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index f1096fbe81..80e508c175 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -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;
}
@@ -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;
}
diff --git a/ext/reflection/tests/bug77772.phpt b/ext/reflection/tests/bug77772.phpt
new file mode 100644
index 0000000000..07696210c5
--- /dev/null
+++ b/ext/reflection/tests/bug77772.phpt
@@ -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"