Abstract properties (hooks) in traits
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 15 giờ
- Pull request đã merge (30 ngày)
- 103
Mô tả
Description
At the moment such code does not work (8.4 and 8.5/master), which does not seem very logical:
<?php
trait Example
{
abstract public string $property {
get;
}
}
class ExampleImpl
{
use Example;
public function __construct(
public readonly string $property,
) {}
}
Produces:
Fatal error: ExampleImpl and Example define the same hooked property ($property) in the composition of ExampleImpl. Conflict resolution between hooked properties is currently not supported. Class was composed
According to RFC (https://wiki.php.net/rfc/property-hooks#interaction_with_traits), traits do not actually support properties, but at least such primitive conflict resolution would be nice to have.
P.S. Is it worth writing to internals for RFC if there is no way to send a PR?
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 với reproducer được cung cấp cho trait và hooked property, sau đó đọc phần trong property-hooks RFC về tương tác giữa các trait. Theo dõi cách việc composition của trait xử lý abstract hooked property và implementing constructor-promoted property. Công việc được hoàn tất khi ví dụ có thể được compose mà không gặp conflict đã báo cáo, đồng thời vẫn giữ nguyên hành vi property-hook dự kiến.
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
- compilers
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- 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
- 30/100