浏览代码

Strict in_array()

Visman 4 年之前
父节点
当前提交
c9cff3bf8f

+ 2 - 2
app/Core/DB.php

@@ -59,7 +59,7 @@ class DB extends PDO
         $type = \strstr($dsn, ':', true);
         if (
             ! $type
-            || ! \in_array($type, PDO::getAvailableDrivers())
+            || ! \in_array($type, PDO::getAvailableDrivers(), true)
             || ! \is_file(__DIR__ . '/DB/' . \ucfirst($type) . '.php')
         ) {
             throw new PDOException("Driver isn't found for '$type'");
@@ -102,7 +102,7 @@ class DB extends PDO
         foreach ($options as $key => $value) {
            if (
                ! isset($verify[$key])
-               || ! \in_array($value, $verify[$key])
+               || ! \in_array($value, $verify[$key], true)
             ) {
                return false;
            }

+ 1 - 1
app/Core/Image.php

@@ -113,7 +113,7 @@ class Image extends File
         }
 
         if (\is_array($info['extension'])) {
-            if (\in_array($this->ext, $info['extension'])) {
+            if (\in_array($this->ext, $info['extension'], true)) {
                 $info['extension'] = $this->ext;
             } else {
                 $info['extension'] = \reset($info['extension']); // ???? выбор расширения?

+ 2 - 2
app/Core/Mail.php

@@ -108,7 +108,7 @@ class Mail
             ];
             $this->EOL = "\r\n";
         } else {
-            $this->EOL = \in_array($eol, ["\r\n", "\n", "\r"]) ? $eol : \PHP_EOL;
+            $this->EOL = \in_array($eol, ["\r\n", "\n", "\r"], true) ? $eol : \PHP_EOL;
         }
     }
 
@@ -630,7 +630,7 @@ class Mail
 
         if (
             null !== $code
-            && ! \in_array($return, $code)
+            && ! \in_array($return, $code, true)
         ) {
             throw new SmtpException("Unable to send email. Response of mail server: \"{$this->response}\"");
         }

+ 1 - 1
app/Core/Secury.php

@@ -31,7 +31,7 @@ class Secury
         ) {
             throw new InvalidArgumentException('Algorithm and salt can not be empty');
         }
-        if (! \in_array($hmac['algo'], \hash_hmac_algos())) {
+        if (! \in_array($hmac['algo'], \hash_hmac_algos(), true)) {
             throw new UnexpectedValueException('Algorithm not supported');
         }
         $this->hmac = $hmac;

+ 1 - 1
app/Models/Group/Model.php

@@ -39,7 +39,7 @@ class Model extends DataModel
             $this->c->GROUP_MEMBER
         ];
 
-        return ! \in_array($this->g_id, $notDeleted) && $this->g_id !== $this->c->config->i_default_user_group;
+        return ! \in_array($this->g_id, $notDeleted, true) && $this->g_id !== $this->c->config->i_default_user_group;
     }
 
     /**

+ 2 - 2
app/Models/Pages/Admin/Groups.php

@@ -34,11 +34,11 @@ class Groups extends Admin
         foreach ($this->c->groups->getList() as $key => $group) {
             $groupsList[$key] = [$group->g_title, $group->linkEdit, $group->linkDelete];
 
-            if (! \in_array($group->g_id, $notForNew)) {
+            if (! \in_array($group->g_id, $notForNew, true)) {
                 $groupsNew[$key] = $group->g_title;
             }
             if (
-                ! \in_array($group->g_id, $notForDefault)
+                ! \in_array($group->g_id, $notForDefault, true)
                 && 0 == $group->g_moderator
             ) {
                 $groupsDefault[$key] = $group->g_title;

+ 1 - 1
app/Models/Pages/Admin/Install.php

@@ -1160,7 +1160,7 @@ class Install extends Admin
             'o_regs_report'           => 0,
             'i_default_email_setting' => 2,
             'o_mailing_list'          => $v->email,
-            'o_avatars'               => \in_array(\strtolower(@\ini_get('file_uploads')), ['on', 'true', '1']) ? 1 : 0,
+            'o_avatars'               => \in_array(\strtolower(@\ini_get('file_uploads')), ['on', 'true', '1'], true) ? 1 : 0,
             'o_avatars_dir'           => '/img/avatars',
             'i_avatars_width'         => 60,
             'i_avatars_height'        => 60,

+ 1 - 1
app/Models/Pages/Moderate.php

@@ -136,7 +136,7 @@ class Moderate extends Page
                     $v->addError('Nowhere to move');
                 } elseif (
                     1 === $v->confirm
-                    && ! \in_array($v->destination, $this->listOfIndexes)
+                    && ! \in_array($v->destination, $this->listOfIndexes, true)
                 ) {
                     $v->addError('Invalid destination');
                 } elseif (