diff --git a/src/RectorizeTemplate.php b/src/RectorizeTemplate.php index 5e23032..a80d445 100644 --- a/src/RectorizeTemplate.php +++ b/src/RectorizeTemplate.php @@ -4,6 +4,7 @@ namespace League\Plates; +use League\Plates\Template\DoNotAddItInConstructorInterface; use League\Plates\Template\Template; use League\Plates\Template\TemplateClass; use League\Plates\Template\TemplateClassInterface; @@ -27,6 +28,7 @@ */ final class RectorizeTemplate extends AbstractRector { + const CLASS_TO_NOT_ADD_IN_CONSTRUCTOR = [Template::class, TemplateClass::class, DoNotAddItInConstructorInterface::class]; /** * @readonly * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer @@ -108,8 +110,10 @@ public function refactor(Node $node) : ?Node $methodDocBlock = $displayMethod?->getDocComment()?->getText() ?? ''; foreach($displayMethod->params as $parameter) { $paramType = $this->paramTypeResolver->resolve($parameter); - if ($paramType instanceof FullyQualifiedObjectType && in_array($paramType->getClassName(), [Template::class, TemplateClass::class], true)) - continue; + if ($paramType instanceof FullyQualifiedObjectType + && in_array($paramType->getClassName(), self::CLASS_TO_NOT_ADD_IN_CONSTRUCTOR, true)) { + continue; + } $paramDocBlock = $this->getParameterDocblock($methodDocBlock, $this->getName($parameter)); if ($paramDocBlock !== null) diff --git a/src/Template/DoNotAddItInConstructorInterface.php b/src/Template/DoNotAddItInConstructorInterface.php new file mode 100644 index 0000000..d82d522 --- /dev/null +++ b/src/Template/DoNotAddItInConstructorInterface.php @@ -0,0 +1,7 @@ +