Add self call fixtures for AssertResourceToClosed (#4103)

This commit is contained in:
Chun-Sheng, Li 2020-09-02 17:53:55 +08:00 committed by GitHub
parent 83e2db04d8
commit 471e820d4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 2 deletions

View File

@ -6,6 +6,7 @@ namespace Rector\PHPUnit\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use Rector\Core\PhpParser\Node\Manipulator\IdentifierManipulator;
use Rector\Core\Rector\AbstractPHPUnitRector;
use Rector\Core\RectorDefinition\CodeSample;
@ -53,11 +54,11 @@ final class AssertResourceToClosedResourceRector extends AbstractPHPUnitRector
*/
public function getNodeTypes(): array
{
return [MethodCall::class];
return [MethodCall::class, StaticCall::class];
}
/**
* @param MethodCall $node
* @param MethodCall|StaticCall $node
*/
public function refactor(Node $node): ?Node
{

View File

@ -0,0 +1,35 @@
<?php
namespace Rector\PHPUnit\Tests\Rector\MethodCall\AssertResourceToClosedResourceRector\Fixture;
final class MyIsTypeTest2 extends \PHPUnit\Framework\TestCase
{
public function test()
{
$handler = fopen('php://temp', 'w');
self::assertIsResource($handler);
fclose($handler);
self::assertIsNotResource($handler);
}
}
?>
-----
<?php
namespace Rector\PHPUnit\Tests\Rector\MethodCall\AssertResourceToClosedResourceRector\Fixture;
final class MyIsTypeTest2 extends \PHPUnit\Framework\TestCase
{
public function test()
{
$handler = fopen('php://temp', 'w');
self::assertIsResource($handler);
fclose($handler);
self::assertIsClosedResource($handler);
}
}
?>