Skip to content
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

TooManyArguments was triggered if the variadic function declared in vendor folder #3313

Closed
mrpavlikov opened this issue May 7, 2020 · 3 comments
Labels

Comments

@mrpavlikov
Copy link

I've found #2580, but bug seems to be still there. Here is a repo with example to reproduce problem: https://github.com/mrpavlikov/psalm-variadic

$ git pull git@github.com:mrpavlikov/psalm-variadic.git
$ composer install
$ ./vendor/bin/psalm

Here's what I get:

ERROR: TooManyArguments - src/Test.php:9:18 - Too many arguments for Google_Service_Sheets_ValueRange::__construct - expecting 0 but saw 1 (see https://psalm.dev/026)
        $range = new \Google_Service_Sheets_ValueRange([]);

but constructor is variadic:

class Google_Model implements ArrayAccess
{
  final public function __construct()
  {
    if (func_num_args() == 1 && is_array(func_get_arg(0))) {
      // Initialize the model with the array's contents.
      $array = func_get_arg(0);
      $this->mapTypes($array);
    }
    $this->gapiInit();
  }
@vimeo vimeo deleted a comment from psalm-github-bot bot May 7, 2020
@muglug muglug added the bug label May 7, 2020
@muglug muglug closed this as completed in 4295f95 May 7, 2020
@muglug
Copy link
Collaborator

muglug commented May 7, 2020

I've fixed with a very specific check for this pattern which is out of your control but should only be found in this very legacy code.

@mrpavlikov
Copy link
Author

Thanks a bunch!

@orklah
Copy link
Collaborator

orklah commented May 8, 2020

Cool! I had some of those cases too. It's actually quite common in projects migrated from version of php that started without variadics

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

No branches or pull requests

3 participants