summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-11-24 16:42:52 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-11-24 16:42:52 +0100
commit70f59b3416992341f9245459f9cd26f363151f1c (patch)
tree793cd319a84209d2395262dbd9e8538b4847ef1c /ext/reflection
parentfc26ad9b1220fdfd7db15ecaff5e7c38283c55b6 (diff)
parent706241f82d675421766b23fad4923f22b2c8e32c (diff)
downloadphp-git-70f59b3416992341f9245459f9cd26f363151f1c.tar.gz
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix usage of casted string in ReflectionParameter ctor
Diffstat (limited to 'ext/reflection')
-rw-r--r--ext/reflection/php_reflection.c4
-rw-r--r--ext/reflection/tests/ReflectionParameter_ctor_cast.phpt18
2 files changed, 20 insertions, 2 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 114b2c273f..dfa084caa5 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2306,10 +2306,10 @@ ZEND_METHOD(ReflectionParameter, __construct)
/* nothing to do. don't set is_closure since is the invoke handler,
not the closure itself */
} else if ((fptr = zend_hash_find_ptr(&ce->function_table, lcname)) == NULL) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0,
+ "Method %s::%s() does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name));
zend_string_release(name);
zend_string_release(lcname);
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Method %s::%s() does not exist", ZSTR_VAL(ce->name), Z_STRVAL_P(method));
RETURN_THROWS();
}
zend_string_release(name);
diff --git a/ext/reflection/tests/ReflectionParameter_ctor_cast.phpt b/ext/reflection/tests/ReflectionParameter_ctor_cast.phpt
new file mode 100644
index 0000000000..10f45647e6
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_ctor_cast.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test method name string cast in ReflectionParameter ctor
+--FILE--
+<?php
+
+class A {}
+try {
+ new ReflectionParameter([
+ A::class,
+ new class { public function __toString() { return 'method'; } }
+ ], 'param');
+} catch (ReflectionException $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Method A::method() does not exist