From 02a79a06b4be0479b3e5cd41e3e1c536be348ce9 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Fri, 8 Nov 2019 16:48:05 +0100 Subject: [PATCH] [PHP70] Skip PHPUnit assert in ThisCallOnStaticMethodToStaticCallRector --- .../ThisCallOnStaticMethodToStaticCallRector.php | 7 +++++++ .../Fixture/skip_phpunit.php.inc | 13 +++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 packages/Php70/tests/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector/Fixture/skip_phpunit.php.inc diff --git a/packages/Php70/src/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php b/packages/Php70/src/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php index d11f82dbe6d..990b16d6e7b 100644 --- a/packages/Php70/src/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php +++ b/packages/Php70/src/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php @@ -7,6 +7,7 @@ namespace Rector\Php70\Rector\MethodCall; use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\Variable; +use PHPUnit\Framework\TestCase; use Rector\NodeContainer\ParsedNodesByType; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Rector\AbstractRector; @@ -85,6 +86,12 @@ PHP return null; } + if ($this->isObjectType($node->var, TestCase::class)) { + if ($this->isName($node->name, 'assert*')) { + return null; + } + } + $className = $node->getAttribute(AttributeKey::CLASS_NAME); if (! is_string($className)) { return null; diff --git a/packages/Php70/tests/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector/Fixture/skip_phpunit.php.inc b/packages/Php70/tests/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector/Fixture/skip_phpunit.php.inc new file mode 100644 index 00000000000..cd9fc2e3b50 --- /dev/null +++ b/packages/Php70/tests/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector/Fixture/skip_phpunit.php.inc @@ -0,0 +1,13 @@ +assertTrue(True); + } +}