Do not create and pass a service if it's nullable in the method argument
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- PHP
- Star
- 10.4k
- Fork
- 742
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rectorphp/rector
-
feature
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
-
withImportNames() reports a change on a short name already imported next to a same-short-name aliasĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
Tất cả issue của rectorphp/rector
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Yoast/wordpress-seo#23658 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
fixed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
firefly-iii/firefly-iii#12934 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày