False InvalidArgument for named dataset keys (PHPUnit 11+)

Aperta
#177 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@alies-dev ci sta già lavorando.

Dal 9/11/2026.

  • #213 di @alies-dev — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
php
Ambito
testing

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Gherkin
Stelle
79
Fork
38
Merge medio
6h 52m
PR unite (30g)
28

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di psalm/psalm-plugin-phpunit

Tutte le issue di psalm/psalm-plugin-phpunit

Issue simili

Altre issue su Testing & QA

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.