phpstan-symfony icon indicating copy to clipboard operation
phpstan-symfony copied to clipboard

Command `getHelper` does not work

Open mitelg opened this issue 3 years ago • 6 comments

Hey there :wave:

I updated to version 1.1.2 and now I got the following error during the analysis:

Call to an undefined method Symfony\Component\Console\Helper\HelperInterface::ask()

We do not extend directly from Symfony\Component\Console\Command\Command but have an own AbstractCommand instead. could that be a reason? Otherwise I don't see a reason why a call like this, should not work: $this->getHelper('question')->ask()

Command where the error occurs: https://github.com/shopware/shopware/blob/5.7/engine/Shopware/Bundle/MediaBundle/Commands/MediaOptimizeCommand.php#L117 Abstract command: https://github.com/shopware/shopware/blob/5.7/engine/Shopware/Commands/ShopwareCommand.php

thanks in advance and have a nice day :slightly_smiling_face: :wave:

mitelg avatar Jan 24 '22 10:01 mitelg

/cc @lookyman who is the author of https://github.com/phpstan/phpstan-symfony/pull/229

ondrejmirtes avatar Jan 24 '22 10:01 ondrejmirtes

Are you using https://github.com/phpstan/phpstan-symfony#analysis-of-symfony-console-commands?

lookyman avatar Jan 24 '22 12:01 lookyman

sure :slightly_smiling_face:

but we also have our own console application class, which extends from the Symfony base application. I do not know, if that matters :grin:

https://github.com/shopware/shopware/blob/5.7/engine/Shopware/Components/Console/Application.php

mitelg avatar Jan 24 '22 12:01 mitelg

I confirm, we also get Call to an undefined method Symfony\Component\Console\Helper\HelperInterface::ask(). with such usage:

$helper = $this->getHelper('question');
$helper->ask($input, $output, $question);

FYI: We don't use consoleApplicationLoader because we have many CLI entrypoints, each has own commands. But for helpers it shouldn't make any difference, since it's for $input methods, right?

Wirone avatar Feb 07 '22 16:02 Wirone

I haven't had a chance to look at this yet. It would be much appreciated if you guys could try to debug it, and maybe send a PR. If not, I will try to find some time later this week. Thanks for understanding.

lookyman avatar Feb 07 '22 20:02 lookyman

just wanted to make sure, this is not forgotten :see_no_evil:

mitelg avatar Mar 23 '23 09:03 mitelg