Skip to content

Commit cbe2a4c

Browse files
authored
include message as well (#428)
1 parent c4c9b2b commit cbe2a4c

3 files changed

Lines changed: 47 additions & 4 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Rector\Doctrine\Tests\TypedCollections\Rector\Expression\RemoveAssertNotNullOnCollectionRector\Fixture;
4+
5+
use Doctrine\Common\Collections\Collection;
6+
7+
final class AlsoIncludeMessage
8+
{
9+
public Collection $items;
10+
11+
public function someMethod()
12+
{
13+
\PHPUnit\Framework\Assert::assertNotNull($this->items, 'some message');
14+
}
15+
}
16+
17+
?>
18+
-----
19+
<?php
20+
21+
namespace Rector\Doctrine\Tests\TypedCollections\Rector\Expression\RemoveAssertNotNullOnCollectionRector\Fixture;
22+
23+
use Doctrine\Common\Collections\Collection;
24+
25+
final class AlsoIncludeMessage
26+
{
27+
public Collection $items;
28+
29+
public function someMethod()
30+
{
31+
}
32+
}
33+
34+
?>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\Doctrine\Tests\TypedCollections\Rector\Expression\RemoveAssertNotNullOnCollectionRector\Fixture;
4+
5+
final class SkipNonCollection
6+
{
7+
public array $items;
8+
9+
public function someMethod()
10+
{
11+
\PHPUnit\Framework\Assert::assertNotNull($this->items);
12+
}
13+
}

rules/TypedCollections/Rector/Expression/RemoveAssertNotNullOnCollectionRector.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ public function refactor(Node $node): ?int
8181
return null;
8282
}
8383

84-
if (count($staticCall->args) !== 1) {
85-
return null;
86-
}
87-
8884
$firstArg = $staticCall->getArgs()[0];
8985
if (! $this->collectionTypeDetector->isCollectionType($firstArg->value)) {
9086
return null;

0 commit comments

Comments
 (0)