mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-20 07:22:43 +02:00
skip analysis of new anonymous classes in method call [closes #1574]
This commit is contained in:
parent
3add1822b4
commit
7c60f52450
@ -406,7 +406,14 @@ final class NodeTypeResolver
|
||||
return [];
|
||||
}
|
||||
|
||||
// PHPStan
|
||||
// skip anonymous classes, ref https://github.com/rectorphp/rector/issues/1574
|
||||
if ($node instanceof Expr\New_) {
|
||||
$className = $this->nameResolver->resolve($node->class);
|
||||
if ($className === null || Strings::contains($className, 'AnonymousClass')) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
$type = $nodeScope->getType($node);
|
||||
|
||||
$typesInStrings = $this->typeToStringResolver->resolve($type);
|
||||
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Symfony\Tests\Rector\New_\StringToArrayArgumentProcessRector\Fixture;
|
||||
|
||||
class SkipAnonymousClass
|
||||
{
|
||||
public function buildForm($builder): void
|
||||
{
|
||||
$builder->add(
|
||||
new class() {
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ final class StringToArrayArgumentProcessRectorTest extends AbstractRectorTestCas
|
||||
__DIR__ . '/Fixture/fixture3.php.inc',
|
||||
__DIR__ . '/Fixture/fixture4.php.inc',
|
||||
__DIR__ . '/Fixture/with_sprintf.php.inc',
|
||||
__DIR__ . '/Fixture/skip_anonymous_class.php.inc',
|
||||
]);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user