Updated Rector to commit 706be908c5d96381785128ad94cc608814aa0f35

706be908c5 lock react/promise to avoid process leaking
This commit is contained in:
Tomas Votruba 2023-07-12 13:11:50 +00:00
parent 75f2fdd3e2
commit d4bf4ea4ff
21 changed files with 245 additions and 38 deletions

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit2162c205e5fd52f68b4a7096dc342d5e::getLoader();
return ComposerAutoloaderInit403e9b3e175b446d3efee98eeb37d45c::getLoader();

View File

@ -2107,6 +2107,7 @@ return array(
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMessageRegExpFactory' => $vendorDir . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageRegExpFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMethodCallFactory' => $vendorDir . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMethodCallFactory.php',
'Rector\\PHPUnit\\NodeFinder\\DataProviderClassMethodFinder' => $vendorDir . '/rector/rector-phpunit/src/NodeFinder/DataProviderClassMethodFinder.php',
'Rector\\PHPUnit\\PHPUnit50\\Rector\\StaticCall\\GetMockRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit50/Rector/StaticCall/GetMockRector.php',
'Rector\\PHPUnit\\PhpDoc\\DataProviderMethodRenamer' => $vendorDir . '/rector/rector-phpunit/src/PhpDoc/DataProviderMethodRenamer.php',
'Rector\\PHPUnit\\PhpDoc\\PhpDocValueToNodeMapper' => $vendorDir . '/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\AddDoesNotPerformAssertionToNonAssertingTestRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php',
@ -2158,7 +2159,6 @@ return array(
'Rector\\PHPUnit\\Rector\\MethodCall\\SpecificAssertInternalTypeRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertInternalTypeRector.php',
'Rector\\PHPUnit\\Rector\\MethodCall\\UseSpecificWillMethodRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/UseSpecificWillMethodRector.php',
'Rector\\PHPUnit\\Rector\\MethodCall\\UseSpecificWithMethodRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/UseSpecificWithMethodRector.php',
'Rector\\PHPUnit\\Rector\\StaticCall\\GetMockRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/StaticCall/GetMockRector.php',
'Rector\\PHPUnit\\Set\\PHPUnitLevelSetList' => $vendorDir . '/rector/rector-phpunit/src/Set/PHPUnitLevelSetList.php',
'Rector\\PHPUnit\\Set\\PHPUnitSetList' => $vendorDir . '/rector/rector-phpunit/src/Set/PHPUnitSetList.php',
'Rector\\PHPUnit\\ValueObject\\AnnotationWithValueToAttribute' => $vendorDir . '/rector/rector-phpunit/src/ValueObject/AnnotationWithValueToAttribute.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit2162c205e5fd52f68b4a7096dc342d5e
class ComposerAutoloaderInit403e9b3e175b446d3efee98eeb37d45c
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit2162c205e5fd52f68b4a7096dc342d5e
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit2162c205e5fd52f68b4a7096dc342d5e', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit403e9b3e175b446d3efee98eeb37d45c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit2162c205e5fd52f68b4a7096dc342d5e', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit403e9b3e175b446d3efee98eeb37d45c', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit2162c205e5fd52f68b4a7096dc342d5e::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit2162c205e5fd52f68b4a7096dc342d5e::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit2162c205e5fd52f68b4a7096dc342d5e
class ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2360,6 +2360,7 @@ class ComposerStaticInit2162c205e5fd52f68b4a7096dc342d5e
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMessageRegExpFactory' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageRegExpFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMethodCallFactory' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMethodCallFactory.php',
'Rector\\PHPUnit\\NodeFinder\\DataProviderClassMethodFinder' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFinder/DataProviderClassMethodFinder.php',
'Rector\\PHPUnit\\PHPUnit50\\Rector\\StaticCall\\GetMockRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit50/Rector/StaticCall/GetMockRector.php',
'Rector\\PHPUnit\\PhpDoc\\DataProviderMethodRenamer' => __DIR__ . '/..' . '/rector/rector-phpunit/src/PhpDoc/DataProviderMethodRenamer.php',
'Rector\\PHPUnit\\PhpDoc\\PhpDocValueToNodeMapper' => __DIR__ . '/..' . '/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\AddDoesNotPerformAssertionToNonAssertingTestRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php',
@ -2411,7 +2412,6 @@ class ComposerStaticInit2162c205e5fd52f68b4a7096dc342d5e
'Rector\\PHPUnit\\Rector\\MethodCall\\SpecificAssertInternalTypeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertInternalTypeRector.php',
'Rector\\PHPUnit\\Rector\\MethodCall\\UseSpecificWillMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/UseSpecificWillMethodRector.php',
'Rector\\PHPUnit\\Rector\\MethodCall\\UseSpecificWithMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/UseSpecificWithMethodRector.php',
'Rector\\PHPUnit\\Rector\\StaticCall\\GetMockRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/StaticCall/GetMockRector.php',
'Rector\\PHPUnit\\Set\\PHPUnitLevelSetList' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Set/PHPUnitLevelSetList.php',
'Rector\\PHPUnit\\Set\\PHPUnitSetList' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Set/PHPUnitSetList.php',
'Rector\\PHPUnit\\ValueObject\\AnnotationWithValueToAttribute' => __DIR__ . '/..' . '/rector/rector-phpunit/src/ValueObject/AnnotationWithValueToAttribute.php',
@ -3068,9 +3068,9 @@ class ComposerStaticInit2162c205e5fd52f68b4a7096dc342d5e
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit2162c205e5fd52f68b4a7096dc342d5e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit2162c205e5fd52f68b4a7096dc342d5e::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit2162c205e5fd52f68b4a7096dc342d5e::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2049,12 +2049,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "7d2eab265f90d1b470b56f89e6680b3155c3204c"
"reference": "120e7ee1d392e5b87b1470c9267dee87acb03037"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/7d2eab265f90d1b470b56f89e6680b3155c3204c",
"reference": "7d2eab265f90d1b470b56f89e6680b3155c3204c",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/120e7ee1d392e5b87b1470c9267dee87acb03037",
"reference": "120e7ee1d392e5b87b1470c9267dee87acb03037",
"shasum": ""
},
"require": {
@ -2082,7 +2082,7 @@
"tomasvotruba\/type-coverage": "^0.1",
"tomasvotruba\/unused-public": "^0.1"
},
"time": "2023-07-12T12:35:37+00:00",
"time": "2023-07-12T13:05:58+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 8afdccb'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 410d05f'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7d2eab2'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e788554'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 8afdccb'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 410d05f'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 120e7ee'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e788554'));
private function __construct()
{
}

View File

@ -4,7 +4,7 @@ declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\StaticCall\GetMockRector;
use Rector\PHPUnit\PHPUnit50\Rector\StaticCall\GetMockRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(GetMockRector::class);
};

