File manager - Edit - /var/www/payraty/helpdesk/vendor/rector/rector/vendor/rector/rector-phpunit/src/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector.php
Back
<?php declare (strict_types=1); namespace Rector\PHPUnit\Rector\MethodCall; use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\StaticCall; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/sebastianbergmann/phpunit/issues/3494#issuecomment-480283612 * @changelog https://github.com/sebastianbergmann/phpunit/issues/3495 * * @see \Rector\PHPUnit\Tests\Rector\MethodCall\ReplaceAssertArraySubsetWithDmsPolyfillRector\ReplaceAssertArraySubsetWithDmsPolyfillRectorTest */ final class ReplaceAssertArraySubsetWithDmsPolyfillRector extends AbstractRector { /** * @readonly * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Change assertArraySubset() to static call of DMS\\PHPUnitExtensions\\ArraySubset\\Assert', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; class SomeClass extends TestCase { public function test() { self::assertArraySubset(['bar' => 0], ['bar' => '0'], true); $this->assertArraySubset(['bar' => 0], ['bar' => '0'], true); } } CODE_SAMPLE , <<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; class SomeClass extends TestCase { public function test() { \DMS\PHPUnitExtensions\ArraySubset\Assert::assertArraySubset(['bar' => 0], ['bar' => '0'], true); \DMS\PHPUnitExtensions\ArraySubset\Assert::assertArraySubset(['bar' => 0], ['bar' => '0'], true); } } CODE_SAMPLE )]); } /** * @return array<class-string<Node>> */ public function getNodeTypes() : array { return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInPHPUnitMethodCallName($node, 'assertArraySubset')) { return null; } return $this->nodeFactory->createStaticCall('DMS\\PHPUnitExtensions\\ArraySubset\\Assert', 'assertArraySubset', $node->args); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0 |
proxy
|
phpinfo
|
Settings