Skip to content

Incorrect behavior of PreferPHPUnitSelfCallRector, PreferPHPUnitThisCallRector #9138

@andrew-demb

Description

@andrew-demb

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/442c80c1-aae0-4ee6-aacb-c3dec50e5db4

<?php

// PreferPHPUnitSelfCallRector
final class DemoFile extends \PHPUnit\Framework\TestCase
{
    public function testSuccess(): void
    {
        $mock = $this->createMock(\stdClass::class);
        
        $this->assertTrue(true);
    }
}

Responsible rules

  • PreferPHPUnitSelfCallRector

  • PreferPHPUnitThisCallRector

Expected Behavior

Rector should change to use self only static methods, not all of them.

createMock method is not static

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions