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 52ad6de

Browse filesBrowse files
committed
Fallback to default helper set when no application loader is provided
1 parent d6ea162 commit 52ad6de
Copy full SHA for 52ad6de

File tree

Expand file treeCollapse file tree

1 file changed

+13
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-1
lines changed

‎src/Type/Symfony/CommandGetHelperDynamicReturnTypeExtension.php

Copy file name to clipboardExpand all lines: src/Type/Symfony/CommandGetHelperDynamicReturnTypeExtension.php
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use PHPStan\Type\Type;
1212
use PHPStan\Type\TypeCombinator;
1313
use PHPStan\Type\TypeUtils;
14+
use Symfony\Component\Console\Application;
1415
use Throwable;
1516
use function count;
1617
use function get_class;
@@ -55,8 +56,19 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
5556
}
5657
$argName = $argStrings[0]->getValue();
5758

59+
$commands = $this->consoleApplicationResolver->findCommands($classReflection);
60+
if (count($commands) === 0) {
61+
$consoleApplication = new Application();
62+
63+
if ($consoleApplication->getHelperSet()->has($argName) === false) {
64+
return $defaultReturnType;
65+
}
66+
67+
return new ObjectType(get_class($consoleApplication->getHelperSet()->get($argName)));
68+
}
69+
5870
$returnTypes = [];
59-
foreach ($this->consoleApplicationResolver->findCommands($classReflection) as $command) {
71+
foreach ($commands as $command) {
6072
try {
6173
$command->mergeApplicationDefinition();
6274
$returnTypes[] = new ObjectType(get_class($command->getHelper($argName)));

0 commit comments

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