Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector\Fixture;

final class AssertCompareContext
use Behat\Behat\Context\Context;

final class AssertCompareContext implements Context
{
public function some($response)
{
Expand All @@ -17,7 +19,9 @@ final class AssertCompareContext

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector\Fixture;

final class AssertCompareContext
use Behat\Behat\Context\Context;

final class AssertCompareContext implements Context
{
public function some($response)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector\Fixture;

final class AssertNullCompareContext
use Behat\Behat\Context\Context;

final class AssertNullCompareContext implements Context
{
public function some($response)
{
Expand All @@ -16,7 +18,9 @@ final class AssertNullCompareContext

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector\Fixture;

final class AssertNullCompareContext
use Behat\Behat\Context\Context;

final class AssertNullCompareContext implements Context
{
public function some($response)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector\Fixture;

final class MethodExistsContext
use Behat\Behat\Context\Context;

final class MethodExistsContext implements Context
{
public function some($response)
{
Expand All @@ -16,7 +18,9 @@ final class MethodExistsContext

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector\Fixture;

final class MethodExistsContext
use Behat\Behat\Context\Context;

final class MethodExistsContext implements Context
{
public function some($response)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector\Fixture;

final class SimpleContext
use Behat\Behat\Context\Context;

final class SimpleContext implements Context
{
public function some($response)
{
Expand All @@ -18,7 +20,9 @@ final class SimpleContext

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector\Fixture;

final class SimpleContext
use Behat\Behat\Context\Context;

final class SimpleContext implements Context
{
public function some($response)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector\Fixture;

final class SchemaValidationContext
{
public function some($response)
{
assert($response instanceof \DateTime, 'only remaining option');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Rector\PhpParser\Node\Value\ValueResolver;
use Rector\PHPStan\ScopeFetcher;
use Rector\PHPUnit\Enum\AssertMethod;
use Rector\PHPUnit\Enum\BehatClassName;
use Rector\PHPUnit\Enum\PHPUnitClassName;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
Expand Down Expand Up @@ -195,15 +196,13 @@ public function refactor(Node $node): ?Class_
private function isBehatContext(Class_ $class): bool
{
$scope = ScopeFetcher::fetch($class);
if (! $scope->getClassReflection() instanceof ClassReflection) {
$classReflection = $scope->getClassReflection();
if (! $classReflection instanceof ClassReflection) {
return false;
}

$className = $scope->getClassReflection()
->getName();

// special case with static call
return str_ends_with($className, 'Context');
return $classReflection->is(BehatClassName::CONTEXT);
}

/**
Expand Down
Loading