Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

NoExport by-default

Đang mở
#151 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
compilers

Hướng nghiên cứu

Start from the export-table generation logic and the existing attribute handling (the issue links swoole.com/aot/en/docs/no-export for current behavior). Decide how #[ExportAs] with and without a name maps onto the export table, then locate where public PHP functions/methods are collected at build time so they become excluded by default. Done looks like: a small test project where an unannotated function is absent from the export table, an #[ExportAs] function appears under its chosen name, and name-conflict errors surface clearly. Note this is a breaking-change proposal still open for maintainer decision, so confirm intent before coding.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hi! First of all, thanks for such a cool project.

My suggestion is to disable all export of public PHP methods by default. The current behavior implies that a method is explicitly exported in the build unless specified otherwise: https://swoole.com/aot/en/docs/no-export

Instead, add the opposite attribute:

#[ExportAs] // "php_foo" (?) by defult
function foo(): void {}

#[ExportAs(name: 'exported_function_name')] // custom name
function foo(): void {}

Proposal Problems

    1. Changing behavior requires breaking BC
    • Counterargument: This is not critical in the current 0.x release
    • Counterargument: There have already been precedents of core's BC (behavior upon integer overflow).
    1. Name conflicts are possible (If user names are allowed).
    • Counterargument: The code's author writes this attributes, so they have control over this and can fix any name conflict errors.
    • Counterargument: In the case of conflicts with vendor code, an option could be added in the future to specify exactly which directories (or namespaces) should be considered when building the export table. For example:
      # project.yml
      export:
        - app/
        - vendor/some/any/  
      

Winnings

    1. A more aggressive DCE could be used in the future, removing unnecessary global functions, classes, and methods from the build.
    1. Allow inlining even of public functions if the compiler deems it necessary or unless otherwise specified.
    1. Security (?): If code is distributed as part of a solution (so/dll/dylib/etc.), external software will not be able to access the internal implementation directly, since the export table is explicitly defined by the developer.
Ngôn ngữ chính
PHP
Star
1.4k
Fork
80
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
26

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của swoole/typephp

Tất cả issue của swoole/typephp

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.