psalm / psalm-plugin-wordpress

WordPress stubs and plugin for Psalm
MIT License
69 stars 18 forks source link

Uncaught ArgumentCountError: Too few arguments #39

Closed AlchemyUnited closed 9 months ago

AlchemyUnited commented 2 years ago

Uncaught ArgumentCountError: Too few arguments to function Psalm\Internal\PhpVisitor\Reflector\FunctionLikeDocblockParser::parse(), 1 passed in \vendor\humanmade\psalm-plugin-wordpress\Plugin.php on line 330 and exactly 3 expected in \vendor\vimeo\psalm\src\Psalm\Internal\PhpVisitor\Reflector\FunctionLikeDocblockParser.php:41

Line 330
$comments = Psalm\Internal\PhpVisitor\Reflector\FunctionLikeDocblockParser::parse( $this->last_doc );

Line 41

public static function parse(
        PhpParser\Comment\Doc $comment,
        CodeLocation $code_location,
        string $cased_function_id
    ): FunctionDocblockComment {

psalm --version returns: Psalm 4.26.0@6998fabb2bf528b65777bf9941920888d23c03ac

I'm new to Psalm and using it with WP. I'm not sure what else you need to know. Psalm runs fine if I remove

    <plugins>
        <pluginClass class="PsalmWordPress\Plugin"/>
    </plugins>

from my psalm.xml. But it natually then flags all the WP functions as errors :(

Perhaps I need to use a different version of Psalm and/or the humanmade WP plugin?

Again, this is all new to me so please type slowly if there are any instruction I need to follow :)

mcaskill commented 2 years ago

I'm having the same issue.

Introduced by vimeo/psalm#8056 (4.24.0).

Fixed in this plugin at c7300bc.

Until a new tag of this plugin is release, either:

Upgrade to development branch:

composer require --dev humanmade/psalm-plugin-wordpress:dev-master

Or downgrade:

composer require --dev vimeo/psalm:~4.23.0

Or add a conflict to composer.json:

"conflict": {
    "vimeo/psalm": ">=4.24.0"
}
AlchemyUnited commented 2 years ago

@mcaskill - Great. Thanks for letting me know.

kkmuffme commented 2 years ago

Please use the version of this plugin on "master" branch, then it also works with the latest psalm (v4) the release of this plugin is extremely outdated.

kkmuffme commented 9 months ago

Fixed in https://github.com/psalm/psalm-plugin-wordpress/pull/33