Skip to content

Commit 7b3de24

Browse files
committed
add do not add in constructor interface
1 parent df1c0df commit 7b3de24

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/RectorizeTemplate.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace League\Plates;
66

7+
use League\Plates\Template\DoNotAddItInConstructorInterface;
78
use League\Plates\Template\Template;
89
use League\Plates\Template\TemplateClass;
910
use League\Plates\Template\TemplateClassInterface;
@@ -27,6 +28,7 @@
2728
*/
2829
final class RectorizeTemplate extends AbstractRector
2930
{
31+
const CLASS_TO_NOT_ADD_IN_CONSTRUCTOR = [Template::class, TemplateClass::class, DoNotAddItInConstructorInterface::class];
3032
/**
3133
* @readonly
3234
* @var \Rector\Core\NodeAnalyzer\ParamAnalyzer
@@ -108,8 +110,10 @@ public function refactor(Node $node) : ?Node
108110
$methodDocBlock = $displayMethod?->getDocComment()?->getText() ?? '';
109111
foreach($displayMethod->params as $parameter) {
110112
$paramType = $this->paramTypeResolver->resolve($parameter);
111-
if ($paramType instanceof FullyQualifiedObjectType && in_array($paramType->getClassName(), [Template::class, TemplateClass::class], true))
112-
continue;
113+
if ($paramType instanceof FullyQualifiedObjectType
114+
&& in_array($paramType->getClassName(), self::CLASS_TO_NOT_ADD_IN_CONSTRUCTOR, true)) {
115+
continue;
116+
}
113117

114118
$paramDocBlock = $this->getParameterDocblock($methodDocBlock, $this->getName($parameter));
115119
if ($paramDocBlock !== null)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace League\Plates\Template;
4+
5+
interface DoNotAddItInConstructorInterface // so retrieve from data
6+
{
7+
}

0 commit comments

Comments
 (0)