View File

@ -1,4 +1,4 @@
# 50 Rules Overview
# 51 Rules Overview
## AddDoesNotPerformAssertionToNonAssertingTestRector
@ -675,7 +675,7 @@ Remove `getMockBuilder()` to `createMock()`
Turns getMock*() methods to `createMock()`
- class: [`Rector\PHPUnit\Rector\StaticCall\GetMockRector`](../src/Rector/StaticCall/GetMockRector.php)
- class: [`Rector\PHPUnit\PHPUnit50\Rector\StaticCall\GetMockRector`](../rules/PHPUnit50/Rector/StaticCall/GetMockRector.php)
```diff
use PHPUnit\Framework\TestCase;
@ -1086,6 +1086,32 @@ Refactor "*TestListener.php" to particular "*Hook.php" files
<br>
## TestWithAnnotationToAttributeRector
Change `@testWith()` annotation to #[TestWith] attribute
- class: [`Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\TestWithAnnotationToAttributeRector`](../rules/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector.php)
```diff
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\TestWith;
final class SomeFixture extends TestCase
{
- /**
- * @testWith ["foo"]
- * ["bar"]
- */
+ #[TestWith(['foo'])]
+ #[TestWith(['bar'])]
public function test(): void
{
}
}
```
<br>
## TryCatchToExpectExceptionRector
Turns try/catch to `expectException()` call

View File

@ -0,0 +1,27 @@
<?php
namespace Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\Fixture;
final class MyGetMockTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$firstMock = $this->getMock('SomeClass');
}
}
?>
-----
<?php
namespace Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\Fixture;
final class MyGetMockTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$firstMock = $this->createMock('SomeClass');
}
}
?>

View File

@ -0,0 +1,27 @@
<?php
namespace Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\Fixture;
final class GetMockMultiTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$firstMock = $this->getMock('LDUser', [], [], '', false);
}
}
?>
-----
<?php
namespace Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\Fixture;
final class GetMockMultiTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$firstMock = $this->createMock('LDUser');
}
}
?>

View File

@ -0,0 +1,12 @@
<?php
namespace Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\Fixture;
final class SkipBuildMockTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$secondMock = $this->buildMock()
->getMock();
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\Fixture;
use PHPUnit\Framework\TestCase;
use Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\Source\SomeExceptionWithGetMock;
final class SkipExceptionGetMock extends TestCase
{
public function test()
{
try {
parent::runTest();
} catch (SomeExceptionWithGetMock $someExceptionWithGetMock) {
$failedMock = $someExceptionWithGetMock->getMock();
}
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\Fixture;
use PHPUnit\Framework\TestCase;
final class SkipPrivateGetMock extends TestCase
{
public function test()
{
$firstMock = $this->getMock('some_class');
}
private function getMock(string $className)
{
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\Fixture;
final class StaticCallTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$firstMock = self::getMock('SomeClass');
}
}
?>
-----
<?php
namespace Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\Fixture;
final class StaticCallTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$firstMock = self::createMock('SomeClass');
}
}
?>

View File

@ -0,0 +1,23 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class GetMockRectorTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/configured_rule.php';
}
}

View File

@ -0,0 +1,11 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\Source;
final class SomeExceptionWithGetMock extends \Exception
{
public function getMock()
{
}
}

View File

@ -0,0 +1,11 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\PHPUnit50\Rector\StaticCall\GetMockRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->import(__DIR__ . '/../../../../../../config/config.php');
$rectorConfig->rule(GetMockRector::class);
};

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\Rector\StaticCall;
namespace Rector\PHPUnit\PHPUnit50\Rector\StaticCall;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
@ -17,7 +17,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
* @changelog https://github.com/sebastianbergmann/phpunit/blob/5.7.0/src/Framework/TestCase.php#L1623
* @changelog https://github.com/sebastianbergmann/phpunit/blob/6.0.0/src/Framework/TestCase.php#L1452
*
* @see \Rector\PHPUnit\Tests\Rector\StaticCall\GetMockRector\GetMockRectorTest
* @see \Rector\PHPUnit\Tests\PHPUnit50\Rector\StaticCall\GetMockRector\GetMockRectorTest
*/
final class GetMockRector extends AbstractRector
{

View File

@ -78,20 +78,24 @@ final class AssertCallAnalyzer
return $this->containsAssertCallByClassMethod[$cacheHash];
}
// A. try "->assert" shallow search first for performance
$hasDirectAssertCall = $this->hasDirectAssertCall($classMethod);
if ($hasDirectAssertCall) {
$this->containsAssertCallByClassMethod[$cacheHash] = $hasDirectAssertCall;
$hasDirectAssertOrMockCall = $this->hasDirectAssertOrMockCall($classMethod);
if ($hasDirectAssertOrMockCall) {
$this->containsAssertCallByClassMethod[$cacheHash] = $hasDirectAssertOrMockCall;
return \true;
}
// B. look for nested calls
$hasNestedAssertCall = $this->hasNestedAssertCall($classMethod);
$this->containsAssertCallByClassMethod[$cacheHash] = $hasNestedAssertCall;
return $hasNestedAssertCall;
$hasNestedAssertOrMockCall = $this->hasNestedAssertCall($classMethod);
$this->containsAssertCallByClassMethod[$cacheHash] = $hasNestedAssertOrMockCall;
return $hasNestedAssertOrMockCall;
}
private function hasDirectAssertCall(ClassMethod $classMethod) : bool
private function hasDirectAssertOrMockCall(ClassMethod $classMethod) : bool
{
return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) : bool {
if ($node instanceof MethodCall) {
// probably a mock
if ($this->nodeNameResolver->isName($node->name, 'expects')) {
return \true;
}
$type = $this->nodeTypeResolver->getType($node->var);
if ($type instanceof FullyQualifiedObjectType && \in_array($type->getClassName(), ['PHPUnit\\Framework\\MockObject\\MockBuilder', 'Prophecy\\Prophet'], \true)) {
return \true;
@ -112,6 +116,10 @@ final class AssertCallAnalyzer
if (!$node instanceof MethodCall && !$node instanceof StaticCall) {
return \false;
}
// is a mock call
if ($this->nodeNameResolver->isName($node->name, 'expects')) {
return \true;
}
$classMethod = $this->resolveClassMethodFromCall($node);
// skip circular self calls
if ($currentClassMethod === $classMethod) {

View File

@ -93,7 +93,8 @@ CODE_SAMPLE
if ($this->shouldSkipClassMethod($node)) {
return null;
}
$this->addDoesNotPerformAssertions($node);
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
$phpDocInfo->addPhpDocTagNode(new PhpDocTagNode('@doesNotPerformAssertions', new GenericTagValueNode('')));
return $node;
}
private function shouldSkipClassMethod(ClassMethod $classMethod) : bool
@ -107,11 +108,7 @@ CODE_SAMPLE
if ($classMethod->isAbstract()) {
return \true;
}
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
if ($phpDocInfo->hasByNames(['doesNotPerformAssertions', 'expectedException'])) {
return \true;
}
if ($this->phpAttributeAnalyzer->hasPhpAttribute($classMethod, 'PHPUnit\\Framework\\Attributes\\DoesNotPerformAssertions')) {
if ($this->hasAssertingAnnotationOrAttribute($classMethod)) {
return \true;
}
$this->assertCallAnalyzer->resetNesting();
@ -120,9 +117,12 @@ CODE_SAMPLE
}
return $this->mockedVariableAnalyzer->containsMockAsUsedVariable($classMethod);
}
private function addDoesNotPerformAssertions(ClassMethod $classMethod) : void
private function hasAssertingAnnotationOrAttribute(ClassMethod $classMethod) : bool
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
$phpDocInfo->addPhpDocTagNode(new PhpDocTagNode('@doesNotPerformAssertions', new GenericTagValueNode('')));
if ($phpDocInfo->hasByNames(['doesNotPerformAssertions', 'expectedException'])) {
return \true;
}
return $this->phpAttributeAnalyzer->hasPhpAttribute($classMethod, 'PHPUnit\\Framework\\Attributes\\DoesNotPerformAssertions');
}
}