Skip to content

Commit a709cbe

Browse files
committed
various compare !== 1 on preg_match()
1 parent 8c43868 commit a709cbe

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

system/Cache/Handlers/FileHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ protected function deleteFiles(string $path, bool $delDir = false, bool $htdocs
308308
if ($filename !== '.' && $filename !== '..') {
309309
if (is_dir($path . DIRECTORY_SEPARATOR . $filename) && $filename[0] !== '.') {
310310
$this->deleteFiles($path . DIRECTORY_SEPARATOR . $filename, $delDir, $htdocs, $_level + 1);
311-
} elseif (! $htdocs || in_array(preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename), [0, false], true)) {
311+
} elseif (! $htdocs || preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename) !== 1) {
312312
@unlink($path . DIRECTORY_SEPARATOR . $filename);
313313
}
314314
}

system/Database/BaseBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,11 +3167,11 @@ protected function compileWhereHaving(string $qbKey): string
31673167
$op = $this->getOperator($condition);
31683168
if (
31693169
$op === false
3170-
|| in_array(preg_match(
3170+
|| preg_match(
31713171
'/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?<!\)))?(\)?)$/i',
31723172
$condition,
31733173
$matches
3174-
), [0, false], true)
3174+
) !== 1
31753175
) {
31763176
continue;
31773177
}

system/Database/MigrationRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ protected function migrationFromFile(string $path, string $namespace)
450450

451451
$filename = basename($path, '.php');
452452

453-
if (in_array(preg_match($this->regex, $filename), [0, false], true)) {
453+
if (preg_match($this->regex, $filename) !== 1) {
454454
return false;
455455
}
456456

system/Helpers/filesystem_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function delete_files(string $path, bool $delDir = false, bool $htdocs = false,
166166
continue;
167167
}
168168

169-
if (! $htdocs || in_array(preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename), [0, false], true)) {
169+
if (! $htdocs || preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename) !== 1) {
170170
$isDir = $object->isDir();
171171
if ($isDir && $delDir) {
172172
rmdir($object->getPathname());

system/Validation/Rules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function is_not_unique($str, string $field, array $data): bool
140140
if (
141141
$whereField !== null && $whereField !== ''
142142
&& $whereValue !== null && $whereValue !== ''
143-
&& in_array(preg_match('/^\{(\w+)\}$/', $whereValue), [0, false], true)
143+
&& preg_match('/^\{(\w+)\}$/', $whereValue) !== 1
144144
) {
145145
$row = $row->where($whereField, $whereValue);
146146
}
@@ -198,7 +198,7 @@ public function is_unique($str, string $field, array $data): bool
198198
if (
199199
$ignoreField !== null && $ignoreField !== ''
200200
&& $ignoreValue !== null && $ignoreValue !== ''
201-
&& in_array(preg_match('/^\{(\w+)\}$/', $ignoreValue), [0, false], true)
201+
&& preg_match('/^\{(\w+)\}$/', $ignoreValue) !== 1
202202
) {
203203
$row = $row->where("{$ignoreField} !=", $ignoreValue);
204204
}

system/Validation/StrictRules/Rules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function is_not_unique($str, string $field, array $data): bool
164164
if (
165165
$whereField !== null && $whereField !== ''
166166
&& $whereValue !== null && $whereValue !== ''
167-
&& in_array(preg_match('/^\{(\w+)\}$/', $whereValue), [0, false], true)
167+
&& preg_match('/^\{(\w+)\}$/', $whereValue) !== 1
168168
) {
169169
$row = $row->where($whereField, $whereValue);
170170
}
@@ -224,7 +224,7 @@ public function is_unique($str, string $field, array $data): bool
224224
if (
225225
$ignoreField !== null && $ignoreField !== ''
226226
&& $ignoreValue !== null && $ignoreValue !== ''
227-
&& in_array(preg_match('/^\{(\w+)\}$/', $ignoreValue), [0, false], true)
227+
&& preg_match('/^\{(\w+)\}$/', $ignoreValue) !== 1
228228
) {
229229
$row = $row->where("{$ignoreField} !=", $ignoreValue);
230230
}

utils/src/Rector/UnderscoreToCamelCaseVariableNameRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private function updateDocblock(string $variableName, string $camelCaseName, ?Fu
178178
return;
179179
}
180180

181-
if (in_array(preg_match(sprintf(self::PARAM_NAME_REGEX, $variableName), $docCommentText), [0, false], true)) {
181+
if (preg_match(sprintf(self::PARAM_NAME_REGEX, $variableName), $docCommentText) !== 1) {
182182
return;
183183
}
184184

0 commit comments

Comments
 (0)