`allIsInstanceOf` does not work with generics
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- PHP
- Estrellas
- 185
- Forks
- 33
- Merge medio
- 20 h 40 min
- PR fusionados (30 d)
- 7
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de phpstan/phpstan-webmozart-assert
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 32/100
phpstan/phpstan-webmozart-assert#180 · 5 comentarios ·
-
False positive: Call to inArray() with different object instances will always evaluate to trueAbiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
phpstan/phpstan-webmozart-assert#142 · 17 comentarios ·
-
Support the new methods in 1.4Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
phpstan/phpstan-webmozart-assert#6 · 3 comentarios · 2 reacciones ·
Todos los issues de phpstan/phpstan-webmozart-assert
Issues similares
-
bug needs grooming
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
phpstan/phpstan-phpunit#361 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
HE-Arc/le-panier-du-coin#49 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 2 días
-
15.0
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100