Skip to content

Commit

Permalink
[CLEANUP] Use self:: to access class constants (#966)
Browse files Browse the repository at this point in the history
...rather than `static::`.  Constants are by definition not intended to be
overridden.

This also clears up the `MixedOperand` issues reported by Psalm for the affected
code.
  • Loading branch information
JakeQZ authored Apr 6, 2021
1 parent 37be66a commit 37595a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
8 changes: 0 additions & 8 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@
</UnnecessaryVarAnnotation>
</file>
<file src="src/HtmlProcessor/AbstractHtmlProcessor.php">
<MixedOperand occurrences="6">
<code>static::CONTENT_TYPE_META_TAG</code>
<code>static::CONTENT_TYPE_META_TAG</code>
<code>static::CONTENT_TYPE_META_TAG</code>
<code>static::DEFAULT_DOCUMENT_TYPE</code>
<code>static::PHP_UNRECOGNIZED_VOID_TAGNAME_MATCHER</code>
<code>static::PHP_UNRECOGNIZED_VOID_TAGNAME_MATCHER</code>
</MixedOperand>
<PossiblyNullPropertyAssignmentValue occurrences="1">
<code>null</code>
</PossiblyNullPropertyAssignmentValue>
Expand Down
12 changes: 6 additions & 6 deletions src/HtmlProcessor/AbstractHtmlProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function renderBodyContent(): string
*/
private function removeSelfClosingTagsClosingTags(string $html): string
{
return \preg_replace('%</' . static::PHP_UNRECOGNIZED_VOID_TAGNAME_MATCHER . '>%', '', $html);
return \preg_replace('%</' . self::PHP_UNRECOGNIZED_VOID_TAGNAME_MATCHER . '>%', '', $html);
}

/**
Expand Down Expand Up @@ -263,7 +263,7 @@ private function ensureDocumentType(string $html): string
return $this->normalizeDocumentType($html);
}

return static::DEFAULT_DOCUMENT_TYPE . $html;
return self::DEFAULT_DOCUMENT_TYPE . $html;
}

/**
Expand Down Expand Up @@ -307,17 +307,17 @@ private function addContentTypeMetaTag(string $html): string
if ($hasHeadTag) {
$reworkedHtml = \preg_replace(
'/<head(?=[\\s>])([^>]*+)>/i',
'<head$1>' . static::CONTENT_TYPE_META_TAG,
'<head$1>' . self::CONTENT_TYPE_META_TAG,
$html
);
} elseif ($hasHtmlTag) {
$reworkedHtml = \preg_replace(
'/<html(.*?)>/i',
'<html$1><head>' . static::CONTENT_TYPE_META_TAG . '</head>',
'<html$1><head>' . self::CONTENT_TYPE_META_TAG . '</head>',
$html
);
} else {
$reworkedHtml = static::CONTENT_TYPE_META_TAG . $html;
$reworkedHtml = self::CONTENT_TYPE_META_TAG . $html;
}

return $reworkedHtml;
Expand Down Expand Up @@ -430,7 +430,7 @@ private function removeHtmlTemplateElements(string $html): string
private function ensurePhpUnrecognizedSelfClosingTagsAreXml(string $html): string
{
return \preg_replace(
'%<' . static::PHP_UNRECOGNIZED_VOID_TAGNAME_MATCHER . '\\b[^>]*+(?<!/)(?=>)%',
'%<' . self::PHP_UNRECOGNIZED_VOID_TAGNAME_MATCHER . '\\b[^>]*+(?<!/)(?=>)%',
'$0/',
$html
);
Expand Down

0 comments on commit 37595a9

Please sign in to comment.