Skip to content

Commit 50acbe6

Browse files
Adjust pretty name of closures on PHP 8.4
1 parent 6a1c9ae commit 50acbe6

File tree

14 files changed

+14
-14
lines changed

14 files changed

+14
-14
lines changed

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ private function getCallableData($callable): array
356356
$data['type'] = 'closure';
357357

358358
$r = new \ReflectionFunction($callable);
359-
if (str_contains($r->name, '{closure}')) {
359+
if (str_contains($r->name, '{closure')) {
360360
return $data;
361361
}
362362
$data['name'] = $r->name;

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ protected function describeCallable($callable, array $options = [])
372372
$string .= "\n- Type: `closure`";
373373

374374
$r = new \ReflectionFunction($callable);
375-
if (str_contains($r->name, '{closure}')) {
375+
if (str_contains($r->name, '{closure')) {
376376
return $this->write($string."\n");
377377
}
378378
$string .= "\n".sprintf('- Name: `%s`', $r->name);

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ private function formatCallable($callable): string
611611

612612
if ($callable instanceof \Closure) {
613613
$r = new \ReflectionFunction($callable);
614-
if (str_contains($r->name, '{closure}')) {
614+
if (str_contains($r->name, '{closure')) {
615615
return 'Closure()';
616616
}
617617
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ private function getCallableDocument($callable): \DOMDocument
543543
$callableXML->setAttribute('type', 'closure');
544544

545545
$r = new \ReflectionFunction($callable);
546-
if (str_contains($r->name, '{closure}')) {
546+
if (str_contains($r->name, '{closure')) {
547547
return $dom;
548548
}
549549
$callableXML->setAttribute('name', $r->name);

src/Symfony/Bundle/SecurityBundle/Command/DebugFirewallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ private function formatCallable($callable): string
252252

253253
if ($callable instanceof \Closure) {
254254
$r = new \ReflectionFunction($callable);
255-
if (false !== strpos($r->name, '{closure}')) {
255+
if (str_contains($r->name, '{closure')) {
256256
return 'Closure()';
257257
}
258258
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {

src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function testCallErrorExceptionInfo()
171171
}
172172
$this->assertSame(__FILE__, $e->getFile());
173173
$this->assertSame(0, $e->getCode());
174-
$this->assertSame('Symfony\Component\ErrorHandler\{closure}', $trace[0]['function']);
174+
$this->assertStringMatchesFormat('%A{closure%A}', $trace[0]['function']);
175175
$this->assertSame(ErrorHandler::class, $trace[0]['class']);
176176
$this->assertSame('triggerNotice', $trace[1]['function']);
177177
$this->assertSame(__CLASS__, $trace[1]['class']);

src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct($listener, ?string $name, Stopwatch $stopwatch, ?Eve
4747
$this->pretty = $this->name.'::'.$listener[1];
4848
} elseif ($listener instanceof \Closure) {
4949
$r = new \ReflectionFunction($listener);
50-
if (str_contains($r->name, '{closure}')) {
50+
if (str_contains($r->name, '{closure')) {
5151
$this->pretty = $this->name = 'closure';
5252
} elseif ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
5353
$this->name = $class->name;

src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function createArgumentMetadata($controller): array
3333
$class = $reflection->class;
3434
} else {
3535
$reflection = new \ReflectionFunction($controller);
36-
if ($class = str_contains($reflection->name, '{closure}') ? null : (\PHP_VERSION_ID >= 80111 ? $reflection->getClosureCalledClass() : $reflection->getClosureScopeClass())) {
36+
if ($class = str_contains($reflection->name, '{closure') ? null : (\PHP_VERSION_ID >= 80111 ? $reflection->getClosureCalledClass() : $reflection->getClosureScopeClass())) {
3737
$class = $class->name;
3838
}
3939
}

src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ private function parseController($controller)
474474
'line' => $r->getStartLine(),
475475
];
476476

477-
if (str_contains($r->name, '{closure}')) {
477+
if (str_contains($r->name, '{closure')) {
478478
return $controller;
479479
}
480480
$controller['method'] = $r->name;

src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static function provideControllerCallables(): array
118118
'Closure',
119119
function () { return 'foo'; },
120120
[
121-
'class' => __NAMESPACE__.'\{closure}',
121+
'class' => \PHP_VERSION_ID >= 80400 ? sprintf('{closure:%s():%d}', __METHOD__, __LINE__ - 2) : __NAMESPACE__.'\{closure}',
122122
'method' => null,
123123
'file' => __FILE__,
124124
'line' => __LINE__ - 5,

0 commit comments

Comments
 (0)