rectorphp / rector-phpunit

Rector upgrade rules for PHPUnit
http://getrector.com
MIT License
62 stars 47 forks source link

[PreferPHPUnitThisCallRector] Skip current and child funct fixes #8008 #195

Closed JohJohan closed 1 year ago

JohJohan commented 1 year ago

This should fix: https://github.com/rectorphp/rector-phpunit/pull/194#discussion_r1234849677

I removed:

if (! $this->isObjectType($node->class, new ObjectType('PHPUnit\Framework\TestCase'))) {
    return null;
}

Because we already check if we are in test case on line 73 if (! $this->testsNodeAnalyzer->isInTestClass($node)) { and i thought it was unnecessary to do this extra check. And i got

src/Rector/Class_/PreferPHPUnitThisCallRector.php:72
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  - '#Cognitive complexity for "Rector\\PHPUnit\\Rector\\Class_\\PreferPHPUnitThisCallRector\:\:refactor\(\)" is 11, keep it under 10#'

from PHPStan

TomasVotruba commented 1 year ago

Thank you @JohJohan :clap: