`allIsInstanceOf` does not work with generics
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 25/100
Piste de recherche
Start by reproducing the provided generic PHP example and inspect how Assert::allIsInstanceOf handles the class-string argument. The issue names no files or tests, so locate the extension's handling of this assertion before changing anything. Done means determining whether the list can be inferred as list rather than list.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
I noticed an interesting behavior in this extension.
With the following code:
class AssertReturn {
/**
* @template TClass of object
* @param class-string<TClass> $class
*
* @throws InvalidArgumentException
* @return list<TClass>
*/
public static function allInstancesOf(mixed $list, string $class) : array
{
Assert::isList($list);
dumpType($list); // Dumped type: list<mixed>
Assert::allIsInstanceOf($list, $class);
dumpType($list); // Dumped type: list<object>
return $list;
}
}
This is not what I was expecting or hoping for.
When using the Debugger I notice this:
So it's related to the fact that I use generics to pass the TClass.
What's the best way to deal to mitigate this problem, if it's possible.
- Langage dominant
- PHP
- Étoiles
- 185
- Forks
- 33
- Merge moyen
- 20 h 40 min
- PR mergées (30 j)
- 7
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de phpstan/phpstan-webmozart-assert
-
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 32/100
phpstan/phpstan-webmozart-assert#180 · 5 commentaires ·
-
False positive: Call to inArray() with different object instances will always evaluate to trueOuvertebug
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
phpstan/phpstan-webmozart-assert#142 · 17 commentaires ·
-
Support the new methods in 1.4Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 38/100
phpstan/phpstan-webmozart-assert#6 · 3 commentaires · 2 réactions ·
Toutes les issues de phpstan/phpstan-webmozart-assert
Issues similaires
-
bug needs grooming
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 63/100
phpstan/phpstan-phpunit#361 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
HE-Arc/le-panier-du-coin#49 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 2 jours
-
15.0
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100