Deprecation errors are inconsistently triggered for underscore class aliases
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
Description
The following code:
<?php
namespace Foo {
class __ {}
}
namespace Bar {
class _ {} // Deprecated
}
namespace {
class __ {}
class_alias('Foo\__', 'Foo\_'); // Is this meant to be deprecated?
class_alias('__', '_'); // Deprecated
}
namespace Baz {
use Foo\_;
}
namespace Qux {
use Foo\__ as _; // Is this meant to be deprecated?
}
Resulted in this output:
Deprecated: Using "_" as a class name is deprecated since 8.4 in /in/ZZMJs on line 8
Deprecated: Using "_" as a class alias is deprecated since 8.4 in /in/ZZMJs on line 15
But I expected this output instead:
Deprecated: Using "_" as a class name is deprecated since 8.4 in /in/ZZMJs on line 8
Deprecated: Using "_" as a class alias is deprecated since 8.4 in /in/ZZMJs on line 14
Deprecated: Using "_" as a class alias is deprecated since 8.4 in /in/ZZMJs on line 15
Deprecated: Using "_" as a class alias is deprecated since 8.4 in /in/ZZMJs on line 23
I encountered this issue while trying to migrate a large closed source project to PHP 8.4. The namespaced _ class was used as a wrapper for the gettext _ function (eg new _("string")), to delay performing the translation of cached content until the http response is stringified. The class had ~35k instantiations in source control and more instances in compressed + serialized database records. This made class aliases a potentially appealing solution, but I understand from @Girgias that these not emitting deprecation errors is an oversight.
PHP Version
8.4.1 - 8.4.6 on 3v4l
Operating System
No response
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.
Hướng nghiên cứu
Bắt đầu bằng cách chạy bản tái hiện PHP 8.4 được cung cấp và so sánh hành vi deprecation đối với các khai báo lớp, các lệnh gọi class_alias() và namespaced use alias. Truy vết các đường đi của trình thông dịch xử lý bí danh lớp và việc import namespace, sau đó thêm phạm vi kiểm thử hồi quy cho thấy cả bốn trường hợp underscore được mong đợi đều phát ra deprecations.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- php
- Lĩnh vực
- backend
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100