Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Do not create and pass a service if it's nullable in the method argument

Abierto
#9,909 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php
Área
backend, devtools

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

bug

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:

Image

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

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rectorphp/rector

Todos los issues de rectorphp/rector

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.