Visman пре 5 година
родитељ
комит
b88bdd2b31

+ 1 - 1
app/Core/DB.php

@@ -140,7 +140,7 @@ class DB extends PDO
                 }
 
                 $type = empty($matches[2]) ? 's' : $matches[2];
-                $key = isset($matches[4]) ? $matches[4] : (isset($matches[3]) ? $matches[3] : $idxIn++);
+                $key = $matches[4] ?? ($matches[3] ?? $idxIn++);
                 $value = $this->getValue($key, $params);
 
                 switch ($type) {

+ 1 - 1
app/Core/DB/mysql.php

@@ -547,7 +547,7 @@ class Mysql
                 $result[$tableNoPref] = [];
             }
             $type = \strtolower($row['DATA_TYPE']);
-            $result[$tableNoPref][$row['COLUMN_NAME']] = isset($this->types[$type]) ? $this->types[$type] : 's';
+            $result[$tableNoPref][$row['COLUMN_NAME']] = $this->types[$type] ?? 's';
         }
         return $result;
     }

+ 4 - 4
app/Core/ErrorHandler.php

@@ -216,12 +216,12 @@ EOT;
                         continue;
                     }
 
-                    $line = isset($cur['file']) ? $cur['file'] : '-';
-                    $line .= '(' . (isset($cur['line']) ? $cur['line'] : '-') . '): ';
+                    $line = $cur['file'] ?? '-';
+                    $line .= '(' . ($cur['line'] ?? '-') . '): ';
                     if (isset($cur['class'])) {
                         $line .= $cur['class'] . $cur['type'];
                     }
-                    $line .= (isset($cur['function']) ? $cur['function'] : 'unknown') . '(';
+                    $line .= ($cur['function'] ?? 'unknown') . '(';
 
                     if (! empty($cur['args']) && \is_array($cur['args'])) {
                         $comma = '';
@@ -278,7 +278,7 @@ EOT;
      */
     protected function message(array $error): string
     {
-        $type = isset($this->type[$error['type']]) ? $this->type[$error['type']] : $this->type[0];
+        $type = $this->type[$error['type']] ?? $this->type[0];
         $file = \str_replace($this->hidePath, '...', $error['file']);
         return "PHP {$type}: \"{$error['message']}\" in {$file}:[{$error['line']}]";
     }

+ 1 - 1
app/Core/Files.php

@@ -187,7 +187,7 @@ class Files
             } else {
                 $type = 0;
             }
-            return isset($this->imageType[$type]) ? $this->imageType[$type] : null;
+            return $this->imageType[$type] ?? null;
         }
 
         return $file instanceof Image ? $file->ext() : null;

+ 2 - 2
app/Core/Validator.php

@@ -184,7 +184,7 @@ class Validator
                         throw new RuntimeException($vs[0] . ' validator not found');
                      }
                  }
-                 $rules[$vs[0]] = isset($vs[1]) ? $vs[1] : '';
+                 $rules[$vs[0]] = $vs[1] ?? '';
             }
             if (isset($suffix)) {
                 if (isset($this->rules[$field]['array']) && ! \is_array($this->rules[$field]['array'])) {
@@ -371,7 +371,7 @@ class Validator
         \extract($vars);
 
         // псевдоним имени поля
-        $alias = isset($this->aliases[$field]) ? $this->aliases[$field] : $field;
+        $alias = $this->aliases[$field] ?? $field;
 
         // текст ошибки
         if (isset($this->messages[$field . '.' . $rule])) {

+ 1 - 1
app/Models/ManagerModel.php

@@ -13,7 +13,7 @@ class ManagerModel extends Model
 
     public function get($key)
     {
-        return isset($this->repository[$key]) ? $this->repository[$key] : null;
+        return $this->repository[$key] ?? null;
     }
 
     public function set($key, $value): self

+ 1 - 1
app/Models/Model.php

@@ -144,7 +144,7 @@ class Model
         } elseif (\method_exists($this, $method = 'get' . $name)) {
             return $this->zAttrsCalc[$name] = $this->$method();
         } else {
-            return isset($this->zAttrs[$name]) ? $this->zAttrs[$name] : null;
+            return $this->zAttrs[$name] ?? null;
         }
     }
 

+ 13 - 13
app/Models/Pages/Admin/Bans.php

@@ -158,25 +158,25 @@ class Bans extends Admin
             'type'      => 'text',
             'maxlength' => 25,
             'caption'   => \ForkBB\__('Username label'),
-            'value'     => isset($data['username']) ? $data['username'] : null,
+            'value'     => $data['username'] ?? null,
         ];
         $fields['ip'] = [
             'type'      => 'text',
             'maxlength' => 40,
             'caption'   => \ForkBB\__('IP label'),
-            'value'     => isset($data['ip']) ? $data['ip'] : null,
+            'value'     => $data['ip'] ?? null,
         ];
         $fields['email'] = [
             'type'      => 'text',
             'maxlength' => 80,
             'caption'   => \ForkBB\__('E-mail label'),
-            'value'     => isset($data['email']) ? $data['email'] : null,
+            'value'     => $data['email'] ?? null,
         ];
         $fields['message'] = [
             'type'      => 'text',
             'maxlength' => 255,
             'caption'   => \ForkBB\__('Message label'),
-            'value'     => isset($data['message']) ? $data['message'] : null,
+            'value'     => $data['message'] ?? null,
         ];
         $fields['between1'] = [
             'class' => 'between',
@@ -186,14 +186,14 @@ class Bans extends Admin
             'class'     => 'bstart',
             'type'      => 'text',
             'maxlength' => 100,
-            'value'     => isset($data['expire_1']) ? $data['expire_1'] : null,
+            'value'     => $data['expire_1'] ?? null,
             'caption'   => \ForkBB\__('Expire date label'),
         ];
         $fields['expire_2'] = [
             'class'     => 'bend',
             'type'      => 'text',
             'maxlength' => 100,
-            'value'     => isset($data['expire_2']) ? $data['expire_2'] : null,
+            'value'     => $data['expire_2'] ?? null,
         ];
         $fields[] = [
             'type' => 'endwrap',
@@ -218,7 +218,7 @@ class Bans extends Admin
                 'email'    => \ForkBB\__('Order by e-mail'),
                 'expire'   => \ForkBB\__('Order by expire'),
             ],
-            'value'   => isset($data['order_by']) ? $data['order_by'] : 'id',
+            'value'   => $data['order_by'] ?? 'id',
             'caption' => \ForkBB\__('Order by label'),
         ];
         $fields['direction'] = [
@@ -228,7 +228,7 @@ class Bans extends Admin
                 'ASC'  => \ForkBB\__('Ascending'),
                 'DESC' => \ForkBB\__('Descending'),
             ],
