Skip to content

Incorrect behavior of DecorateWillReturnMapWithExpectsMockRector #9634

@mvhirsch

Description

@mvhirsch

Bug Report

Subject Details
Rector version 2.3.6
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/9db2158f-daff-4c24-af4c-0a7ece60f49a

<?php

use \PHPUnit\Framework\MockObject\Stub;

interface SomeInterface
{
    public function execute(): string;
}

final class FoobarTest extends \PHPUnit\Framework\TestCase
{
    private SomeInterface&Stub $service;
    
    protected function setUp() {
        $this->service = $this->createStub(SomeInterface::class);
    }
    
    public function run(bool $param)
    {
        $this->service->method('execute')->willReturnMap(['asdf', 'adsfasdf']);
        
        $this->service->execute(); // simulate test
    }
}

Responsible rules

  • DecorateWillReturnMapWithExpectsMockRector

Expected Behavior

No code change, as Stub does not implement expects method (only MockObject does).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions