Skip to content

Commit

Permalink
in_array MUST be strict
Browse files Browse the repository at this point in the history
  • Loading branch information
GlazerMann authored Dec 11, 2024
2 parents daff561 + 057931a commit f624904
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static function (array $matches): string {
public function prepare(): void
{
set_time_limit(120);
if (in_array($this->wikiname(), TEMPLATES_WE_PROCESS) || in_array($this->wikiname(), TEMPLATES_WE_SLIGHTLY_PROCESS, true)) {
if (in_array($this->wikiname(), TEMPLATES_WE_PROCESS, true) || in_array($this->wikiname(), TEMPLATES_WE_SLIGHTLY_PROCESS, true)) {
// Clean up bad data
if (in_array($this->get('title'), ALWAYS_BAD_TITLES, true)) {
$this->set('title', '');
Expand Down Expand Up @@ -3771,7 +3771,7 @@ public function get_unpaywall_url(string $doi): string

public function clean_google_books(): void
{
if (!in_array(WIKI_BASE, ['en', 'simple', 'mdwiki'])) { // TODO - support other countries
if (!in_array(WIKI_BASE, ['en', 'simple', 'mdwiki'], true)) { // TODO - support other countries
return;
}
foreach (ALL_URL_TYPES as $url_type) {
Expand Down Expand Up @@ -6103,20 +6103,20 @@ public function tidy_parameter(string $param): void
}
}
if ($this->wikiname() === 'cite book' && $the_title === '') {
if (in_array($this->get($param), ['Automata, Languages and Programming'])) {
if (in_array($this->get($param), ['Automata, Languages and Programming'], true)) {
$this->rename($param, 'title');
return;
}
}
if ($this->wikiname() === 'cite book' && $this->blank('chapter')) {
/**
if (in_array($this->get($param), [])) {
if (in_array($this->get($param), [], true)) {
$this->rename('title', 'chapter');
$this->rename($param, 'title');
return;
}
*/
if (in_array($this->get('series'), ['Lecture Notes in Computer Science', 'Klassische Texte der Wissenschaft'])) {
if (in_array($this->get('series'), ['Lecture Notes in Computer Science', 'Klassische Texte der Wissenschaft'], true)) {
$this->rename('title', 'chapter');
$this->rename($param, 'title');
return;
Expand Down
2 changes: 1 addition & 1 deletion Zotero.php
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ public static function process_zotero_response(string $zotero_response, Template
if (isset($result->thesisType) && $template->blank(['type', 'medium', 'degree'])) {
$type = (string) $result->thesisType;
$type = str_replace('.', '', $type);
if (in_array($type, ['PhD', 'MS', 'MA', 'MFA', 'MBA', 'EdD', 'BSN', 'DMin', 'DDiv'])) {
if (in_array($type, ['PhD', 'MS', 'MA', 'MFA', 'MBA', 'EdD', 'BSN', 'DMin', 'DDiv'], true)) {
$template->add_if_new('type', $type); // Prefer type since it exists in cite journal too
}
}
Expand Down
2 changes: 1 addition & 1 deletion apiFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ function expand_by_doi(Template $template, bool $force = false): void {
if (preg_match(REGEXP_DOI_ISSN_ONLY, $doi)) {
return;
}
if (in_array($doi, BAD_DOI_ARRAY)) { // Really bad ones that do not really exist at all
if (isset(BAD_DOI_ARRAY[$doi])) { // Really bad ones that do not really exist at all
return;
}
if ($doi && preg_match('~^10\.2307/(\d+)$~', $doi)) {
Expand Down
2 changes: 1 addition & 1 deletion expandFns.php
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ function straighten_quotes(string $str, bool $do_more): string { // (?<!\') and
$str = safe_preg_replace('~&[lr]saquo;|[\x{2039}\x{203A}]|[‹›]~u', "'", $str); // Websites tiles: Jobs ›› Iowa ›› Cows ›› Ames
}
$str = safe_preg_replace('~&#822[013];|[\x{201C}-\x{201F}]|&[rlb][d]?quo;~u', '"', $str);
if(in_array(WIKI_BASE, ['en', 'simple', 'mdwiki']) && (
if(in_array(WIKI_BASE, ['en', 'simple', 'mdwiki'], true) && (
(mb_strpos($str, '&raquo;') !== false && mb_strpos($str, '&laquo;') !== false) ||
(mb_strpos($str, '\x{00AB}') !== false && mb_strpos($str, '\x{00AB}') !== false) ||
(mb_strpos($str, '«') !== false && mb_strpos($str, '»') !== false))) { // Only replace double angle quotes if some of both // Websites tiles: Jobs » Iowa » Cows » Ames
Expand Down
2 changes: 1 addition & 1 deletion process_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

if (isset($argv[1])) {
$pages = $argv[1];
if (in_array($pages, ['page_list.txt', 'page_list2.txt'])) {
if (in_array($pages, ['page_list.txt', 'page_list2.txt'], true)) {
$pages = trim((string) file_get_contents($pages));
}
} elseif (isset($_GET["page"])) {
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/constantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,11 @@ public function testDoubleMap(): void {
if ($mappedp === 's#cid') {
$mappedp = 's2cid';
}
if (!in_array($mapped, $okay_to_be_bad)) {
if (!in_array($mappedp, PARAMETER_LIST)) {
if (!in_array($mapped, $okay_to_be_bad, true)) {
if (!in_array($mappedp, PARAMETER_LIST, true)) {
$errors .= ' mapped to non-existant parameter: ' . $map_me . '/' . $mapped . ' ';
}
if (in_array($mappedp, DEAD_PARAMETERS) || in_array($mapped, DEAD_PARAMETERS)) {
if (in_array($mappedp, DEAD_PARAMETERS, true) || in_array($mapped, DEAD_PARAMETERS, true)) {
$errors .= ' mapped to dead parameter: ' . $map_me . '/' . $mapped . ' ';
}
}
Expand Down

0 comments on commit f624904

Please sign in to comment.