Adjust pretty name of closures on PHP 8.4 (#6351)

related to https://github.com/php/php-src/pull/13550

see analog symfony change: https://github.com/symfony/symfony/pull/54614
This commit is contained in:
Markus Staab 2024-11-19 18:05:21 +01:00 committed by GitHub
parent faf1e26bac
commit e710b3750f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -80,7 +80,7 @@ use function preg_match_all;
use function preg_replace; use function preg_replace;
use function shell_exec; use function shell_exec;
use function spl_object_id; use function spl_object_id;
use function str_ends_with; use function str_contains;
use function str_pad; use function str_pad;
use function str_split; use function str_split;
use function str_starts_with; use function str_starts_with;
@ -121,7 +121,7 @@ final class Utils{
*/ */
public static function getNiceClosureName(\Closure $closure) : string{ public static function getNiceClosureName(\Closure $closure) : string{
$func = new \ReflectionFunction($closure); $func = new \ReflectionFunction($closure);
if(!str_ends_with($func->getName(), '{closure}')){ if(!str_contains($func->getName(), '{closure')){
//closure wraps a named function, can be done with reflection or fromCallable() //closure wraps a named function, can be done with reflection or fromCallable()
//isClosure() is useless here because it just tells us if $func is reflecting a Closure object //isClosure() is useless here because it just tells us if $func is reflecting a Closure object