Skip to content

Commit

Permalink
TASK: Assert preg_* has no errors to make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Nov 18, 2023
1 parent 98302d6 commit 4670625
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Neos.Neos/Classes/Fusion/ConvertUrisImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function evaluate()
$unresolvedUris = [];
$absolute = $this->fusionValue('absolute');

$processedContent = preg_replace_callback(self::PATTERN_SUPPORTED_URIS, function (array $matches) use ($node, $nodeAddress, &$unresolvedUris, $absolute) {
$processedContent = preg_replace_callback(self::PATTERN_SUPPORTED_URIS, function (array $matches) use ($nodeAddress, &$unresolvedUris, $absolute) {
$resolvedUri = null;
switch ($matches[1]) {
case 'node':
Expand Down Expand Up @@ -174,10 +174,13 @@ public function evaluate()

return $resolvedUri;
}, $text);
assert($processedContent !== null, 'preg_* error');

if ($unresolvedUris !== []) {
$processedContent = preg_replace('/<a(?:\s+[^>]*)?\s+href="(node|asset):\/\/[^"]+"[^>]*>(.*?)<\/a>/', '$2', $processedContent);
assert($processedContent !== null, 'preg_* error');
$processedContent = preg_replace(self::PATTERN_SUPPORTED_URIS, '', $processedContent);
assert($processedContent !== null, 'preg_* error');
}

$processedContent = $this->replaceLinkTargets($processedContent);
Expand Down Expand Up @@ -228,6 +231,7 @@ static function ($matches) use ($externalLinkTarget, $resourceLinkTarget, $host,
},
$processedContent
);
assert($processedContent !== null, 'preg_* error');
return $processedContent;
}

Expand All @@ -249,7 +253,9 @@ private static function setAttribute(string $attribute, string $value, string $c
return $content;
}
// Add the attribute to the list
return \preg_replace('/' . $attribute . '="(.*?)"/', sprintf('%s="$1 %s"', $attribute, $value), $content);
$result = \preg_replace('/' . $attribute . '="(.*?)"/', sprintf('%s="$1 %s"', $attribute, $value), $content);
assert($result !== null, 'preg_* error');
return $result;
}

// Add the missing attribute with the value
Expand Down

0 comments on commit 4670625

Please sign in to comment.