Skip to content

Commit 5a111a0

Browse files
Fix getting the name of closures on PHP 8.1.11+
1 parent 24c5f18 commit 5a111a0

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

Console/Descriptor/JsonDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ private function getCallableData($callable): array
361361
}
362362
$data['name'] = $r->name;
363363

364-
if ($class = $r->getClosureScopeClass()) {
364+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
365365
$data['class'] = $class->name;
366366
if (!$r->getClosureThis()) {
367367
$data['static'] = true;

Console/Descriptor/MarkdownDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ protected function describeCallable($callable, array $options = [])
377377
}
378378
$string .= "\n".sprintf('- Name: `%s`', $r->name);
379379

380-
if ($class = $r->getClosureScopeClass()) {
380+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
381381
$string .= "\n".sprintf('- Class: `%s`', $class->name);
382382
if (!$r->getClosureThis()) {
383383
$string .= "\n- Static: yes";

Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ private function formatCallable($callable): string
614614
if (str_contains($r->name, '{closure}')) {
615615
return 'Closure()';
616616
}
617-
if ($class = $r->getClosureScopeClass()) {
617+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
618618
return sprintf('%s::%s()', $class->name, $r->name);
619619
}
620620

Console/Descriptor/XmlDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ private function getCallableDocument($callable): \DOMDocument
548548
}
549549
$callableXML->setAttribute('name', $r->name);
550550

551-
if ($class = $r->getClosureScopeClass()) {
551+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
552552
$callableXML->setAttribute('class', $class->name);
553553
if (!$r->getClosureThis()) {
554554
$callableXML->setAttribute('static', 'true');

0 commit comments

Comments
 (0)