Make evaled code/tokens accessible
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
Code like:
<?php
namespace N;
class Cl {}
eval(<<<'EOF'
use N\Cl;
class U {
/**
* @return Cl
*/
public function test() { throw new \Exception(); }
}
EOF);
$u = new \U();
$refl = new \ReflectionMethod($u, 'test');
var_dump($refl->getFileName());
var_dump($refl->getDocComment());
has unusable phpdoc, as it relies on a use N\Cl; statement. The issue is phpdoc can be accessed by reflection - https://3v4l.org/djLIA - but the full evaled code is not accessible thus the use statements required to parse the phpdoc cannot be read.
At least I am unaware of any way to access the evaled code (or parsed tokens).
The ability to resolve phpdoc for classes from eval is important as annotations are used by many production libs (like Doctrine ORM) and also for static analysers.
This is a feature request to make the full evaled code accessible at least via new reflection ReflectionClass::getFileContents() method. If the parsed file tokens are already stored somewhere, providing a method to access the tokens instead of the file source code will be enough.
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 các entry point eval và ReflectionClass được mô tả trong issue, đồng thời điều tra xem interpreter có giữ lại source đã được eval hay các token đã được parse hay không. Công việc được xem là hoàn tất khi reflection cung cấp đủ code đã được eval để các phpdoc using statements có thể được phân giải, thông qua ReflectionClass::getFileContents() hoặc một token API tương đương.
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
- 35/100