False InvalidArgument for named dataset keys (PHPUnit 11+)

Open
#177 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@alies-dev is already working on this.

Since Nov 9, 2026.

  • #213 by @alies-dev — open

Assessment

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

Research direction

Read TestCaseHandler::afterStatementAnalysis() and the argument checks it performs, then inspect the named dataset handling and test fixture in phpstan-phpunit’s DataProviderDataRule for reference. Add coverage for named keys, unknown parameter names, positional datasets, and PHPUnit 10 compatibility. Done when the plugin reports valid PHPUnit 11 named datasets correctly and the tests pass; a linked pull request is already open.

Written by the indexing model from the issue text.

Description

bug

Since PHPUnit 11, string keys in a dataset are passed as named arguments. The plugin matches dataset entries to parameters by position, so a valid provider is reported:

/** @return iterable<array{currency: string, cents: int}> */
public static function prices(): iterable
{
    yield ['currency' => 'EUR', 'cents' => 100];
}

#[DataProvider('prices')]
public function testPrice(int $cents, string $currency): void {} // two InvalidArgument reports

phpstan-phpunit handles named entries (DataProviderDataRule, see its data-provider-data-named test fixture).

Idea: in the argument checks of TestCaseHandler::afterStatementAnalysis(), match string keys of a TKeyedArray dataset to parameter names (and report unknown names), falling back to positional matching for list-shaped datasets. It should take the PHPUnit version into account while PHPUnit 10 is supported. Roughly 50 lines with tests.

Idea borrowed from phpstan/phpstan-phpunit.

Dominant language
Gherkin
Stars
79
Forks
38
Avg merge
6h 52m
Merged PRs (30d)
28

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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 psalm/psalm-plugin-phpunit

All issues in psalm/psalm-plugin-phpunit

Similar issues

More Testing & QA issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.