Do not create and pass a service if it's nullable in the method argument
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- PHP
- Stelle
- 10.4k
- Fork
- 742
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
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 rectorphp/rector
-
FileCacheStorage uses copy() instead of rename(), corrupting cache files on parallel cold-cache runsApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
withImportNames() reports a change on a short name already imported next to a same-short-name aliasAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
Tutte le issue di rectorphp/rector
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
521xueweihan/HelloGitHub#3790 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
benjaminkott/bootstrap_package#1670 ·
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni