Skip to content

Commit

Permalink
chore: use str_contains (#3841)
Browse files Browse the repository at this point in the history
  • Loading branch information
datlechin authored Sep 14, 2023
1 parent ee34217 commit be9eb16
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions extensions/mentions/src/Formatter/UnparsePostMentions.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function updatePostMentionTags(mixed $context, string $xml): string
$attributes['displayname'] = $this->translator->trans('core.lib.username.deleted_text');
}

if (strpos($attributes['displayname'], '"#') !== false) {
if (str_contains($attributes['displayname'], '"#')) {
$attributes['displayname'] = preg_replace('/"#[a-z]{0,3}[0-9]+/', '_', $attributes['displayname']);
}

Expand All @@ -62,7 +62,7 @@ protected function unparsePostMentionTags(string $xml): string
{
$tagName = 'POSTMENTION';

if (strpos($xml, $tagName) === false) {
if (! str_contains($xml, $tagName)) {
return $xml;
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/mentions/src/Formatter/UnparseTagMentions.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function unparseTagMentionTags(string $xml): string
{
$tagName = 'TAGMENTION';

if (strpos($xml, $tagName) === false) {
if (! str_contains($xml, $tagName)) {
return $xml;
}

Expand Down
4 changes: 2 additions & 2 deletions extensions/mentions/src/Formatter/UnparseUserMentions.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function updateUserMentionTags(mixed $context, string $xml): string

$attributes['displayname'] = $user?->display_name ?? $this->translator->trans('core.lib.username.deleted_text');

if (strpos($attributes['displayname'], '"#') !== false) {
if (str_contains($attributes['displayname'], '"#')) {
$attributes['displayname'] = preg_replace('/"#[a-z]{0,3}[0-9]+/', '_', $attributes['displayname']);
}

Expand All @@ -55,7 +55,7 @@ protected function unparseUserMentionTags(string $xml): string
{
$tagName = 'USERMENTION';

if (strpos($xml, $tagName) === false) {
if (! str_contains($xml, $tagName)) {
return $xml;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function handle(RequireExtension $command): array
$packageName = $command->package;

// Auto append :* if not requiring a specific version.
if (strpos($packageName, ':') === false) {
if (! str_contains($packageName, ':')) {
$packageName .= ':*';
}

Expand Down

0 comments on commit be9eb16

Please sign in to comment.