Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Argument count error in PHPUnit test with data provider and depends attribute

Open
#286 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
testing-qa

Research direction

Start by reproducing the issue with the shown testSearch method, its Depends and DataProvider attributes, and providerSearchCases generator. Trace how the extension combines dependent-test arguments with data-provider arguments, then verify that the valid four-parameter method produces no arguments.count diagnostic. No repository file or existing test is named in the issue.

Written by the indexing model from the issue text.

Description

Bug report

hey there 👋

I think I found an issue within PHPUnit tests, using the Depends and DataProvider attribute on the same test method.

    public function testIndexing(): IdsCollection
    {
        $ids = new IdsCollection();
        // ...

        return $ids;
    }

    /**
     * @param list<string> $config
     * @param list<string> $expectedProducts
     */
    #[Depends('testIndexing')]
    #[DataProvider('providerSearchCases')]
    public function testSearch(array $config, string $term, array $expectedProducts, IdsCollection $ids): void
    {
        // ...
    }

    /**
     * @return \Generator<string, array{list<string>, string, list<string>}>
     */
    public static function providerSearchCases(): \Generator
    {
        yield 'search for manufacturer' => [
            ['name', 'description', 'customSearchKeywords', 'manufacturer.name'],
            'Shopware',
            ['product-4'],
        ];

        // and more
    }

error:

Method Shopware\TestClassName::testSearch() invoked with 3 parameters, 4 required.  
🪪  arguments.count   

Unfortunately I cannot provide a playground code snippet, as PHPUnit is not available there. I also don't know, if this is a problem of the PHPUnit extension.

Expected output

no error

Did PHPStan help you today? Did it make you happy in any way?

PHPStan helps me everyday to be the last stand against AI slop 😁

Dominant language
PHP
Stars
544
Forks
58
Avg merge
2d 1h
Merged PRs (30d)
5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from phpstan/phpstan-phpunit

All issues in phpstan/phpstan-phpunit

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.