Codeception / Codeception/AspectMock
Error when mocking built-in function with pass-by-reference argument and argument with default value (PHP 8)
- 主要语言
- PHP
- 星标
- 784
- 派生
- 132
- PR 合并指标
- 30 天内没有已合并 PR
描述
This is for AspectMock 4.1.1.
During our migration from PHP 7.4 to PHP 8.1, we've encountered this pattern a few times:
When our PHP-Unit tests mock a PHP built-in function that has at least one argument passed by reference and one argument with a default value, the mock fails with the error `ParseError: syntax error, unexpected token "=", expecting ")"`.
The stack track looks like this:
```
/tmp/flockoipmSG:4
/petabox/www/common/vendor/codeception/aspect-mock/src/AspectMock/Core/Mocker.php:275
/petabox/www/common/vendor/codeception/aspect-mock/src/AspectMock/Core/Registry.php:38
/petabox/www/common/vendor/codeception/aspect-mock/src/AspectMock/Test.php:248
```
Examining the temporary file reveals the problem:
```
$ cat /tmp/flockoipmSG
贡献指南
这个仓库没有索引到贡献指南
调研方向
从 AspectMock/Core/Mocker.php:275 开始,跟踪内置函数签名如何转换为临时 wrapper;Registry.php:38 和 Test.php:248 展示了周围的调用路径。使用 flock、system、stream_socket_client 或 stream_select 在 PHP 8.1 中重现,然后验证生成的声明能够在没有重复默认值的情况下通过解析,并且 mock 的调用仍然有效。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- testing-qa
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100