mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 06:18:07 +01:00
[NodeTraverser] Apply array param autowire
This commit is contained in:
parent
3073942c8a
commit
318f5b30f8
@ -52,18 +52,6 @@ final class NodeTypeResolver
|
||||
}
|
||||
}
|
||||
|
||||
private function addPerNodeTypeResolver(PerNodeTypeResolverInterface $perNodeTypeResolver): void
|
||||
{
|
||||
foreach ($perNodeTypeResolver->getNodeClasses() as $nodeClass) {
|
||||
$this->perNodeTypeResolvers[$nodeClass] = $perNodeTypeResolver;
|
||||
}
|
||||
|
||||
// in-code setter injection to drop CompilerPass requirement for 3rd party package install
|
||||
if ($perNodeTypeResolver instanceof NodeTypeResolverAwareInterface) {
|
||||
$perNodeTypeResolver->setNodeTypeResolver($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
@ -88,6 +76,18 @@ final class NodeTypeResolver
|
||||
return $types;
|
||||
}
|
||||
|
||||
private function addPerNodeTypeResolver(PerNodeTypeResolverInterface $perNodeTypeResolver): void
|
||||
{
|
||||
foreach ($perNodeTypeResolver->getNodeClasses() as $nodeClass) {
|
||||
$this->perNodeTypeResolvers[$nodeClass] = $perNodeTypeResolver;
|
||||
}
|
||||
|
||||
// in-code setter injection to drop CompilerPass requirement for 3rd party package install
|
||||
if ($perNodeTypeResolver instanceof NodeTypeResolverAwareInterface) {
|
||||
$perNodeTypeResolver->setNodeTypeResolver($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
|
@ -88,6 +88,9 @@ parameters:
|
||||
- '#In method "Rector\\Node\\NodeFactory::createArray", parameter \$items can be type-hinted to "array"#'
|
||||
- '#In method "Rector\\Builder\\StatementGlue::addStatementToClassBeforeTypes", parameter \$types type is "array". Please provide a \@param annotation to further specify the type of the array. For instance: \@param int\[\] \$types#'
|
||||
|
||||
# not really needed, empty
|
||||
- '#Rector\\NodeTraverser\\RectorNodeTraverser::__construct\(\) does not call parent constructor from PhpParser\\NodeTraverser#'
|
||||
|
||||
services:
|
||||
-
|
||||
class: Symplify\PHPStanExtensions\Type\SplFileInfoTolerantDynamicMethodReturnTypeExtension
|
||||
|
@ -7,9 +7,14 @@ use Rector\Contract\Rector\PhpRectorInterface;
|
||||
|
||||
final class RectorNodeTraverser extends NodeTraverser
|
||||
{
|
||||
public function addRector(PhpRectorInterface $phpRector): void
|
||||
/**
|
||||
* @param PhpRectorInterface[] $phpRectors
|
||||
*/
|
||||
public function __construct(array $phpRectors = [])
|
||||
{
|
||||
$this->addVisitor($phpRector);
|
||||
foreach ($phpRectors as $phpRector) {
|
||||
$this->addVisitor($phpRector);
|
||||
}
|
||||
}
|
||||
|
||||
public function getRectorCount(): int
|
||||
|
@ -8,10 +8,3 @@ imports:
|
||||
parameters:
|
||||
exclude_paths: []
|
||||
autoload_paths: []
|
||||
|
||||
# see https://github.com/symplify/packagebuilder#collect-services-in-short-configs
|
||||
collectors:
|
||||
-
|
||||
main_type: 'Rector\NodeTraverser\RectorNodeTraverser'
|
||||
collected_type: 'Rector\Contract\Rector\PhpRectorInterface'
|
||||
add_method: 'addRector'
|
||||
|
Loading…
x
Reference in New Issue
Block a user