mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix usage of casted string in ReflectionParameter ctor
This commit is contained in:
commit
70f59b3416
2 changed files with 20 additions and 2 deletions
|
@ -2306,10 +2306,10 @@ ZEND_METHOD(ReflectionParameter, __construct)
|
||||||
/* nothing to do. don't set is_closure since is the invoke handler,
|
/* nothing to do. don't set is_closure since is the invoke handler,
|
||||||
not the closure itself */
|
not the closure itself */
|
||||||
} else if ((fptr = zend_hash_find_ptr(&ce->function_table, lcname)) == NULL) {
|
} 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(name);
|
||||||
zend_string_release(lcname);
|
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();
|
RETURN_THROWS();
|
||||||
}
|
}
|
||||||
zend_string_release(name);
|
zend_string_release(name);
|
||||||
|
|
18
ext/reflection/tests/ReflectionParameter_ctor_cast.phpt
Normal file
18
ext/reflection/tests/ReflectionParameter_ctor_cast.phpt
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue