Always use the strict equality flag when using in_array

Change-Id: Ia09f5aadc3bbf64645ba174f047e53db49e07925
This commit is contained in:
Ed Sanders 2023-06-06 13:08:00 +01:00
parent a937911b27
commit dda86f8ebf
6 changed files with 16 additions and 16 deletions

View file

@ -80,7 +80,7 @@ class ApiDiscussionToolsEdit extends ApiBase {
if ( $formToken ) {
$session = $this->getContext()->getRequest()->getSession();
$usedFormTokens = $session->get( $usedFormTokensKey ) ?? [];
if ( in_array( $formToken, $usedFormTokens ) ) {
if ( in_array( $formToken, $usedFormTokens, true ) ) {
$this->dieWithError( [ 'apierror-discussiontools-formtoken-used' ] );
}
}

View file

@ -840,7 +840,7 @@ class CommentFormatter {
public static function isLanguageRequiringReplyIcon( Language $lang ): bool {
$dtConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'discussiontools' );
$languages = $dtConfig->get( 'DiscussionTools_visualenhancements_reply_icon_languages' );
return in_array( $lang->getCode(), $languages );
return in_array( $lang->getCode(), $languages, true );
}
}

View file

@ -468,7 +468,7 @@ class CommentModifier {
$dataMw = json_decode( $node->getAttribute( 'data-mw' ) ?? '', true );
$wikitextLine = $dataMw['parts'][0] ?? null;
return $wikitextLine && is_string( $wikitextLine ) &&
in_array( $wikitextLine[0], [ '*', '#', ':', ';' ] );
in_array( $wikitextLine[0], [ '*', '#', ':', ';' ], true );
}
/**
@ -525,7 +525,7 @@ class CommentModifier {
$lastLine = end( $lines );
// If last line looks like a list item, add an empty line afterwards for the signature (T263217)
if ( $lastLine && in_array( $lastLine[0], [ '*', '#', ':', ';' ] ) ) {
if ( $lastLine && in_array( $lastLine[0], [ '*', '#', ':', ';' ], true ) ) {
$wikitext .= "\n";
// Trim the signature to prevent leading whitespace triggering preformatted text (T269188, T276612)
$signature = ltrim( $signature, ' ' );

View file

@ -42,7 +42,7 @@ class CommentUtils {
*/
public static function isBlockElement( Node $node ): bool {
return $node instanceof Element &&
in_array( strtolower( $node->tagName ), static::$blockElementTypes );
in_array( strtolower( $node->tagName ), static::$blockElementTypes, true );
}
private const SOL_TRANSPARENT_LINK_REGEX =
@ -66,7 +66,7 @@ class CommentUtils {
// But not empty nodes that are just the start of a non-empty template about-group. (T290940)
(
strtolower( $node->tagName ) === 'span' &&
in_array( 'mw:Transclusion', explode( ' ', $node->getAttribute( 'typeof' ) ?? '' ) ) &&
in_array( 'mw:Transclusion', explode( ' ', $node->getAttribute( 'typeof' ) ?? '' ), true ) &&
!static::htmlTrim( DOMCompat::getInnerHTML( $node ) ) &&
(
!$nextSibling || !( $nextSibling instanceof Element ) ||
@ -124,7 +124,7 @@ class CommentUtils {
return (
$node instanceof Comment ||
$node instanceof Element && (
in_array( strtolower( $node->tagName ), static::$noElementChildrenElementTypes ) ||
in_array( strtolower( $node->tagName ), static::$noElementChildrenElementTypes, true ) ||
// Thumbnail wrappers generated by MediaTransformOutput::linkWrap (T301427),
// for compatibility with TimedMediaHandler.
// There is no better way to detect them, and we can't insert markers here,
@ -132,7 +132,7 @@ class CommentUtils {
// TODO See if we can remove this condition when wgParserEnableLegacyMediaDOM=false
// is enabled everywhere.
(
in_array( strtolower( $node->tagName ), [ 'a', 'span' ] ) &&
in_array( strtolower( $node->tagName ), [ 'a', 'span' ], true ) &&
$node->firstChild &&
// We always step inside a child node so this can't be infinite, silly Phan
// @phan-suppress-next-line PhanInfiniteRecursion
@ -159,7 +159,7 @@ class CommentUtils {
strtolower( $node->tagName ) === 'hr' ||
// TemplateStyles followed by any of the others
(
in_array( strtolower( $node->tagName ), [ 'style', 'link' ] ) &&
in_array( strtolower( $node->tagName ), [ 'style', 'link' ], true ) &&
// @phan-suppress-next-line PhanInfiniteRecursion
$node->nextSibling && self::isCommentSeparator( $node->nextSibling )
) ||
@ -234,7 +234,7 @@ class CommentUtils {
do {
if (
$node instanceof Element &&
in_array( strtolower( $node->tagName ), $tagNames )
in_array( strtolower( $node->tagName ), $tagNames, true )
) {
return $node;
}
@ -297,7 +297,7 @@ class CommentUtils {
// 3.
if (
$node->getAttribute( 'typeof' ) &&
in_array( 'mw:Transclusion', explode( ' ', $node->getAttribute( 'typeof' ) ?? '' ) )
in_array( 'mw:Transclusion', explode( ' ', $node->getAttribute( 'typeof' ) ?? '' ), true )
) {
break;
}

View file

@ -170,7 +170,7 @@ class HookUtils {
return false;
}
if ( !in_array( $feature, static::FEATURES_CONFLICT_WITH_GADGET ) ) {
if ( !in_array( $feature, static::FEATURES_CONFLICT_WITH_GADGET, true ) ) {
return false;
}
@ -308,7 +308,7 @@ class HookUtils {
}
if (
( $feature ? in_array( $feature, (array)$abtest ) : (bool)$abtest ) &&
( $feature ? in_array( $feature, (array)$abtest, true ) : (bool)$abtest ) &&
$user->isRegistered()
) {
return $user->getId() % 2 == 0 ? 'test' : 'control';
@ -393,7 +393,7 @@ class HookUtils {
// the hook onGetActionName to override the action for the tool on empty pages.
// If we tried to call it here it would set up infinite recursion (T312689)
$feature !== static::NEWTOPICTOOL &&
!in_array( $output->getActionName(), [ 'view', 'edit', 'submit' ] )
!in_array( $output->getActionName(), [ 'view', 'edit', 'submit' ], true )
) {
return false;
}

View file

@ -189,11 +189,11 @@ class ResourceLoaderData {
$localPath = $info['localBasePath'] . '/' . $path;
$data = json_decode( file_get_contents( $localPath ), true );
foreach ( $data as $case ) {
if ( isset( $case['name'] ) && in_array( $case['name'], $skipTests[$path] ?? [] ) ) {
if ( isset( $case['name'] ) && in_array( $case['name'], $skipTests[$path] ?? [], true ) ) {
continue;
}
foreach ( $case as $key => $val ) {
if ( in_array( $key, $keys ) && is_string( $val ) ) {
if ( in_array( $key, $keys, true ) && is_string( $val ) ) {
if ( str_ends_with( $val, '.json' ) ) {
$info['packageFiles'][] = substr( $val, strlen( '../' ) );
} elseif ( str_ends_with( $val, '.html' ) ) {