-            'value'   => isset($data['direction']) ? $data['direction'] : 'DESC',
+            'value'   => $data['direction'] ?? 'DESC',
         ];
         $fields[] = [
             'type' => 'endwrap',
@@ -273,21 +273,21 @@ class Bans extends Admin
                 'maxlength' => 25,
                 'caption'   => \ForkBB\__('Username label'),
                 'info'      => $this->banCount < 1 ? \ForkBB\__('Username help') : null,
-                'value'     => isset($data['username']) ? $data['username'] : null,
+                'value'     => $data['username'] ?? null,
             ];
             $fields['ip'] = [
                 'type'      => 'text',
                 'maxlength' => 255,
                 'caption'   => \ForkBB\__('IP label'),
                 'info'      => \ForkBB\__('IP help'),
-                'value'     => isset($data['ip']) ? $data['ip'] : null,
+                'value'     => $data['ip'] ?? null,
             ];
             $fields['email'] = [
                 'type'      => 'text',
                 'maxlength' => 80,
                 'caption'   => \ForkBB\__('E-mail label'),
                 'info'      => \ForkBB\__('E-mail help'),
-                'value'     => isset($data['email']) ? $data['email'] : null,
+                'value'     => $data['email'] ?? null,
             ];
             $form['sets']['ban-attrs'] = [
                 'legend' => $this->formBanSubHead,
@@ -301,14 +301,14 @@ class Bans extends Admin
             'maxlength' => 255,
             'caption'   => \ForkBB\__('Ban message label'),
             'info'      => \ForkBB\__('Ban message help'),
-            'value'     => isset($data['message']) ? $data['message'] : null,
+            'value'     => $data['message'] ?? null,
         ];
         $fields['expire'] = [
             'type'      => 'text',
             'maxlength' => 100,
             'caption'   => \ForkBB\__('Expire date label'),
             'info'      => \ForkBB\__('Expire date help'),
-            'value'     => isset($data['expire']) ? $data['expire'] : null,
+            'value'     => $data['expire'] ?? null,
         ];
 /*
         $yn     = [1 => \ForkBB\__('Yes'), 0 => \ForkBB\__('No')];

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

@@ -186,7 +186,7 @@ class Groups extends Admin
             $next = false;
         // продолжение редактирования/создания
         } else {
-            $gid  = (int) (isset($args['id']) ? $args['id'] : $args['base']);
+            $gid  = (int) ($args['id'] ?? $args['base']);
             $next = true;
         }
 

+ 21 - 21
app/Models/Pages/Admin/Users/View.php

@@ -163,25 +163,25 @@ class View extends Users
             'type'      => 'text',
             'maxlength' => 25,
             'caption'   => \ForkBB\__('Username label'),
-            'value'     => isset($data['username']) ? $data['username'] : null,
+            'value'     => $data['username'] ?? null,
         ];
         $fields['email'] = [
             'type'      => 'text',
             'maxlength' => 80,
             'caption'   => \ForkBB\__('E-mail address label'),
-            'value'     => isset($data['email']) ? $data['email'] : null,
+            'value'     => $data['email'] ?? null,
         ];
         $fields['title'] = [
             'type'      => 'text',
             'maxlength' => 50,
             'caption'   => \ForkBB\__('Title label'),
-            'value'     => isset($data['title']) ? $data['title'] : null,
+            'value'     => $data['title'] ?? null,
         ];
         $fields['realname'] = [
             'type'      => 'text',
             'maxlength' => 40,
             'caption'   => \ForkBB\__('Real name label'),
-            'value'     => isset($data['realname']) ? $data['realname'] : null,
+            'value'     => $data['realname'] ?? null,
         ];
         $genders = [
             0 => \ForkBB\__('Do not display'),
@@ -191,7 +191,7 @@ class View extends Users
         $fields['gender'] = [
 #            'class'   => 'block',
             'type'    => 'radio',
-            'value'   => isset($data['gender']) ? $data['gender'] : -1,
+            'value'   => $data['gender'] ?? -1,
             'values'  => $genders,
             'caption' => \ForkBB\__('Gender label'),
         ];
@@ -200,25 +200,25 @@ class View extends Users
             'type'      => 'text',
             'maxlength' => 100,
             'caption'   => \ForkBB\__('Website label'),
-            'value'     => isset($data['url']) ? $data['url'] : null,
+            'value'     => $data['url'] ?? null,
         ];
         $fields['location'] = [
             'type'      => 'text',
             'maxlength' => 30,
             'caption'   => \ForkBB\__('Location label'),
-            'value'     => isset($data['location']) ? $data['location'] : null,
+            'value'     => $data['location'] ?? null,
         ];
         $fields['signature'] = [
             'type'      => 'text',
             'maxlength' => 512,
             'caption'   => \ForkBB\__('Signature label'),
-            'value'     => isset($data['signature']) ? $data['signature'] : null,
+            'value'     => $data['signature'] ?? null,
         ];
         $fields['admin_note'] = [
             'type'      => 'text',
             'maxlength' => 30,
             'caption'   => \ForkBB\__('Admin note label'),
-            'value'     => isset($data['admin_note']) ? $data['admin_note'] : null,
+            'value'     => $data['admin_note'] ?? null,
         ];
         $fields['between1'] = [
             'class' => 'between',
@@ -229,7 +229,7 @@ class View extends Users
             'class'   => 'bstart',
             'min'     => 0,
             'max'     => 9999999999,
-            'value'   => isset($data['num_posts_1']) ? $data['num_posts_1'] : null,
+            'value'   => $data['num_posts_1'] ?? null,
             'caption' => \ForkBB\__('Posts label'),
         ];
         $fields['num_posts_2'] = [
@@ -237,7 +237,7 @@ class View extends Users
             'class'   => 'bend',
             'min'     => 0,
             'max'     => 9999999999,
-            'value'   => isset($data['num_posts_2']) ? $data['num_posts_2'] : null,
+            'value'   => $data['num_posts_2'] ?? null,
         ];
         $fields[] = [
             'type' => 'endwrap',
@@ -250,14 +250,14 @@ class View extends Users
             'class'     => 'bstart',
             'type'      => 'text',
             'maxlength' => 100,
-            'value'     => isset($data['last_post_1']) ? $data['last_post_1'] : null,
+            'value'     => $data['last_post_1'] ?? null,
             'caption'   => \ForkBB\__('Last post label'),
         ];
         $fields['last_post_2'] = [
             'class'     => 'bend',
             'type'      => 'text',
             'maxlength' => 100,
-            'value'     => isset($data['last_post_2']) ? $data['last_post_2'] : null,
+            'value'     => $data['last_post_2'] ?? null,
         ];
         $fields[] = [
             'type' => 'endwrap',
@@ -270,14 +270,14 @@ class View extends Users
             'class'     => 'bstart',
             'type'      => 'text',
             'maxlength' => 100,
-            'value'     => isset($data['last_visit_1']) ? $data['last_visit_1'] : null,
+            'value'     => $data['last_visit_1'] ?? null,
             'caption'   => \ForkBB\__('Last visit label'),
         ];
         $fields['last_visit_2'] = [
             'class'     => 'bend',
             'type'      => 'text',
             'maxlength' => 100,
-            'value'     => isset($data['last_visit_2']) ? $data['last_visit_2'] : null,
+            'value'     => $data['last_visit_2'] ?? null,
         ];
         $fields[] = [
             'type' => 'endwrap',
@@ -290,14 +290,14 @@ class View extends Users
             'class'     => 'bstart',
             'type'      => 'text',
             'maxlength' => 100,
-            'value'     => isset($data['registered_1']) ? $data['registered_1'] : null,
+            'value'     => $data['registered_1'] ?? null,
             'caption'   => \ForkBB\__('Registered label'),
         ];
         $fields['registered_2'] = [
             'class'     => 'bend',
             'type'      => 'text',
             'maxlength' => 100,
-            'value'     => isset($data['registered_2']) ? $data['registered_2'] : null,
+            'value'     => $data['registered_2'] ?? null,
         ];
         $fields[] = [
             'type' => 'endwrap',
@@ -323,7 +323,7 @@ class View extends Users
                 'last_visit' => \ForkBB\__('Order by last visit'),
                 'registered' => \ForkBB\__('Order by registered'),
             ],
-            'value'   => isset($data['order_by']) ? $data['order_by'] : 'registered',
+            'value'   => $data['order_by'] ?? 'registered',
             'caption' => \ForkBB\__('Order by label'),
         ];
         $fields['direction'] = [
@@ -333,7 +333,7 @@ class View extends Users
                 'ASC'  => \ForkBB\__('Ascending'),
                 'DESC' => \ForkBB\__('Descending'),
             ],
-            'value'   => isset($data['direction']) ? $data['direction'] : 'DESC',
+            'value'   => $data['direction'] ?? 'DESC',
         ];
         $fields[] = [
             'type' => 'endwrap',
@@ -341,7 +341,7 @@ class View extends Users
         $fields['user_group'] = [
             'type'    => 'select',
             'options' => $this->groups(),
-            'value'   => isset($data['user_group']) ? $data['user_group'] : -1,
+            'value'   => $data['user_group'] ?? -1,
             'caption' => \ForkBB\__('User group label'),
         ];
 
@@ -381,7 +381,7 @@ class View extends Users
             'type'      => 'text',
             'maxlength' => 49,
             'caption'   => \ForkBB\__('IP address label'),
-            'value'     => isset($data['ip']) ? $data['ip'] : null,
+            'value'     => $data['ip'] ?? null,
             'required'  => true,
         ];
         $form['sets']['ip'] = [

+ 3 - 3
app/Models/Pages/Auth.php

@@ -65,7 +65,7 @@ class Auth extends Page
             $this->fIswev = $v->getErrors();
         }
 
-        $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
+        $ref = $_SERVER['HTTP_REFERER'] ?? '';
 
         $this->fIndex     = 'login';
         $this->nameTpl    = 'login';
@@ -74,7 +74,7 @@ class Auth extends Page
         $this->titles     = \ForkBB\__('Login');
         $this->regLink    = $this->c->config->o_regs_allow == '1' ? $this->c->Router->link('Register') : null;
 
-        $username         = $v ? $v->username : (isset($args['_username']) ? $args['_username'] : '');
+        $username         = $v ? $v->username : ($args['_username'] ?? '');
         $save             = $v ? $v->save : 1;
         $redirect         = $v ? $v->redirect : $this->c->Router->validate($ref, 'Index');
         $this->form       = $this->formLogin($username, $save, $redirect);
@@ -254,7 +254,7 @@ class Auth extends Page
         $this->robots     = 'noindex';
         $this->titles     = \ForkBB\__('Passphrase reset');
 
-        $email            = $v ? $v->email : (isset($args['_email']) ? $args['_email'] : '');
+        $email            = $v ? $v->email : ($args['_email'] ?? '');
         $this->form       = $this->formForget($email);
 
         return $this;

+ 5 - 5
app/Models/Pages/PostFormTrait.php

@@ -20,7 +20,7 @@ trait PostFormTrait
      */
     protected function messageForm(array $args, Model $model, string $marker, bool $editPost = false, bool $editSubject = false, bool $quickReply = false): array
     {
-        $vars = isset($args['_vars']) ? $args['_vars'] : null;
+        $vars = $args['_vars'] ?? null;
         unset($args['_vars']);
 
         $autofocus = $quickReply ? null : true;
@@ -54,7 +54,7 @@ trait PostFormTrait
                 'caption'   => \ForkBB\__('Username'),
                 'required'  => true,
                 'pattern'   => '^.{2,25}$',
-                'value'     => isset($vars['username']) ? $vars['username'] : null,
+                'value'     => $vars['username'] ?? null,
                 'autofocus' => $autofocus,
             ];
             $fieldset['email'] = [
@@ -64,7 +64,7 @@ trait PostFormTrait
                 'caption'   => \ForkBB\__('Email'),
                 'required'  => '1' == $this->c->config->p_force_guest_email,
                 'pattern'   => '.+@.+',
-                'value'     => isset($vars['email']) ? $vars['email'] : null,
+                'value'     => $vars['email'] ?? null,
             ];
             $autofocus = null;
         }
