From f39cd7d77050d78f63f7e585804a7ff61745e6b2 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 8 Dec 2025 19:55:38 +0100 Subject: [PATCH 1/2] [fix] skip HTML + PHP mix in DeclareStrictTypesTestsRector to avoid mallformed code --- .../Fixture/skip_html_php_mix.php.inc | 12 ++++++++++++ .../DeclareStrictTypesTestsRector.php | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 rules-tests/CodeQuality/Rector/StmtsAwareInterface/DeclareStrictTypesTestsRector/Fixture/skip_html_php_mix.php.inc diff --git a/rules-tests/CodeQuality/Rector/StmtsAwareInterface/DeclareStrictTypesTestsRector/Fixture/skip_html_php_mix.php.inc b/rules-tests/CodeQuality/Rector/StmtsAwareInterface/DeclareStrictTypesTestsRector/Fixture/skip_html_php_mix.php.inc new file mode 100644 index 00000000..c600657f --- /dev/null +++ b/rules-tests/CodeQuality/Rector/StmtsAwareInterface/DeclareStrictTypesTestsRector/Fixture/skip_html_php_mix.php.inc @@ -0,0 +1,12 @@ + + +file->containsHTML()) { + return null; + } + if ($this->shouldSkipNodes($nodes, $this->file)) { return null; } From cd9f03c233157d77b9d9aab399ecc4c2083780a1 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 8 Dec 2025 19:57:19 +0100 Subject: [PATCH 2/2] cleanup RemoveOverrideFinalConstructTestCaseRector --- ...oveOverrideFinalConstructTestCaseRector.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rules/PHPUnit120/Rector/Class_/RemoveOverrideFinalConstructTestCaseRector.php b/rules/PHPUnit120/Rector/Class_/RemoveOverrideFinalConstructTestCaseRector.php index f7938a82..9b426557 100644 --- a/rules/PHPUnit120/Rector/Class_/RemoveOverrideFinalConstructTestCaseRector.php +++ b/rules/PHPUnit120/Rector/Class_/RemoveOverrideFinalConstructTestCaseRector.php @@ -71,17 +71,17 @@ public function refactor(Node $node): Node|null return null; } - $constructClassMethod = $node->getMethod(MethodName::CONSTRUCT); - - if ($constructClassMethod instanceof ClassMethod) { - foreach ($node->stmts as $key => $stmt) { - if ($stmt instanceof ClassMethod && $this->isName($stmt, MethodName::CONSTRUCT)) { - unset($node->stmts[$key]); + foreach ($node->stmts as $key => $stmt) { + if (! $stmt instanceof ClassMethod) { + continue; + } - $node->setAttribute('hasRemovedFinalConstruct', true); - return $node; - } + if (! $this->isName($stmt, MethodName::CONSTRUCT)) { + continue; } + + unset($node->stmts[$key]); + return $node; } return null;