From 55733a8664b8853b003e70251c58bc8cb2d82a6b Mon Sep 17 00:00:00 2001
From: Nicolas Grekas <nicolas.grekas@gmail.com>
Date: Mon, 12 Dec 2022 16:54:21 +0100
Subject: [PATCH] Fix getting the name of closures on PHP 8.1.11+

---
 LazyString.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/LazyString.php b/LazyString.php
index 3b10595..9c7a9c5 100644
--- a/LazyString.php
+++ b/LazyString.php
@@ -148,7 +148,7 @@ private static function getPrettyName(callable $callback): string
         } elseif ($callback instanceof \Closure) {
             $r = new \ReflectionFunction($callback);
 
-            if (false !== strpos($r->name, '{closure}') || !$class = $r->getClosureScopeClass()) {
+            if (false !== strpos($r->name, '{closure}') || !$class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
                 return $r->name;
             }