diff --git a/rules-tests/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector/Fixture/skipped_by_path.php.inc b/rules-tests/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector/Fixture/skipped_by_path.php.inc new file mode 100644 index 00000000000..2b606aed16a --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector/Fixture/skipped_by_path.php.inc @@ -0,0 +1,7 @@ +rule(DeclareStrictTypesRector::class); + $rectorConfig->skip([ + DeclareStrictTypesRector::class => [ + // .php.inc changed .php during running test + realpath(__DIR__ . '/../Fixture') . '/skipped_by_path.php', + ], + ]); }; diff --git a/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php b/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php index 43ddd607979..1cf9d22e7aa 100644 --- a/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php +++ b/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php @@ -53,6 +53,11 @@ public function beforeTraverse(array $nodes): ?array { parent::beforeTraverse($nodes); + $filePath = $this->file->getFilePath(); + if ($this->skipper->shouldSkipElementAndFilePath(self::class, $filePath)) { + return null; + } + $newStmts = $this->file->getNewStmts(); if ($newStmts === []) { diff --git a/src/Rector/AbstractRector.php b/src/Rector/AbstractRector.php index d872f2b35b0..21906895321 100644 --- a/src/Rector/AbstractRector.php +++ b/src/Rector/AbstractRector.php @@ -71,7 +71,7 @@ abstract class AbstractRector extends NodeVisitorAbstract implements RectorInter private SimpleCallableNodeTraverser $simpleCallableNodeTraverser; - private Skipper $skipper; + protected Skipper $skipper; private CurrentFileProvider $currentFileProvider;