瀏覽代碼

Update PostFormTrait.php

Replace Ternary Operator to Null Coalescing Operator.
Visman 4 年之前
父節點
當前提交
19ca100b2d
共有 1 個文件被更改,包括 6 次插入8 次删除
  1. 6 8
      app/Models/Pages/PostFormTrait.php

+ 6 - 8
app/Models/Pages/PostFormTrait.php

@@ -113,20 +113,20 @@ trait PostFormTrait
                     'type'    => 'checkbox',
                     'type'    => 'checkbox',
                     'label'   => __('Stick topic'),
                     'label'   => __('Stick topic'),
                     'value'   => '1',
                     'value'   => '1',
-                    'checked' => isset($vars['stick_topic']) ? (bool) $vars['stick_topic'] : false,
+                    'checked' => (bool) ($vars['stick_topic'] ?? false),
                 ];
                 ];
                 $fieldset['stick_fp'] = [
                 $fieldset['stick_fp'] = [
                     'type'    => 'checkbox',
                     'type'    => 'checkbox',
                     'label'   => __('Stick first post'),
                     'label'   => __('Stick first post'),
                     'value'   => '1',
                     'value'   => '1',
-                    'checked' => isset($vars['stick_fp']) ? (bool) $vars['stick_fp'] : false,
+                    'checked' => (bool) ($vars['stick_fp'] ?? false),
                 ];
                 ];
             } elseif (! $editPost) {
             } elseif (! $editPost) {
                 $fieldset['merge_post'] = [
                 $fieldset['merge_post'] = [
                     'type'    => 'checkbox',
                     'type'    => 'checkbox',
                     'label'   => __('Merge posts'),
                     'label'   => __('Merge posts'),
                     'value'   => '1',
                     'value'   => '1',
-                    'checked' => isset($vars['merge_post']) ? (bool) $vars['merge_post'] : true,
+                    'checked' => (bool) ($vars['merge_post'] ?? true),
                 ];
                 ];
             }
             }
 
 
@@ -139,7 +139,7 @@ trait PostFormTrait
                     'type'    => 'checkbox',
                     'type'    => 'checkbox',
                     'label'   => __('EditPost edit'),
                     'label'   => __('EditPost edit'),
                     'value'   => '1',
                     'value'   => '1',
-                    'checked' => isset($vars['edit_post']) ? (bool) $vars['edit_post'] : false,
+                    'checked' => (bool) ($vars['edit_post'] ?? false),
                 ];
                 ];
             }
             }
         }
         }
@@ -163,9 +163,7 @@ trait PostFormTrait
                     'type'    => 'checkbox',
                     'type'    => 'checkbox',
                     'label'   => $subscribed ? __('Stay subscribed') : __('New subscribe'),
                     'label'   => $subscribed ? __('Stay subscribed') : __('New subscribe'),
                     'value'   => '1',
                     'value'   => '1',
-                    'checked' => isset($vars['subscribe'])
-                        ? (bool) $vars['subscribe']
-                        : ($subscribed || $this->user->auto_notify),
+                    'checked' => (bool) ($vars['subscribe'] ?? ($subscribed || $this->user->auto_notify)),
                 ];
                 ];
             }
             }
         }
         }
@@ -178,7 +176,7 @@ trait PostFormTrait
                 'type'    => 'checkbox',
                 'type'    => 'checkbox',
                 'label'   => __('Hide smilies'),
                 'label'   => __('Hide smilies'),
                 'value'   => '1',
                 'value'   => '1',
-                'checked' => isset($vars['hide_smilies']) ? (bool) $vars['hide_smilies'] : false,
+                'checked' => (bool) ($vars['hide_smilies'] ?? false),
             ];
             ];
         }
         }