Skip to content

Commit 70f59b3

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix usage of casted string in ReflectionParameter ctor
2 parents fc26ad9 + 706241f commit 70f59b3

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

ext/reflection/php_reflection.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2306,10 +2306,10 @@ ZEND_METHOD(ReflectionParameter, __construct)
23062306
/* nothing to do. don't set is_closure since is the invoke handler,
23072307
not the closure itself */
23082308
} else if ((fptr = zend_hash_find_ptr(&ce->function_table, lcname)) == NULL) {
2309+
zend_throw_exception_ex(reflection_exception_ptr, 0,
2310+
"Method %s::%s() does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name));
23092311
zend_string_release(name);
23102312
zend_string_release(lcname);
2311-
zend_throw_exception_ex(reflection_exception_ptr, 0,
2312-
"Method %s::%s() does not exist", ZSTR_VAL(ce->name), Z_STRVAL_P(method));
23132313
RETURN_THROWS();
23142314
}
23152315
zend_string_release(name);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Test method name string cast in ReflectionParameter ctor
3+
--FILE--
4+
<?php
5+
6+
class A {}
7+
try {
8+
new ReflectionParameter([
9+
A::class,
10+
new class { public function __toString() { return 'method'; } }
11+
], 'param');
12+
} catch (ReflectionException $e) {
13+
echo $e->getMessage(), "\n";
14+
}
15+
16+
?>
17+
--EXPECT--
18+
Method A::method() does not exist

0 commit comments

Comments
 (0)