@@ -76,7 +76,7 @@ trait PostFormTrait
                 'maxlength' => 70,
                 'caption'   => \ForkBB\__('Subject'),
                 'required'  => true,
-                'value'     => isset($vars['subject']) ? $vars['subject'] : null,
+                'value'     => $vars['subject'] ?? null,
                 'autofocus' => $autofocus,
             ];
             $autofocus = null;
@@ -87,7 +87,7 @@ trait PostFormTrait
             'type'     => 'textarea',
             'caption'  => \ForkBB\__('Message'),
             'required' => true,
-            'value'    => isset($vars['message']) ? $vars['message'] : null,
+            'value'    => $vars['message'] ?? null,
             'bb'       => [
                 ['link', \ForkBB\__('BBCode'), \ForkBB\__($this->c->config->p_message_bbcode == '1' ? 'on' : 'off')],
                 ['link', \ForkBB\__('url tag'), \ForkBB\__($this->c->config->p_message_bbcode == '1' && $this->user->g_post_links == '1' ? 'on' : 'off')],

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

@@ -120,7 +120,7 @@ class Report extends Page
                             'type'      => 'textarea',
                             'caption'   => \ForkBB\__('Reason'),
                             'required'  => true,
-                            'value'     => isset($data['reason']) ? $data['reason'] : null,
+                            'value'     => $data['reason'] ?? null,
                             'autofocus' => true,
                         ],
                     ],

+ 1 - 1
app/Models/User/Current.php

@@ -116,7 +116,7 @@ class Current extends Action
      */
     protected function getUserAgent(): string
     {
-        $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
+        $ua = $_SERVER['HTTP_USER_AGENT'] ?? '';
         return \is_string($ua) ? \trim($ua) : '';
     }