CakeDC / cakephp-phpstan

CakePHP extension for PHPStan
Other
30 stars 5 forks source link

Command ConsoleIo::helper() issue #9

Closed dereuromark closed 2 years ago

dereuromark commented 2 years ago
  Line   FooBarCommand.php                                        
 ------ --------------------------------------------------------- 
  40     Call to an undefined method Cake\Console\Helper::foo().  
 ------ --------------------------------------------------------- 

According to https://github.com/CakeDC/cakephp-phpstan/blob/master/extension.neon#L69-L71 it should work however to autocomplete

    public function execute(Arguments $args, ConsoleIo $io)
    {
        $helper = $io->helper('BazBaz');
        $x = $helper->foo();

And helper

namespace App\Shell\Helper;

use Cake\Console\Helper;

class BazBazHelper extends Helper
{
    public function output(array $args): void
    {
    }

    public function foo(): string
    {
        return '';
    }
}

I added IDE part in https://github.com/dereuromark/cakephp-ide-helper/pull/265 and wanted to check if PHPStan issue is also solved, but seems not.

rochamarcelo commented 2 years ago

I see that you are using a command, that line is for shell class (https://github.com/CakeDC/cakephp-phpstan/blob/master/extension.neon#L69-L71) but we should support ConsoleIo class too.

dereuromark commented 2 years ago

Yeah, it should, thats why I was surprised it doesnt work

rochamarcelo commented 2 years ago

Closing issue pull request was sent https://github.com/CakeDC/cakephp-phpstan/pull/10 . Thank you.