NoExport by-default
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
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
-
- 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).
-
- 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
-
- A more aggressive DCE could be used in the future, removing unnecessary global functions, classes, and methods from the build.
-
- Allow inlining even of public functions if the compiler deems it necessary or unless otherwise specified.
-
- 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,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
swoole/typephp 的其他 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
Featured image not passed to checks in the Tasks column or publish blocks可能已有人在做 @roborourke 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
humanmade/publication-checklist#100 ·
维护者通常 1 天内回复
-
bug customer-reported
难度 2/5 1-3 小时 新手友好度 62/100
MagnaCapax/PMSS#1072 ·
维护者通常 5 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 62/100
hestiacp/hestiacp#5800 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 68/100
components-web-app/docs#244 ·