Skip to content

Commit 42bc067

Browse files
committed
Reduce duplicate code
1 parent 33585e0 commit 42bc067

File tree

2 files changed

+2
-32
lines changed

2 files changed

+2
-32
lines changed

Magento2/Sniffs/Html/HtmlClosingVoidTagsSniff.php

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Sniff for void closing tags.
1515
*/
16-
class HtmlClosingVoidTagsSniff implements Sniff
16+
class HtmlClosingVoidTagsSniff extends HtmlSelfClosingTagsSniff implements Sniff
1717
{
1818
/**
1919
* String representation of warning.
@@ -53,9 +53,6 @@ class HtmlClosingVoidTagsSniff implements Sniff
5353
'wbr',
5454
];
5555

56-
/** @var int */
57-
private int $lastPointer = 0;
58-
5956
/**
6057
* @inheritdoc
6158
*/
@@ -114,31 +111,4 @@ public function process(File $phpcsFile, $stackPtr): void
114111
}
115112
}
116113
}
117-
118-
/**
119-
* Apply a fix for the detected issue
120-
*
121-
* @param File $phpcsFile
122-
* @param string $needle
123-
* @return int|null
124-
*/
125-
public function findPointer(File $phpcsFile, string $needle): ?int
126-
{
127-
foreach ($phpcsFile->getTokens() as $ptr => $token) {
128-
if ($ptr < $this->lastPointer) {
129-
continue;
130-
}
131-
132-
if ($token['code'] !== T_INLINE_HTML) {
133-
continue;
134-
}
135-
136-
if (str_contains($token['content'], $needle)) {
137-
$this->lastPointer = $ptr;
138-
return $ptr;
139-
}
140-
}
141-
142-
return null;
143-
}
144114
}

Magento2/Sniffs/Html/HtmlSelfClosingTagsSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function process(File $phpcsFile, $stackPtr)
111111
* @param string $needle
112112
* @return int|null
113113
*/
114-
private function findPointer(File $phpcsFile, string $needle): ?int
114+
protected function findPointer(File $phpcsFile, string $needle): ?int
115115
{
116116
foreach ($phpcsFile->getTokens() as $ptr => $token) {
117117
if ($ptr < $this->lastPointer) {

0 commit comments

Comments
 (0)