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

Non-existent functions can't be mocked since 2.1.0

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

@tw-360vier 已经在做这个了。

开始于 2021年7月7日。

  • #1 来自 @tw-360vier —— 已关闭,未合并
  • #194 来自 @tw-360vier —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
php
领域
testing

调研方向

从 placeOptionalAndReferenceFunction 方法和所引用的 pull request diff 开始,重点关注其对 ReflectionFunction 的调用。确认对于不存在的函数的行为,然后验证对这样的函数进行 mocking 不再引发 ReflectionException。

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

描述

The problem was introduced here:
https://github.com/Codeception/AspectMock/pull/133/files#diff-50b2697c4aa86740dcae323b3d7ebe44R44

The placeOptionalAndReferenceFunction method uses ReflectionFunction which throws an exception if a non-existent function name is passed:

[ReflectionException] Function somefunc() does not exist

Before that change it worked fine when trying to mock a non-existent function. This is a valid use case for a plugin architecture where you may not have desired functions in a test environment.

Can it be like this, for example:

if (function_exists($function)) {
    $this->placeOptionalAndReferenceFunction($namespace, $function);
}
主要语言
PHP
星标
785
派生
132
PR 合并指标
30 天内没有已合并 PR

环境准备

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

从这里开始

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

Codeception/AspectMock 的其他 Issue

查看 Codeception/AspectMock 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

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