Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3418e7b

Browse filesBrowse files
minor symfony#53322 Leverage ReflectionFunction::isAnonymous() (nicolas-grekas)
This PR was merged into the 7.1 branch. Discussion ---------- Leverage ReflectionFunction::isAnonymous() | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Introduced in PHP 8.2 Commits ------- 1d26010 Leverage ReflectionFunction::isAnonymous()
2 parents 6dfa363 + 1d26010 commit 3418e7b
Copy full SHA for 3418e7b

File tree

Expand file treeCollapse file tree

14 files changed

+14
-14
lines changed
Filter options
Expand file treeCollapse file tree

14 files changed

+14
-14
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ private function getCallableData(mixed $callable): array
393393
$data['type'] = 'closure';
394394

395395
$r = new \ReflectionFunction($callable);
396-
if (str_contains($r->name, '{closure}')) {
396+
if ($r->isAnonymous()) {
397397
return $data;
398398
}
399399
$data['name'] = $r->name;

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ protected function describeCallable(mixed $callable, array $options = []): void
403403
$string .= "\n- Type: `closure`";
404404

405405
$r = new \ReflectionFunction($callable);
406-
if (str_contains($r->name, '{closure}')) {
406+
if ($r->isAnonymous()) {
407407
$this->write($string."\n");
408408

409409
return;

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ private function formatCallable(mixed $callable): string
649649

650650
if ($callable instanceof \Closure) {
651651
$r = new \ReflectionFunction($callable);
652-
if (str_contains($r->name, '{closure}')) {
652+
if ($r->isAnonymous()) {
653653
return 'Closure()';
654654
}
655655
if ($class = $r->getClosureCalledClass()) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ private function getCallableDocument(mixed $callable): \DOMDocument
581581
$callableXML->setAttribute('type', 'closure');
582582

583583
$r = new \ReflectionFunction($callable);
584-
if (str_contains($r->name, '{closure}')) {
584+
if ($r->isAnonymous()) {
585585
return $dom;
586586
}
587587
$callableXML->setAttribute('name', $r->name);

‎src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function loadRoutes(LoaderInterface $loader): RouteCollection
214214

215215
if (\is_array($controller) && [0, 1] === array_keys($controller) && $this === $controller[0]) {
216216
$route->setDefault('_controller', ['kernel', $controller[1]]);
217-
} elseif ($controller instanceof \Closure && $this === ($r = new \ReflectionFunction($controller))->getClosureThis() && !str_contains($r->name, '{closure}')) {
217+
} elseif ($controller instanceof \Closure && $this === ($r = new \ReflectionFunction($controller))->getClosureThis() && !$r->isAnonymous()) {
218218
$route->setDefault('_controller', ['kernel', $r->name]);
219219
}
220220
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Command/DebugFirewallCommand.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private function formatCallable(mixed $callable): string
238238

239239
if ($callable instanceof \Closure) {
240240
$r = new \ReflectionFunction($callable);
241-
if (str_contains($r->name, '{closure}')) {
241+
if ($r->isAnonymous()) {
242242
return 'Closure()';
243243
}
244244
if ($class = $r->getClosureCalledClass()) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(callable|array $listener, ?string $name, Stopwatch $
4848
$this->callableRef .= '::'.$listener[1];
4949
} elseif ($listener instanceof \Closure) {
5050
$r = new \ReflectionFunction($listener);
51-
if (str_contains($r->name, '{closure}')) {
51+
if ($r->isAnonymous()) {
5252
$this->pretty = $this->name = 'closure';
5353
} elseif ($class = $r->getClosureCalledClass()) {
5454
$this->name = $class->name;

‎src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private function checkController(Request $request, callable $controller): callab
240240
$r = new \ReflectionFunction($controller);
241241
$name = $r->name;
242242

243-
if (str_contains($name, '{closure}')) {
243+
if ($r->isAnonymous()) {
244244
$name = $class = \Closure::class;
245245
} elseif ($class = $r->getClosureCalledClass()) {
246246
$class = $class->name;

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ private function parseController(array|object|string|null $controller): array|st
469469
'line' => $r->getStartLine(),
470470
];
471471

472-
if (str_contains($r->name, '{closure}')) {
472+
if ($r->isAnonymous()) {
473473
return $controller;
474474
}
475475
$controller['method'] = $r->name;

‎src/Symfony/Component/HttpKernel/Event/ControllerEvent.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Event/ControllerEvent.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function getAttributes(string $className = null): array
9898
} elseif (\is_string($this->controller) && false !== $i = strpos($this->controller, '::')) {
9999
$class = new \ReflectionClass(substr($this->controller, 0, $i));
100100
} else {
101-
$class = str_contains($this->controllerReflector->name, '{closure}') ? null : $this->controllerReflector->getClosureCalledClass();
101+
$class = $this->controllerReflector instanceof \ReflectionFunction && $this->controllerReflector->isAnonymous() ? null : $this->controllerReflector->getClosureCalledClass();
102102
}
103103
$this->attributes = [];
104104

‎src/Symfony/Component/Messenger/Handler/HandlerDescriptor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Handler/HandlerDescriptor.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(callable $handler, array $options = [])
3232

3333
$r = new \ReflectionFunction($handler);
3434

35-
if (str_contains($r->name, '{closure}')) {
35+
if ($r->isAnonymous()) {
3636
$this->name = 'Closure';
3737
} elseif (!$handler = $r->getClosureThis()) {
3838
$class = $r->getClosureCalledClass();

‎src/Symfony/Component/String/LazyString.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/String/LazyString.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private static function getPrettyName(callable $callback): string
129129
} elseif ($callback instanceof \Closure) {
130130
$r = new \ReflectionFunction($callback);
131131

132-
if (str_contains($r->name, '{closure}') || !$class = $r->getClosureCalledClass()) {
132+
if ($r->isAnonymous() || !$class = $r->getClosureCalledClass()) {
133133
return $r->name;
134134
}
135135

‎src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function castClosure(\Closure $c, array $a, Stub $stub, bool $isNe
4242

4343
$a = static::castFunctionAbstract($c, $a, $stub, $isNested, $filter);
4444

45-
if (!str_contains($c->name, '{closure}')) {
45+
if (!$c->isAnonymous()) {
4646
$stub->class = isset($a[$prefix.'class']) ? $a[$prefix.'class']->value.'::'.$c->name : $c->name;
4747
unset($a[$prefix.'class']);
4848
}

‎src/Symfony/Component/Workflow/DataCollector/WorkflowDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/DataCollector/WorkflowDataCollector.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private function summarizeListener(callable $callable, string $eventName = null,
171171

172172
if ($callable instanceof \Closure) {
173173
$r = new \ReflectionFunction($callable);
174-
if (str_contains($r->name, '{closure}')) {
174+
if ($r->isAnonymous()) {
175175
$title = (string) $r;
176176
} elseif ($class = $r->getClosureCalledClass()) {
177177
$title = $class->name.'::'.$r->name.'()';

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.