Skip to content

Update getArgument return type in interact method #391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2024

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented May 20, 2024

Solve #256 (cc @alexander-schranz)

By design, all the arguments can be null in Command::interact method.
Doing

/** @var string|null $market */
$market = $input->getArgument('market');

in the interact method is reported as an error by PHPStan so there is currently no satisfying solution except ignoring the error. And updating the dynamic return type extension seems doable.

@@ -76,6 +77,11 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
}
}

$method = $scope->getFunction();
if ($method instanceof MethodReflection && $method->getName() === 'interact') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also check the declaring class of the method. You might not be in a console command at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new check 1dfe119

I'm not sure if there is a more optimised method for this.

@ondrejmirtes ondrejmirtes merged commit af6ae0f into phpstan:1.4.x May 30, 2024
31 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants