Skip to content

Commit 2a8c64b

Browse files
Adjust pretty name of closures on PHP 8.4
1 parent 4e232c8 commit 2a8c64b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

LazyString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ private static function getPrettyName(callable $callback): string
148148
} elseif ($callback instanceof \Closure) {
149149
$r = new \ReflectionFunction($callback);
150150

151-
if (false !== strpos($r->name, '{closure}') || !$class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
151+
if (str_contains($r->name, '{closure') || !$class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
152152
return $r->name;
153153
}
154154

Tests/LazyStringTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testReturnTypeError()
6565
$s = LazyString::fromCallable(function () { return []; });
6666

6767
$this->expectException(\TypeError::class);
68-
$this->expectExceptionMessage('Return value of '.__NAMESPACE__.'\{closure}() passed to '.LazyString::class.'::fromCallable() must be of the type string, array returned.');
68+
$this->expectExceptionMessageMatches('{^Return value of .*\{closure.*\}\(\) passed to '.preg_quote(LazyString::class).'::fromCallable\(\) must be of the type string, array returned\.$}');
6969

7070
(string) $s;
7171
}

0 commit comments

Comments
 (0)