Skip to content

Commit f39cd7d

Browse files
committed
[fix] skip HTML + PHP mix in DeclareStrictTypesTestsRector to avoid mallformed code
1 parent 50cec58 commit f39cd7d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<img src="asdf">
2+
3+
<?php
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class SkipHtmlPHPMix extends TestCase
8+
{
9+
public function test()
10+
{
11+
}
12+
}

rules/CodeQuality/Rector/StmtsAwareInterface/DeclareStrictTypesTestsRector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public function beforeTraverse(array $nodes): ?array
7474
{
7575
parent::beforeTraverse($nodes);
7676

77+
if ($this->file->containsHTML()) {
78+
return null;
79+
}
80+
7781
if ($this->shouldSkipNodes($nodes, $this->file)) {
7882
return null;
7983
}

0 commit comments

Comments
 (0)