Do not create and pass a service if it's nullable in the method argument
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
The issue is in the Entropy dependency injection container's service creation logic. Look at the ServiceMapProvider constructor in Rector\Symfony\DataProvider\ServiceMapProvider. The bug is that a service is being instantiated and passed when the argument is nullable and defaulted to null. Find where services are instantiated in the container code, likely in a service factory or resolver. Check how constructor arguments are resolved, particularly for nullable parameters. The fix is to pass null when the argument is nullable and no concrete service is bound, matching the illuminate/container behavior. Run existing tests related to dependency injection to verify the change.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Entropy should not create a service and pass it if the constructor definition is nullable like here:
\Rector\Symfony\DataProvider\ServiceMapProvider:
public function __construct(ServiceMapFactory $serviceMapFactory, ?ServiceMap $serviceMap = null)
{
$this->serviceMapFactory = $serviceMapFactory;
$this->serviceMap = null;
}
I expect a ServiceMapFactory and null as serviceMap.
This is the behavior with illuminate/container and Rector 2.6.3:
Before using Entropy in Rector the DI container from illuminate/container was used and since this commit https://github.com/rectorphp/rector-src/commit/cd3ec48e1209436d03d9c67d47c51ac4972a20cc the behavior is different because illuminate/container passed null as seen in the screenshot.
- Lenguaje dominante
- PHP
- Estrellas
- 10.4k
- Forks
- 742
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
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 rectorphp/rector
-
FileCacheStorage uses copy() instead of rename(), corrupting cache files on parallel cold-cache runs Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
withImportNames() reports a change on a short name already imported next to a same-short-name alias Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
Todos los issues de rectorphp/rector
Issues similares
-
sync-en
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
sync-en
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
Перевод устарел
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
az-digital/az_quickstart#6047 ·
-
Error when saving email Abiertobug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100