Skip to content

Commit adeb406

Browse files
Merge branch '5.0'
* 5.0: (24 commits) Removing unused variable Fixed #35084 Add missing use statement [HttpClient] fix scheduling pending NativeResponse do not overwrite variable value [Profiler] wording Use spaces correctly to display options in DebugCommand Add supported schemes doc blocks type X-Accel Nginx URL updated ticket-30197 [Validator] Add the missing translations for the Chinese (Taiwan) ("zh_TW") locale Fixed test added in #35022 Use locale_parse for computing fallback locales [Console] Fix filtering out identical alternatives when there is a command loader [String][UnicodeString] Remove unneeded flag in chunk regex pattern add note about HTTP status code change Migrate server:log command away from WebServerBundle [DependencyInjection][CheckTypeDeclarationsPass] Handle \Closure for callable [Security] Fix missing defaults for auto-migrating encoders bumped Symfony version to 5.0.3 updated VERSION for 5.0.2 ...
2 parents 0522ef1 + e5bb8da commit adeb406

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

Compiler/CheckTypeDeclarationsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private function checkType(Definition $checkedDefinition, $value, \ReflectionPar
166166
return;
167167
}
168168

169-
if ('callable' === $type && method_exists($class, '__invoke')) {
169+
if ('callable' === $type && (\Closure::class === $class || method_exists($class, '__invoke'))) {
170170
return;
171171
}
172172

Tests/Compiler/CheckTypeDeclarationsPassTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,4 +681,20 @@ public function testProcessSkipSkippedIds()
681681

682682
$this->addToAssertionCount(1);
683683
}
684+
685+
public function testProcessHandleClosureForCallable()
686+
{
687+
$closureDefinition = new Definition(\Closure::class);
688+
$closureDefinition->setFactory([\Closure::class, 'fromCallable']);
689+
$closureDefinition->setArguments(['strlen']);
690+
691+
$container = new ContainerBuilder();
692+
$container
693+
->register('foobar', BarMethodCall::class)
694+
->addMethodCall('setCallable', [$closureDefinition]);
695+
696+
(new CheckTypeDeclarationsPass(true))->process($container);
697+
698+
$this->addToAssertionCount(1);
699+
}
684700
}

Tests/Fixtures/CheckTypeDeclarationsPass/BarMethodCall.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ public function setArray(array $array)
3636
public function setIterable(iterable $iterable)
3737
{
3838
}
39+
40+
public function setCallable(callable $callable): void
41+
{
42+
}
3943
}

TypedReference.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class TypedReference extends Reference
2020
{
2121
private $type;
2222
private $name;
23-
private $requiringClass;
2423

2524
/**
2625
* @param string $id The service identifier

0 commit comments

Comments
 (0)