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

Unexpected errors with `willReturn` called on `with`

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

还没有人认领这个 Issue。

评估

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

调研方向

Reproduce the reported diagnostic using the shown PHPUnit mock chain and the listed PHPStan and PHPUnit versions. Inspect the PHPStan PHPUnit extension's handling of with() and willReturn(); done means the chain no longer reports InvocationStubber::with() as undefined while unrelated invalid calls remain detectable.

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

描述

After upgrading to PHPStan 2.2.0 the willReturn on the with seems not longer be detected correctly:

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class RegisterPreviewWebspaceClassPassTest extends TestCase
{
    /** @var ContainerBuilder&MockObject */
    private $containerBuilderMock;

    public function testShouldNotOverrideWebspaceCacheClass(): void
    {
        $this->containerBuilderMock
            ->method('hasExtension')
            ->with('sulu_core')
            ->willReturn(false);
    }
  28     Call to an undefined method PHPUnit\Framework\MockObject\InvocationStubber::with().
         🪪  method.notFound

Packages which are installed related to PHPUnit:

phpspec/prophecy-phpunit                         2.5.0   Integrating the Prophecy mocking library in PHPUnit test cases
phpstan/phpstan-phpunit                          2.0.16  PHPUnit extensions and rules for PHPStan
phpunit/php-code-coverage                        14.1.9  Library that provides collection, processing, and rendering functionality for PHP code covera...
phpunit/php-file-iterator                        7.0.0   FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                              7.0.0   Invoke callables with a timeout
phpunit/php-text-template                        6.0.0   Simple template engine.
phpunit/php-timer                                9.0.0   Utility class for timing
phpunit/phpunit                                  13.1.13 The PHP Unit Testing framework.
symfony/phpunit-bridge                           7.4.8   Provides utilities for PHPUnit, especially user deprecation notices management
主要语言
PHP
星标
544
派生
58
平均合并
2 天 1 小时
30 天内合并 PR
5

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

phpstan/phpstan-phpunit 的其他 Issue

查看 phpstan/phpstan-phpunit 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

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