Skip to content

Commit

Permalink
refactor: various compare !== 1 on preg_match()
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 27, 2024
1 parent 8c43868 commit 638a0d3
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion system/Cache/Handlers/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ protected function deleteFiles(string $path, bool $delDir = false, bool $htdocs
if ($filename !== '.' && $filename !== '..') {
if (is_dir($path . DIRECTORY_SEPARATOR . $filename) && $filename[0] !== '.') {
$this->deleteFiles($path . DIRECTORY_SEPARATOR . $filename, $delDir, $htdocs, $_level + 1);
} elseif (! $htdocs || in_array(preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename), [0, false], true)) {
} elseif (! $htdocs || preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename) !== 1) {
@unlink($path . DIRECTORY_SEPARATOR . $filename);
}
}
Expand Down
4 changes: 2 additions & 2 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3167,11 +3167,11 @@ protected function compileWhereHaving(string $qbKey): string
$op = $this->getOperator($condition);
if (
$op === false
|| in_array(preg_match(
|| preg_match(
'/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?<!\)))?(\)?)$/i',
$condition,
$matches
), [0, false], true)
) !== 1
) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion system/Database/MigrationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ protected function migrationFromFile(string $path, string $namespace)

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

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

Expand Down
2 changes: 1 addition & 1 deletion system/Helpers/filesystem_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function delete_files(string $path, bool $delDir = false, bool $htdocs = false,
continue;
}

if (! $htdocs || in_array(preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename), [0, false], true)) {
if (! $htdocs || preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename) !== 1) {
$isDir = $object->isDir();
if ($isDir && $delDir) {
rmdir($object->getPathname());
Expand Down
4 changes: 2 additions & 2 deletions system/Validation/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function is_not_unique($str, string $field, array $data): bool
if (
$whereField !== null && $whereField !== ''
&& $whereValue !== null && $whereValue !== ''
&& in_array(preg_match('/^\{(\w+)\}$/', $whereValue), [0, false], true)
&& preg_match('/^\{(\w+)\}$/', $whereValue) !== 1
) {
$row = $row->where($whereField, $whereValue);
}
Expand Down Expand Up @@ -198,7 +198,7 @@ public function is_unique($str, string $field, array $data): bool
if (
$ignoreField !== null && $ignoreField !== ''
&& $ignoreValue !== null && $ignoreValue !== ''
&& in_array(preg_match('/^\{(\w+)\}$/', $ignoreValue), [0, false], true)
&& preg_match('/^\{(\w+)\}$/', $ignoreValue) !== 1
) {
$row = $row->where("{$ignoreField} !=", $ignoreValue);
}
Expand Down
4 changes: 2 additions & 2 deletions system/Validation/StrictRules/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function is_not_unique($str, string $field, array $data): bool
if (
$whereField !== null && $whereField !== ''
&& $whereValue !== null && $whereValue !== ''
&& in_array(preg_match('/^\{(\w+)\}$/', $whereValue), [0, false], true)
&& preg_match('/^\{(\w+)\}$/', $whereValue) !== 1
) {
$row = $row->where($whereField, $whereValue);
}
Expand Down Expand Up @@ -224,7 +224,7 @@ public function is_unique($str, string $field, array $data): bool
if (
$ignoreField !== null && $ignoreField !== ''
&& $ignoreValue !== null && $ignoreValue !== ''
&& in_array(preg_match('/^\{(\w+)\}$/', $ignoreValue), [0, false], true)
&& preg_match('/^\{(\w+)\}$/', $ignoreValue) !== 1
) {
$row = $row->where("{$ignoreField} !=", $ignoreValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private function updateDocblock(string $variableName, string $camelCaseName, ?Fu
return;
}

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

Expand Down

0 comments on commit 638a0d3

Please sign in to comment.