Simplify preg_replace_callback in ApiDiscussionToolsPreview

There is nothing in this preg_replace call that needs to be executed
"as code". A normal preg_replace can do the same.

The pattern looks a bit different but really does have the exact same
effect as before.

Change-Id: I3597d632f2ecbe5b7ccef39a394075327c9bea79
This commit is contained in:
thiemowmde 2023-10-30 09:12:21 +01:00
parent f2265f918f
commit 07c051ba75

View file

@ -79,10 +79,8 @@ class ApiDiscussionToolsPreview extends ApiBase {
$signature = $this->msg( 'discussiontools-signature-prefix' )->inContentLanguage()->text() . '~~~~';
// Drop opacity of signature in preview to make message body preview clearer.
// Extract any leading spaces outside the <span> markup to ensure accurate previews.
$signature = preg_replace_callback( '/^( *)(.+)$/', static function ( $matches ) {
list( , $leadingSpaces, $sig ) = $matches;
return $leadingSpaces . '<span style="opacity: 0.6;">' . $sig . '</span>';
}, $signature );
$signature = preg_replace( '/([^ ].*)/', '<span style="opacity: 0.6;">$1</span>',
$signature );
$result = $this->previewMessage(
$params['type'],