False positive: Call to static method Webmozart\Assert\Assert::allInArray() with array<string> and array<string> will always evaluate to true
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Start with the test.php reproduction and run the shown PHPStan command using phpstan.neon at level 4. Inspect the phpstan-webmozart-assert extension configuration and the discussion in issue 142; done means this example no longer reports staticMethod.alreadyNarrowedType while the assertion analysis remains correct.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The following code causes a false PHPStan error. The Assert::allInArray($enabledNames, $supportedNames); assertion certainly isn't always true.
use Webmozart\Assert\Assert;
class C
{
/**
* @param array<string> $supportedNames
* @param array<string> $enabledNames
*/
public function __construct(
array $supportedNames,
array $enabledNames,
)
{
Assert::allInArray($enabledNames, $supportedNames);
}
}
$ vendor/bin/phpstan analyse -c phpstan.neon test.php
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ --------------------------------------------------------------------------------------------------------------------------------
Line test.php
------ --------------------------------------------------------------------------------------------------------------------------------
17 Call to static method Webmozart\Assert\Assert::allInArray() with array<string> and array<string> will always evaluate to true.
🪪 staticMethod.alreadyNarrowedType
------ --------------------------------------------------------------------------------------------------------------------------------
[ERROR] Found 1 error
===============
$ vendor/bin/phpstan diagnose
Note: Using configuration file /Users/melka/work/rh/phpstan.neon.
PHP runtime version: 8.3.22
PHP version for analysis: 8.3.22 (from runtime)
PHPStan version: 2.1.29
PHPStan running from:
/Users/melka/work/rh/vendor/phpstan/phpstan
Extension installer: Not installed
Included configs from Composer packages:
phpstan/phpstan-webmozart-assert (extension.neon): 2.0.0
Discovered Composer project root:
/Users/melka/work/rh
===============
$ cat phpstan.neon
includes:
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
parameters:
level: 4 # lowest level where this starts happening
Also discussed in https://github.com/phpstan/phpstan-webmozart-assert/issues/142#issuecomment-3372330454
- Lingua principale
- PHP
- Stelle
- 185
- Fork
- 33
- Merge medio
- 20h 40m
- PR unite (30g)
- 7
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
- 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-webmozart-assert
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
phpstan/phpstan-webmozart-assert#187 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 32/100
phpstan/phpstan-webmozart-assert#180 · 5 commenti ·
-
False positive: Call to inArray() with different object instances will always evaluate to trueApertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
phpstan/phpstan-webmozart-assert#142 · 17 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
phpstan/phpstan-webmozart-assert#6 · 3 commenti · 2 reazioni ·
Tutte le issue di phpstan/phpstan-webmozart-assert
Issue simili
-
bug needs grooming
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
phpstan/phpstan-phpunit#361 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
HE-Arc/le-panier-du-coin#49 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 2 giorni
-
15.0
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100