韩天峰
ea02ec096f
feat(compiler): add constant expression validation and runtime attribute factories
...
- Implement ConstantExpressionValidationVisitor and ConstantExpressionValidator
- Add validation for attribute arguments, class constants, property defaults
- Support runtime factories for dynamic expressions in PHP 8.5
- Enable new expressions, object casts, closures in attribute contexts
- Add proper scope handling for attribute factory functions
- Integrate validation into preprocessing and stub generation pipeline
- Add comprehensive tests for valid and invalid constant expressions
- Update compiler base to handle attribute factory scope correctly
- Remove old unsupported attribute argument validation logic
1 month ago
韩天峰
8ac4c5872d
refactor(core): rename PhpAot namespace to TypePhp across codebase
...
- Updated namespace declarations from PhpAot\Php to TypePhp in all source files
- Modified import statements to use TypePhp instead of PhpAot\Php throughout the codebase
- Adjusted composer.json autoload configuration to map TypePhp namespace to src directories
- Updated documentation references from PhpAot\Php to TypePhp in comments and markdown files
- Changed class references in test files to use new TypePhp namespace
- Updated bootstrap and utility scripts to reference TypePhp namespace
- Removed abstract base class inheritance in CompilerBase class
- Added new properties and methods for indentation and mode handling in CompilerBase
- Updated exception handling to use new TypePhp\Exception namespace
2 months ago
韩天峰
6e5b186c91
refactor(php): 重构PHP解析器的表达式处理和动态属性访问
...
- 将parseExpr替换为parseExprAsValue方法,统一处理void表达式转换为null
- 移除多处trimBrackets调用,简化表达式解析流程
- 添加emitDynamicPropertyFetchRead/Write/Unset等统一动态属性访问方法
- 重构PropertyWriteTarget类,将objectExpr和propertyExpr设为私有并添加getter方法
- 合并动态属性访问的目标路径和传统回退路径
- 修改测试框架中的exec方法为compile方法,更新相关测试用例
- 移除void表达式相关的错误检查,在运行时将其转换为null值
- 优化类型转换表达式的括号处理,移除不必要的trimBrackets调用
- 统一动态属性读取、写入、引用和取消设置的操作方法
2 months ago
韩天峰
5d150a2b02
refactor(php): 优化变量赋值类型检查逻辑
...
- 移除数组类型重分配检查的特殊处理
- 添加全局翻译器变量用于测试环境
- 引入通用变量赋值表达式检查方法
- 改进错误消息中的变量名显示格式
- 统一变量类型转换错误处理流程
3 months ago
韩天峰
e5b7955fa1
refactor(translator): 重构PHP到C++编译器的文件处理逻辑
...
- 将prepare方法重命名为prepareFile,convert方法重命名为convertFile
- 添加ignore路径配置支持,可在项目配置中忽略特定文件或目录
- 重构编译器主流程,将文件扫描、预处理和转换分离为独立步骤
- 移除不必要的异常类引用,优化代码结构
- 添加文件过滤功能,支持在预处理阶段跳过无效文件
- 修复预处理器中的默认情况处理逻辑,统一错误处理方式
4 months ago
韩天峰
a1c922dac2
feat(compiler): 添加变量重新赋值类型检查功能
...
- 实现了对变量重新赋值时的类型验证逻辑
- 当变量从一种类型重新赋值为另一种类型时抛出致命错误
- 添加了测试基类用于编译器测试
- 新增变量重新赋值的单元测试用例
- 在代码差异中检测到变量类型变化时触发错误处理
5 months ago
韩天峰
e508b6de4f
refactor(php): 重构编译器内部函数和类管理机制
...
- 移除 CompilerTest 单例模式,改为 create 方法创建实例
- 将 nativeFunctions 重命名为 functions 并统一使用 addFunction/hasFunction/getFunction 方法管理
- 将 nativeConstants 重命名为 constants 并统一使用相应方法管理
- 将 nativeClasses 相关方法重构为 getClass/hasClass 等统一命名方式
- 添加 ConstantDef 实体类用于常量定义管理
- 优化函数查找逻辑,使用 escapeFunction 进行名称转换
- 重构预处理器中的函数注册逻辑
- 更新模板文件中的变量引用以匹配新的属性命名
- 添加重复函数、类的测试用例并移除旧的错误测试文件
5 months ago
韩天峰
76c1104234
feat(compiler): 添加测试模式和静态变量重复检测功能
...
- 引入 CompilerTest 类用于测试模式运行
- 在 CompilerBase 中添加 forTest 标志和 TestError 异常
- 实现静态变量重复定义的检测和报错功能
- 添加 phpunit 配置文件和引导文件
- 创建重复静态变量的测试用例
- 添加基本静态变量功能的测试文件
- 修改 Translator 的 addFiles 方法支持文件列表添加
- convert 方法中添加文件路径解析功能
5 months ago