Do not create and pass a service if it's nullable in the method argument
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- PHP
- 星标
- 10.4k
- 派生
- 742
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rectorphp/rector 的其他 Issue
-
bug
难度 3/5 1-2 天 新手友好度 68/100
-
withImportNames() reports a change on a short name already imported next to a same-short-name alias可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 3/5 1-2 天 新手友好度 65/100
相似的 Issue
-
sync-en
难度 1/5 1 小时以内 新手友好度 83/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
nextcloud/integration_openai#446 ·
-
bug customer-reported
难度 2/5 1-3 小时 新手友好度 76/100
MagnaCapax/PMSS#1101 ·
维护者通常 5 天内回复
-
Installation / Upgrade Platform: Docker
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复