Skip to content

Commit bc6349b

Browse files
[PHPUnit90] Handle crash on different object without second arg on SpecificAssertContainsWithoutIdentityRector (#474)
* [PHPUnit90] Handle crash on different object without second arg on SpecificAssertContainsWithoutIdentityRector * [PHPUnit90] Handle crash on different object without second arg on SpecificAssertContainsWithoutIdentityRector * [ci-review] Rector Rectify * [PHPUnit90] Handle crash on different object without second arg on SpecificAssertContainsWithoutIdentityRector * [PHPUnit90] Handle crash on different object without second arg on SpecificAssertContainsWithoutIdentityRector * Fix * [ci-review] Rector Rectify * Fix --------- Co-authored-by: GitHub Action <[email protected]>
1 parent 0da29d9 commit bc6349b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\PHPUnit90\Rector\MethodCall\SpecificAssertContainsWithoutIdentityRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use stdClass;
7+
8+
final class SkipNoSecondArg extends TestCase
9+
{
10+
public function test()
11+
{
12+
$objects = [ new stdClass(), new stdClass(), new stdClass() ];
13+
$this->transport()->queue()->assertContains(new stdClass());
14+
}
15+
}

rules/PHPUnit90/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ public function refactor(Node $node): ?Node
9292
return null;
9393
}
9494

95+
if (count($node->getArgs()) < 2) {
96+
return null;
97+
}
98+
9599
// when second argument is string: do nothing
96100
$secondArgType = $this->getType($node->getArgs()[1]->value);
97101
if ($secondArgType instanceof StringType) {

0 commit comments

Comments
 (0)