[Feature request] Report willReturn values incompatible with method signature
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- php
- Ambito
- devtools, testing-qa
Direzione di ricerca
Start with the PHP example using createMock(), method('foo'), and willReturn(123), then trace the existing PHPStan PHPUnit rules that inspect mock configurations. Confirm how the declared string return type and the configured int value should be compared; done means PHPStan reports the incompatible willReturn value with an actionable diagnostic.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Given
class MyClass
{
public function foo(): string {}
}
class MyOtherClassTest extends \PHPUnit\Framework\TestCase
{
public function testFooMock()
{
$class = $this->createMock(MyClass::class);
$class
->expects(static::once())
->method('foo')
->willReturn(123)
;
}
}
PHPUnit reports:
PHPUnit 8.2.0 by Sebastian Bergmann and contributors.
W 1 / 1 (100%)
Time: 173 ms, Memory: 16.00 MB
There was 1 warning:
1) MyOtherClassTest::testFooMock
Method foo may not return value of type int
WARNINGS!
Tests: 1, Assertions: 0, Warnings: 1.
It would be awesome if PHPStan could report this errors too.
- Lingua principale
- PHP
- Stelle
- 544
- Fork
- 58
- Merge medio
- 2g 1h
- PR unite (30g)
- 5
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di phpstan/phpstan-phpunit
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
phpstan/phpstan-phpunit#332 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
phpstan/phpstan-phpunit#321 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
phpstan/phpstan-phpunit#309 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
phpstan/phpstan-phpunit#299 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
phpstan/phpstan-phpunit#292 · 3 commenti ·
Tutte le issue di phpstan/phpstan-phpunit
Issue simili
-
Admissions heading updates Apertaa11y admissions.uiowa.edu needs grooming SiteImprove best practice
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Save States Menu Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
pluginsGLPI/datainjection#673 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
octobercms/october#6130 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
getgrav/grav-plugin-form#656 ·