PHPStan includes phpstan/phpstan-phpunit, but it doesn't seem to recognize mocks.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 55/100
Direzione di ricerca
Start with vendor/phpstan/phpstan-phpunit/stubs/MockObject.stub and compare it with vendor/phpunit/phpunit/src/Framework/MockObject/Runtime/Interface/MockObject.php. Check how PHPStan uses the stub, then update the stub so the MockObject interface exposes the expects() method shown in the PHPUnit interface. Done means PHPStan recognizes expects() on PHPUnit mock objects.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
PHPStan includes phpstan/phpstan-phpunit, but it doesn't seem to recognize mocks.
- phpstan-phpunit 2.0.16 ships with a stub file, MockObject.stub, which contains an empty
MockObjectinterface without anexpects()method. - When PHPStan analyzes your code, it uses the stub file instead of the real PHPUnit interface.
- This causes PHPStan to not see the expects() method on mock objects.
This is a bug in phpstan-phpunit 2.0.16. The stub file, MockObject.stub, must contain a definition of theexpects()method.
Reason
Bug in phpstan/phpstan-phpunit version 2.0.16
The stub file /home/mihail/proj/task/vendor/phpstan/phpstan-phpunit/stubs/MockObject.stub contains an empty MockObject interface without an expects() method:
// vendor/phpstan/phpstan-phpunit/stubs/MockObject.stub
namespace PHPUnit\Framework\MockObject;
interface MockObject
{
// EMPTY - no expects() method!
}
However, the real MockObject interface in PHPUnit 11.x has an expects() method:
// vendor/phpunit/phpunit/src/Framework/MockObject/Runtime/Interface/MockObject.php
interface MockObject extends Stub
{
public function expects(InvocationOrder $invocationRule): InvocationMocker;
}
PHPStan uses the stub file instead of the real class, so it doesn't see the expects() method.
Solution
Correct the stub file in phpstan-phpunit. You need to add the expects() method to MockObject.stub.
- 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
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
phpstan/phpstan-phpunit#332 ·
-
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
-
sync-en
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
-
sync-en
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
-
Перевод устарел
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
-
priority: p3
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nextcloud/fulltextsearch#1011 ·