Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

NoExport by-default

未关闭
#151 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
php
领域
compilers

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
PHP
星标
1.4k
派生
81
平均合并
1 天 1 小时
30 天内合并 PR
25

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

swoole/typephp 的其他 Issue

查看 swoole/typephp 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。