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
@@ -0,0 +1,20 @@
<?php

// skip: non-string argument (enum case) should not crash

namespace Rector\PHPUnit\Tests\PHPUnit120\Rector\Class_\AssertIsTypeMethodCallRector\Fixture;

use PHPUnit\Framework\TestCase;

enum SkipNonStringArgEnum
{
case ONE;
}

final class SkipNonStringArg extends TestCase
{
public function testMethod(): void
{
$this->assertThat([], $this->isType(SkipNonStringArgEnum::ONE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ public function refactor(Node $node): Node|null
}

$argValue = $this->valueResolver->getValue($arg);
if (! is_string($argValue)) {
return null;
}

if (isset(self::IS_TYPE_VALUE_TO_METHOD[$argValue])) {
if ($node instanceof MethodCall) {
return new MethodCall($node->var, self::IS_TYPE_VALUE_TO_METHOD[$argValue]);
Expand Down
Loading