From e020d4be449e5ef44fb817cc1ca33583bb4ecdb6 Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Thu, 13 Feb 2025 14:50:37 +0700 Subject: [PATCH 1/6] Use Null Coalescing Assignment Operator for components code --- .../com_content/src/Event/Model/FeatureEvent.php | 4 ++-- .../components/com_content/src/Model/ArticleModel.php | 6 +++--- .../components/com_menus/src/Helper/MenusHelper.php | 4 ++-- .../components/com_menus/src/Model/ItemModel.php | 8 ++++---- .../components/com_menus/src/View/Items/HtmlView.php | 2 +- .../com_scheduler/src/Helper/ExecRuleHelper.php | 2 +- .../components/com_scheduler/src/Model/TaskModel.php | 4 ++-- administrator/components/com_scheduler/src/Task/Task.php | 2 +- .../com_users/src/Controller/MethodsController.php | 6 +++--- components/com_contact/src/Helper/AssociationHelper.php | 2 +- components/com_content/src/Helper/AssociationHelper.php | 2 +- components/com_newsfeeds/src/Helper/AssociationHelper.php | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/administrator/components/com_content/src/Event/Model/FeatureEvent.php b/administrator/components/com_content/src/Event/Model/FeatureEvent.php index 226a56203a3c7..05e7a98b46155 100644 --- a/administrator/components/com_content/src/Event/Model/FeatureEvent.php +++ b/administrator/components/com_content/src/Event/Model/FeatureEvent.php @@ -49,8 +49,8 @@ public function __construct($name, array $arguments = []) if (!\array_key_exists('extensionName', $arguments) || !\array_key_exists('section', $arguments)) { $parts = explode('.', $arguments['extension']); - $arguments['extensionName'] = $arguments['extensionName'] ?? $parts[0]; - $arguments['section'] = $arguments['section'] ?? $parts[1]; + $arguments['extensionName'] ??= $parts[0]; + $arguments['section'] ??= $parts[1]; } if (!isset($arguments['pks']) || !\is_array($arguments['pks'])) { diff --git a/administrator/components/com_content/src/Model/ArticleModel.php b/administrator/components/com_content/src/Model/ArticleModel.php index 4414e43079d02..ee4e816eff8ec 100644 --- a/administrator/components/com_content/src/Model/ArticleModel.php +++ b/administrator/components/com_content/src/Model/ArticleModel.php @@ -106,7 +106,7 @@ class ArticleModel extends AdminModel implements WorkflowModelInterface */ public function __construct($config = [], ?MVCFactoryInterface $factory = null, ?FormFactoryInterface $formFactory = null) { - $config['events_map'] = $config['events_map'] ?? []; + $config['events_map'] ??= []; $config['events_map'] = array_merge( ['featured' => 'content'], @@ -117,9 +117,9 @@ public function __construct($config = [], ?MVCFactoryInterface $factory = null, // Set the featured status change events $this->event_before_change_featured = $config['event_before_change_featured'] ?? $this->event_before_change_featured; - $this->event_before_change_featured = $this->event_before_change_featured ?? 'onContentBeforeChangeFeatured'; + $this->event_before_change_featured ??= 'onContentBeforeChangeFeatured'; $this->event_after_change_featured = $config['event_after_change_featured'] ?? $this->event_after_change_featured; - $this->event_after_change_featured = $this->event_after_change_featured ?? 'onContentAfterChangeFeatured'; + $this->event_after_change_featured ??= 'onContentAfterChangeFeatured'; $this->setUpWorkflow('com_content.article'); } diff --git a/administrator/components/com_menus/src/Helper/MenusHelper.php b/administrator/components/com_menus/src/Helper/MenusHelper.php index 6bfb7339d2d38..a43079f6d4d2c 100644 --- a/administrator/components/com_menus/src/Helper/MenusHelper.php +++ b/administrator/components/com_menus/src/Helper/MenusHelper.php @@ -368,7 +368,7 @@ public static function getMenuItems($menutype, $enabledOnly = false, $exclude = if ($menuitem->link = \in_array($menuitem->type, ['separator', 'heading', 'container']) ? '#' : trim($menuitem->link)) { $menuitem->submenu = []; $menuitem->class = $menuitem->img ?? ''; - $menuitem->scope = $menuitem->scope ?? null; + $menuitem->scope ??= null; $menuitem->target = $menuitem->browserNav ? '_blank' : ''; } @@ -750,7 +750,7 @@ public static function preprocess($item) if ($item->link = \in_array($item->type, ['separator', 'heading', 'container']) ? '#' : trim($item->link)) { $item->class = $item->img ?? ''; - $item->scope = $item->scope ?? null; + $item->scope ??= null; $item->target = $item->browserNav ? '_blank' : ''; } } diff --git a/administrator/components/com_menus/src/Model/ItemModel.php b/administrator/components/com_menus/src/Model/ItemModel.php index b43f6c9c6e396..9d08ce30fc158 100644 --- a/administrator/components/com_menus/src/Model/ItemModel.php +++ b/administrator/components/com_menus/src/Model/ItemModel.php @@ -579,10 +579,10 @@ protected function loadFormData() if (empty($data['id'])) { // Get selected fields $filters = Factory::getApplication()->getUserState('com_menus.items.filter'); - $data['parent_id'] = $data['parent_id'] ?? ($filters['parent_id'] ?? null); - $data['published'] = $data['published'] ?? ($filters['published'] ?? null); - $data['language'] = $data['language'] ?? ($filters['language'] ?? null); - $data['access'] = $data['access'] ?? ($filters['access'] ?? Factory::getApplication()->get('access')); + $data['parent_id'] ??= $filters['parent_id'] ?? null; + $data['published'] ??= $filters['published'] ?? null; + $data['language'] ??= $filters['language'] ?? null; + $data['access'] ??= $filters['access'] ?? Factory::getApplication()->get('access'); } if (isset($data['menutype']) && !$this->getState('item.menutypeid')) { diff --git a/administrator/components/com_menus/src/View/Items/HtmlView.php b/administrator/components/com_menus/src/View/Items/HtmlView.php index c6cd0b0511000..7a634b3f09888 100644 --- a/administrator/components/com_menus/src/View/Items/HtmlView.php +++ b/administrator/components/com_menus/src/View/Items/HtmlView.php @@ -177,7 +177,7 @@ public function display($tpl = null) } } - $vars['layout'] = $vars['layout'] ?? 'default'; + $vars['layout'] ??= 'default'; // Attempt to load the layout xml file. // If Alternative Menu Item, get template folder for layout file diff --git a/administrator/components/com_scheduler/src/Helper/ExecRuleHelper.php b/administrator/components/com_scheduler/src/Helper/ExecRuleHelper.php index e8331afa97eb7..99c77178756d6 100644 --- a/administrator/components/com_scheduler/src/Helper/ExecRuleHelper.php +++ b/administrator/components/com_scheduler/src/Helper/ExecRuleHelper.php @@ -163,7 +163,7 @@ public function nextExec(bool $string = true, bool $basisNow = false) private function dateTimeToSql(\DateTime $dateTime): string { static $db; - $db = $db ?? Factory::getContainer()->get(DatabaseInterface::class); + $db ??= Factory::getContainer()->get(DatabaseInterface::class); return $dateTime->format($db->getDateFormat()); } diff --git a/administrator/components/com_scheduler/src/Model/TaskModel.php b/administrator/components/com_scheduler/src/Model/TaskModel.php index e2c63a1e90dc5..1387186a431fb 100644 --- a/administrator/components/com_scheduler/src/Model/TaskModel.php +++ b/administrator/components/com_scheduler/src/Model/TaskModel.php @@ -119,7 +119,7 @@ class TaskModel extends AdminModel */ public function __construct($config = [], ?MVCFactoryInterface $factory = null, ?FormFactoryInterface $formFactory = null) { - $config['events_map'] = $config['events_map'] ?? []; + $config['events_map'] ??= []; $config['events_map'] = array_merge( [ @@ -631,7 +631,7 @@ public function save($data): bool // If no params, we set as empty array. // ? Is this the right place to do this - $data['params'] = $data['params'] ?? []; + $data['params'] ??= []; // Parent method takes care of saving to the table return parent::save($data); diff --git a/administrator/components/com_scheduler/src/Task/Task.php b/administrator/components/com_scheduler/src/Task/Task.php index e4d58a933a734..5fd8ab56e9fbf 100644 --- a/administrator/components/com_scheduler/src/Task/Task.php +++ b/administrator/components/com_scheduler/src/Task/Task.php @@ -207,7 +207,7 @@ public function run(): bool } $this->snapshot['status'] = Status::RUNNING; - $this->snapshot['taskStart'] = $this->snapshot['taskStart'] ?? microtime(true); + $this->snapshot['taskStart'] ??= microtime(true); $this->snapshot['netDuration'] = 0; /** @var ExecuteTaskEvent $event */ diff --git a/administrator/components/com_users/src/Controller/MethodsController.php b/administrator/components/com_users/src/Controller/MethodsController.php index bd0c655a18a99..1ffc6ecd38699 100644 --- a/administrator/components/com_users/src/Controller/MethodsController.php +++ b/administrator/components/com_users/src/Controller/MethodsController.php @@ -75,7 +75,7 @@ public function disable($cachable = false, $urlparams = []): void $user = ($userId === null) ? $this->app->getIdentity() : $this->getUserFactory()->loadUserById($userId); - $user = $user ?? $this->getUserFactory()->loadUserById(0); + $user ??= $this->getUserFactory()->loadUserById(0); if (!MfaHelper::canDeleteMethod($user)) { throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403); @@ -127,7 +127,7 @@ public function display($cachable = false, $urlparams = []): void $user = ($userId === null) ? $this->app->getIdentity() : $this->getUserFactory()->loadUserById($userId); - $user = $user ?? $this->getUserFactory()->loadUserById(0); + $user ??= $this->getUserFactory()->loadUserById(0); if (!MfaHelper::canShowConfigurationInterface($user)) { throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403); @@ -171,7 +171,7 @@ public function doNotShowThisAgain($cachable = false, $urlparams = []): void $user = ($userId === null) ? $this->app->getIdentity() : $this->getUserFactory()->loadUserById($userId); - $user = $user ?? $this->getUserFactory()->loadUserById(0); + $user ??= $this->getUserFactory()->loadUserById(0); if (!MfaHelper::canAddEditMethod($user)) { throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403); diff --git a/components/com_contact/src/Helper/AssociationHelper.php b/components/com_contact/src/Helper/AssociationHelper.php index 1bfe734e1b4b9..95e712aa40263 100644 --- a/components/com_contact/src/Helper/AssociationHelper.php +++ b/components/com_contact/src/Helper/AssociationHelper.php @@ -38,7 +38,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null) { $jinput = Factory::getApplication()->getInput(); - $view = $view ?? $jinput->get('view'); + $view ??= $jinput->get('view'); $id = empty($id) ? $jinput->getInt('id') : $id; if ($view === 'contact') { diff --git a/components/com_content/src/Helper/AssociationHelper.php b/components/com_content/src/Helper/AssociationHelper.php index 45ce2595abd4c..83ff4387395f3 100644 --- a/components/com_content/src/Helper/AssociationHelper.php +++ b/components/com_content/src/Helper/AssociationHelper.php @@ -41,7 +41,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null, $layout = null) { $jinput = Factory::getApplication()->getInput(); - $view = $view ?? $jinput->get('view'); + $view ??= $jinput->get('view'); $component = $jinput->getCmd('option'); $id = empty($id) ? $jinput->getInt('id') : $id; diff --git a/components/com_newsfeeds/src/Helper/AssociationHelper.php b/components/com_newsfeeds/src/Helper/AssociationHelper.php index a0823f11f8bc2..302d290bb0c4c 100644 --- a/components/com_newsfeeds/src/Helper/AssociationHelper.php +++ b/components/com_newsfeeds/src/Helper/AssociationHelper.php @@ -38,7 +38,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null) { $jinput = Factory::getApplication()->getInput(); - $view = $view ?? $jinput->get('view'); + $view ??= $jinput->get('view'); $id = empty($id) ? $jinput->getInt('id') : $id; if ($view === 'newsfeed') { From 461165bd7faf5568d674e9ca9fa74e3083626e49 Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Fri, 14 Feb 2025 12:06:35 +0700 Subject: [PATCH 2/6] Fix alignment, thanks @QuyTon --- .../components/com_content/src/Event/Model/FeatureEvent.php | 2 +- .../components/com_content/src/Model/ArticleModel.php | 2 +- administrator/components/com_menus/src/Helper/MenusHelper.php | 4 ++-- administrator/components/com_menus/src/Model/ItemModel.php | 4 ++-- administrator/components/com_scheduler/src/Task/Task.php | 2 +- .../components/com_users/src/Controller/MethodsController.php | 2 +- components/com_contact/src/Helper/AssociationHelper.php | 2 +- components/com_content/src/Helper/AssociationHelper.php | 2 +- components/com_newsfeeds/src/Helper/AssociationHelper.php | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/administrator/components/com_content/src/Event/Model/FeatureEvent.php b/administrator/components/com_content/src/Event/Model/FeatureEvent.php index 05e7a98b46155..7fcaabb62f801 100644 --- a/administrator/components/com_content/src/Event/Model/FeatureEvent.php +++ b/administrator/components/com_content/src/Event/Model/FeatureEvent.php @@ -50,7 +50,7 @@ public function __construct($name, array $arguments = []) $parts = explode('.', $arguments['extension']); $arguments['extensionName'] ??= $parts[0]; - $arguments['section'] ??= $parts[1]; + $arguments['section'] ??= $parts[1]; } if (!isset($arguments['pks']) || !\is_array($arguments['pks'])) { diff --git a/administrator/components/com_content/src/Model/ArticleModel.php b/administrator/components/com_content/src/Model/ArticleModel.php index ee4e816eff8ec..f7cceafe132bc 100644 --- a/administrator/components/com_content/src/Model/ArticleModel.php +++ b/administrator/components/com_content/src/Model/ArticleModel.php @@ -119,7 +119,7 @@ public function __construct($config = [], ?MVCFactoryInterface $factory = null, $this->event_before_change_featured = $config['event_before_change_featured'] ?? $this->event_before_change_featured; $this->event_before_change_featured ??= 'onContentBeforeChangeFeatured'; $this->event_after_change_featured = $config['event_after_change_featured'] ?? $this->event_after_change_featured; - $this->event_after_change_featured ??= 'onContentAfterChangeFeatured'; + $this->event_after_change_featured ??= 'onContentAfterChangeFeatured'; $this->setUpWorkflow('com_content.article'); } diff --git a/administrator/components/com_menus/src/Helper/MenusHelper.php b/administrator/components/com_menus/src/Helper/MenusHelper.php index a43079f6d4d2c..1ab04682a193e 100644 --- a/administrator/components/com_menus/src/Helper/MenusHelper.php +++ b/administrator/components/com_menus/src/Helper/MenusHelper.php @@ -368,7 +368,7 @@ public static function getMenuItems($menutype, $enabledOnly = false, $exclude = if ($menuitem->link = \in_array($menuitem->type, ['separator', 'heading', 'container']) ? '#' : trim($menuitem->link)) { $menuitem->submenu = []; $menuitem->class = $menuitem->img ?? ''; - $menuitem->scope ??= null; + $menuitem->scope ??= null; $menuitem->target = $menuitem->browserNav ? '_blank' : ''; } @@ -750,7 +750,7 @@ public static function preprocess($item) if ($item->link = \in_array($item->type, ['separator', 'heading', 'container']) ? '#' : trim($item->link)) { $item->class = $item->img ?? ''; - $item->scope ??= null; + $item->scope ??= null; $item->target = $item->browserNav ? '_blank' : ''; } } diff --git a/administrator/components/com_menus/src/Model/ItemModel.php b/administrator/components/com_menus/src/Model/ItemModel.php index 9d08ce30fc158..322036cc5b41c 100644 --- a/administrator/components/com_menus/src/Model/ItemModel.php +++ b/administrator/components/com_menus/src/Model/ItemModel.php @@ -581,8 +581,8 @@ protected function loadFormData() $filters = Factory::getApplication()->getUserState('com_menus.items.filter'); $data['parent_id'] ??= $filters['parent_id'] ?? null; $data['published'] ??= $filters['published'] ?? null; - $data['language'] ??= $filters['language'] ?? null; - $data['access'] ??= $filters['access'] ?? Factory::getApplication()->get('access'); + $data['language'] ??= $filters['language'] ?? null; + $data['access'] ??= $filters['access'] ?? Factory::getApplication()->get('access'); } if (isset($data['menutype']) && !$this->getState('item.menutypeid')) { diff --git a/administrator/components/com_scheduler/src/Task/Task.php b/administrator/components/com_scheduler/src/Task/Task.php index 5fd8ab56e9fbf..75f5ea0947b8e 100644 --- a/administrator/components/com_scheduler/src/Task/Task.php +++ b/administrator/components/com_scheduler/src/Task/Task.php @@ -207,7 +207,7 @@ public function run(): bool } $this->snapshot['status'] = Status::RUNNING; - $this->snapshot['taskStart'] ??= microtime(true); + $this->snapshot['taskStart'] ??= microtime(true); $this->snapshot['netDuration'] = 0; /** @var ExecuteTaskEvent $event */ diff --git a/administrator/components/com_users/src/Controller/MethodsController.php b/administrator/components/com_users/src/Controller/MethodsController.php index 1ffc6ecd38699..c55acd2d0e26c 100644 --- a/administrator/components/com_users/src/Controller/MethodsController.php +++ b/administrator/components/com_users/src/Controller/MethodsController.php @@ -75,7 +75,7 @@ public function disable($cachable = false, $urlparams = []): void $user = ($userId === null) ? $this->app->getIdentity() : $this->getUserFactory()->loadUserById($userId); - $user ??= $this->getUserFactory()->loadUserById(0); + $user ??= $this->getUserFactory()->loadUserById(0); if (!MfaHelper::canDeleteMethod($user)) { throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403); diff --git a/components/com_contact/src/Helper/AssociationHelper.php b/components/com_contact/src/Helper/AssociationHelper.php index 95e712aa40263..3124fb8ebc886 100644 --- a/components/com_contact/src/Helper/AssociationHelper.php +++ b/components/com_contact/src/Helper/AssociationHelper.php @@ -38,7 +38,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null) { $jinput = Factory::getApplication()->getInput(); - $view ??= $jinput->get('view'); + $view ??= $jinput->get('view'); $id = empty($id) ? $jinput->getInt('id') : $id; if ($view === 'contact') { diff --git a/components/com_content/src/Helper/AssociationHelper.php b/components/com_content/src/Helper/AssociationHelper.php index 83ff4387395f3..04c3955044fc3 100644 --- a/components/com_content/src/Helper/AssociationHelper.php +++ b/components/com_content/src/Helper/AssociationHelper.php @@ -41,7 +41,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null, $layout = null) { $jinput = Factory::getApplication()->getInput(); - $view ??= $jinput->get('view'); + $view ??= $jinput->get('view'); $component = $jinput->getCmd('option'); $id = empty($id) ? $jinput->getInt('id') : $id; diff --git a/components/com_newsfeeds/src/Helper/AssociationHelper.php b/components/com_newsfeeds/src/Helper/AssociationHelper.php index 302d290bb0c4c..a07d661af5a7f 100644 --- a/components/com_newsfeeds/src/Helper/AssociationHelper.php +++ b/components/com_newsfeeds/src/Helper/AssociationHelper.php @@ -38,7 +38,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null) { $jinput = Factory::getApplication()->getInput(); - $view ??= $jinput->get('view'); + $view ??= $jinput->get('view'); $id = empty($id) ? $jinput->getInt('id') : $id; if ($view === 'newsfeed') { From 7045b5ba57af28892c6450a2e453cb4c802320f2 Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Sun, 16 Feb 2025 11:27:38 +0700 Subject: [PATCH 3/6] CS --- .../components/com_content/src/Event/Model/FeatureEvent.php | 2 +- .../components/com_content/src/Model/ArticleModel.php | 2 +- administrator/components/com_menus/src/Helper/MenusHelper.php | 4 ++-- administrator/components/com_menus/src/Model/ItemModel.php | 4 ++-- administrator/components/com_scheduler/src/Task/Task.php | 2 +- .../components/com_users/src/Controller/MethodsController.php | 2 +- components/com_contact/src/Helper/AssociationHelper.php | 2 +- components/com_content/src/Helper/AssociationHelper.php | 2 +- components/com_newsfeeds/src/Helper/AssociationHelper.php | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/administrator/components/com_content/src/Event/Model/FeatureEvent.php b/administrator/components/com_content/src/Event/Model/FeatureEvent.php index 7fcaabb62f801..05e7a98b46155 100644 --- a/administrator/components/com_content/src/Event/Model/FeatureEvent.php +++ b/administrator/components/com_content/src/Event/Model/FeatureEvent.php @@ -50,7 +50,7 @@ public function __construct($name, array $arguments = []) $parts = explode('.', $arguments['extension']); $arguments['extensionName'] ??= $parts[0]; - $arguments['section'] ??= $parts[1]; + $arguments['section'] ??= $parts[1]; } if (!isset($arguments['pks']) || !\is_array($arguments['pks'])) { diff --git a/administrator/components/com_content/src/Model/ArticleModel.php b/administrator/components/com_content/src/Model/ArticleModel.php index f7cceafe132bc..ee4e816eff8ec 100644 --- a/administrator/components/com_content/src/Model/ArticleModel.php +++ b/administrator/components/com_content/src/Model/ArticleModel.php @@ -119,7 +119,7 @@ public function __construct($config = [], ?MVCFactoryInterface $factory = null, $this->event_before_change_featured = $config['event_before_change_featured'] ?? $this->event_before_change_featured; $this->event_before_change_featured ??= 'onContentBeforeChangeFeatured'; $this->event_after_change_featured = $config['event_after_change_featured'] ?? $this->event_after_change_featured; - $this->event_after_change_featured ??= 'onContentAfterChangeFeatured'; + $this->event_after_change_featured ??= 'onContentAfterChangeFeatured'; $this->setUpWorkflow('com_content.article'); } diff --git a/administrator/components/com_menus/src/Helper/MenusHelper.php b/administrator/components/com_menus/src/Helper/MenusHelper.php index 1ab04682a193e..a43079f6d4d2c 100644 --- a/administrator/components/com_menus/src/Helper/MenusHelper.php +++ b/administrator/components/com_menus/src/Helper/MenusHelper.php @@ -368,7 +368,7 @@ public static function getMenuItems($menutype, $enabledOnly = false, $exclude = if ($menuitem->link = \in_array($menuitem->type, ['separator', 'heading', 'container']) ? '#' : trim($menuitem->link)) { $menuitem->submenu = []; $menuitem->class = $menuitem->img ?? ''; - $menuitem->scope ??= null; + $menuitem->scope ??= null; $menuitem->target = $menuitem->browserNav ? '_blank' : ''; } @@ -750,7 +750,7 @@ public static function preprocess($item) if ($item->link = \in_array($item->type, ['separator', 'heading', 'container']) ? '#' : trim($item->link)) { $item->class = $item->img ?? ''; - $item->scope ??= null; + $item->scope ??= null; $item->target = $item->browserNav ? '_blank' : ''; } } diff --git a/administrator/components/com_menus/src/Model/ItemModel.php b/administrator/components/com_menus/src/Model/ItemModel.php index 322036cc5b41c..9d08ce30fc158 100644 --- a/administrator/components/com_menus/src/Model/ItemModel.php +++ b/administrator/components/com_menus/src/Model/ItemModel.php @@ -581,8 +581,8 @@ protected function loadFormData() $filters = Factory::getApplication()->getUserState('com_menus.items.filter'); $data['parent_id'] ??= $filters['parent_id'] ?? null; $data['published'] ??= $filters['published'] ?? null; - $data['language'] ??= $filters['language'] ?? null; - $data['access'] ??= $filters['access'] ?? Factory::getApplication()->get('access'); + $data['language'] ??= $filters['language'] ?? null; + $data['access'] ??= $filters['access'] ?? Factory::getApplication()->get('access'); } if (isset($data['menutype']) && !$this->getState('item.menutypeid')) { diff --git a/administrator/components/com_scheduler/src/Task/Task.php b/administrator/components/com_scheduler/src/Task/Task.php index 75f5ea0947b8e..5fd8ab56e9fbf 100644 --- a/administrator/components/com_scheduler/src/Task/Task.php +++ b/administrator/components/com_scheduler/src/Task/Task.php @@ -207,7 +207,7 @@ public function run(): bool } $this->snapshot['status'] = Status::RUNNING; - $this->snapshot['taskStart'] ??= microtime(true); + $this->snapshot['taskStart'] ??= microtime(true); $this->snapshot['netDuration'] = 0; /** @var ExecuteTaskEvent $event */ diff --git a/administrator/components/com_users/src/Controller/MethodsController.php b/administrator/components/com_users/src/Controller/MethodsController.php index c55acd2d0e26c..1ffc6ecd38699 100644 --- a/administrator/components/com_users/src/Controller/MethodsController.php +++ b/administrator/components/com_users/src/Controller/MethodsController.php @@ -75,7 +75,7 @@ public function disable($cachable = false, $urlparams = []): void $user = ($userId === null) ? $this->app->getIdentity() : $this->getUserFactory()->loadUserById($userId); - $user ??= $this->getUserFactory()->loadUserById(0); + $user ??= $this->getUserFactory()->loadUserById(0); if (!MfaHelper::canDeleteMethod($user)) { throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403); diff --git a/components/com_contact/src/Helper/AssociationHelper.php b/components/com_contact/src/Helper/AssociationHelper.php index 3124fb8ebc886..95e712aa40263 100644 --- a/components/com_contact/src/Helper/AssociationHelper.php +++ b/components/com_contact/src/Helper/AssociationHelper.php @@ -38,7 +38,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null) { $jinput = Factory::getApplication()->getInput(); - $view ??= $jinput->get('view'); + $view ??= $jinput->get('view'); $id = empty($id) ? $jinput->getInt('id') : $id; if ($view === 'contact') { diff --git a/components/com_content/src/Helper/AssociationHelper.php b/components/com_content/src/Helper/AssociationHelper.php index 04c3955044fc3..83ff4387395f3 100644 --- a/components/com_content/src/Helper/AssociationHelper.php +++ b/components/com_content/src/Helper/AssociationHelper.php @@ -41,7 +41,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null, $layout = null) { $jinput = Factory::getApplication()->getInput(); - $view ??= $jinput->get('view'); + $view ??= $jinput->get('view'); $component = $jinput->getCmd('option'); $id = empty($id) ? $jinput->getInt('id') : $id; diff --git a/components/com_newsfeeds/src/Helper/AssociationHelper.php b/components/com_newsfeeds/src/Helper/AssociationHelper.php index a07d661af5a7f..302d290bb0c4c 100644 --- a/components/com_newsfeeds/src/Helper/AssociationHelper.php +++ b/components/com_newsfeeds/src/Helper/AssociationHelper.php @@ -38,7 +38,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null) { $jinput = Factory::getApplication()->getInput(); - $view ??= $jinput->get('view'); + $view ??= $jinput->get('view'); $id = empty($id) ? $jinput->getInt('id') : $id; if ($view === 'newsfeed') { From 9cb92d0e8d58b78f5749b5cf520ff36ef8965e1a Mon Sep 17 00:00:00 2001 From: hleithner Date: Sat, 22 Feb 2025 11:29:36 +0100 Subject: [PATCH 4/6] Revert "CS" This reverts commit 7045b5ba57af28892c6450a2e453cb4c802320f2. --- .../components/com_content/src/Event/Model/FeatureEvent.php | 2 +- .../components/com_content/src/Model/ArticleModel.php | 2 +- administrator/components/com_menus/src/Helper/MenusHelper.php | 4 ++-- administrator/components/com_menus/src/Model/ItemModel.php | 4 ++-- administrator/components/com_scheduler/src/Task/Task.php | 2 +- .../components/com_users/src/Controller/MethodsController.php | 2 +- components/com_contact/src/Helper/AssociationHelper.php | 2 +- components/com_content/src/Helper/AssociationHelper.php | 2 +- components/com_newsfeeds/src/Helper/AssociationHelper.php | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/administrator/components/com_content/src/Event/Model/FeatureEvent.php b/administrator/components/com_content/src/Event/Model/FeatureEvent.php index 05e7a98b46155..7fcaabb62f801 100644 --- a/administrator/components/com_content/src/Event/Model/FeatureEvent.php +++ b/administrator/components/com_content/src/Event/Model/FeatureEvent.php @@ -50,7 +50,7 @@ public function __construct($name, array $arguments = []) $parts = explode('.', $arguments['extension']); $arguments['extensionName'] ??= $parts[0]; - $arguments['section'] ??= $parts[1]; + $arguments['section'] ??= $parts[1]; } if (!isset($arguments['pks']) || !\is_array($arguments['pks'])) { diff --git a/administrator/components/com_content/src/Model/ArticleModel.php b/administrator/components/com_content/src/Model/ArticleModel.php index ee4e816eff8ec..f7cceafe132bc 100644 --- a/administrator/components/com_content/src/Model/ArticleModel.php +++ b/administrator/components/com_content/src/Model/ArticleModel.php @@ -119,7 +119,7 @@ public function __construct($config = [], ?MVCFactoryInterface $factory = null, $this->event_before_change_featured = $config['event_before_change_featured'] ?? $this->event_before_change_featured; $this->event_before_change_featured ??= 'onContentBeforeChangeFeatured'; $this->event_after_change_featured = $config['event_after_change_featured'] ?? $this->event_after_change_featured; - $this->event_after_change_featured ??= 'onContentAfterChangeFeatured'; + $this->event_after_change_featured ??= 'onContentAfterChangeFeatured'; $this->setUpWorkflow('com_content.article'); } diff --git a/administrator/components/com_menus/src/Helper/MenusHelper.php b/administrator/components/com_menus/src/Helper/MenusHelper.php index a43079f6d4d2c..1ab04682a193e 100644 --- a/administrator/components/com_menus/src/Helper/MenusHelper.php +++ b/administrator/components/com_menus/src/Helper/MenusHelper.php @@ -368,7 +368,7 @@ public static function getMenuItems($menutype, $enabledOnly = false, $exclude = if ($menuitem->link = \in_array($menuitem->type, ['separator', 'heading', 'container']) ? '#' : trim($menuitem->link)) { $menuitem->submenu = []; $menuitem->class = $menuitem->img ?? ''; - $menuitem->scope ??= null; + $menuitem->scope ??= null; $menuitem->target = $menuitem->browserNav ? '_blank' : ''; } @@ -750,7 +750,7 @@ public static function preprocess($item) if ($item->link = \in_array($item->type, ['separator', 'heading', 'container']) ? '#' : trim($item->link)) { $item->class = $item->img ?? ''; - $item->scope ??= null; + $item->scope ??= null; $item->target = $item->browserNav ? '_blank' : ''; } } diff --git a/administrator/components/com_menus/src/Model/ItemModel.php b/administrator/components/com_menus/src/Model/ItemModel.php index 9d08ce30fc158..322036cc5b41c 100644 --- a/administrator/components/com_menus/src/Model/ItemModel.php +++ b/administrator/components/com_menus/src/Model/ItemModel.php @@ -581,8 +581,8 @@ protected function loadFormData() $filters = Factory::getApplication()->getUserState('com_menus.items.filter'); $data['parent_id'] ??= $filters['parent_id'] ?? null; $data['published'] ??= $filters['published'] ?? null; - $data['language'] ??= $filters['language'] ?? null; - $data['access'] ??= $filters['access'] ?? Factory::getApplication()->get('access'); + $data['language'] ??= $filters['language'] ?? null; + $data['access'] ??= $filters['access'] ?? Factory::getApplication()->get('access'); } if (isset($data['menutype']) && !$this->getState('item.menutypeid')) { diff --git a/administrator/components/com_scheduler/src/Task/Task.php b/administrator/components/com_scheduler/src/Task/Task.php index 5fd8ab56e9fbf..75f5ea0947b8e 100644 --- a/administrator/components/com_scheduler/src/Task/Task.php +++ b/administrator/components/com_scheduler/src/Task/Task.php @@ -207,7 +207,7 @@ public function run(): bool } $this->snapshot['status'] = Status::RUNNING; - $this->snapshot['taskStart'] ??= microtime(true); + $this->snapshot['taskStart'] ??= microtime(true); $this->snapshot['netDuration'] = 0; /** @var ExecuteTaskEvent $event */ diff --git a/administrator/components/com_users/src/Controller/MethodsController.php b/administrator/components/com_users/src/Controller/MethodsController.php index 1ffc6ecd38699..c55acd2d0e26c 100644 --- a/administrator/components/com_users/src/Controller/MethodsController.php +++ b/administrator/components/com_users/src/Controller/MethodsController.php @@ -75,7 +75,7 @@ public function disable($cachable = false, $urlparams = []): void $user = ($userId === null) ? $this->app->getIdentity() : $this->getUserFactory()->loadUserById($userId); - $user ??= $this->getUserFactory()->loadUserById(0); + $user ??= $this->getUserFactory()->loadUserById(0); if (!MfaHelper::canDeleteMethod($user)) { throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403); diff --git a/components/com_contact/src/Helper/AssociationHelper.php b/components/com_contact/src/Helper/AssociationHelper.php index 95e712aa40263..3124fb8ebc886 100644 --- a/components/com_contact/src/Helper/AssociationHelper.php +++ b/components/com_contact/src/Helper/AssociationHelper.php @@ -38,7 +38,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null) { $jinput = Factory::getApplication()->getInput(); - $view ??= $jinput->get('view'); + $view ??= $jinput->get('view'); $id = empty($id) ? $jinput->getInt('id') : $id; if ($view === 'contact') { diff --git a/components/com_content/src/Helper/AssociationHelper.php b/components/com_content/src/Helper/AssociationHelper.php index 83ff4387395f3..04c3955044fc3 100644 --- a/components/com_content/src/Helper/AssociationHelper.php +++ b/components/com_content/src/Helper/AssociationHelper.php @@ -41,7 +41,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null, $layout = null) { $jinput = Factory::getApplication()->getInput(); - $view ??= $jinput->get('view'); + $view ??= $jinput->get('view'); $component = $jinput->getCmd('option'); $id = empty($id) ? $jinput->getInt('id') : $id; diff --git a/components/com_newsfeeds/src/Helper/AssociationHelper.php b/components/com_newsfeeds/src/Helper/AssociationHelper.php index 302d290bb0c4c..a07d661af5a7f 100644 --- a/components/com_newsfeeds/src/Helper/AssociationHelper.php +++ b/components/com_newsfeeds/src/Helper/AssociationHelper.php @@ -38,7 +38,7 @@ abstract class AssociationHelper extends CategoryAssociationHelper public static function getAssociations($id = 0, $view = null) { $jinput = Factory::getApplication()->getInput(); - $view ??= $jinput->get('view'); + $view ??= $jinput->get('view'); $id = empty($id) ? $jinput->getInt('id') : $id; if ($view === 'newsfeed') { From 99ec42481e64f4e1cc0787ece33f9da7ba447e9b Mon Sep 17 00:00:00 2001 From: hleithner Date: Sat, 22 Feb 2025 11:30:08 +0100 Subject: [PATCH 5/6] Update php-cs-fixer rule, correctly align ??= operator --- .php-cs-fixer.dist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 23f0a3741954f..27b6d831e85ae 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -76,7 +76,7 @@ // Arrays on multiline should have a trailing comma 'trailing_comma_in_multiline' => ['elements' => ['arrays']], // Align elements in multiline array and variable declarations on new lines below each other - 'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align']], + 'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align', '??=' => 'align']], // The "No break" comment in switch statements 'no_break_comment' => ['comment_text' => 'No break'], // Remove unused imports From 34afc9169ac0ba2da0baf081ed8ec83d8ea1a651 Mon Sep 17 00:00:00 2001 From: hleithner Date: Sat, 22 Feb 2025 11:46:32 +0100 Subject: [PATCH 6/6] Fix CS --- libraries/src/Categories/Categories.php | 6 +++--- libraries/src/Editor/Button/ButtonsRegistry.php | 2 +- libraries/src/Editor/Editor.php | 4 ++-- libraries/src/Event/View/DisplayEvent.php | 2 +- libraries/src/Event/Workflow/AbstractEvent.php | 2 +- libraries/src/HTML/HTMLHelper.php | 12 ++++++------ libraries/src/Toolbar/Button/InlinehelpButton.php | 2 +- libraries/src/WebAuthn/Server.php | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libraries/src/Categories/Categories.php b/libraries/src/Categories/Categories.php index f961dc720043b..7205c7e563db2 100644 --- a/libraries/src/Categories/Categories.php +++ b/libraries/src/Categories/Categories.php @@ -117,9 +117,9 @@ public function __construct($options) $this->_key = isset($options['key']) && $options['key'] ? $options['key'] : 'id'; $this->_statefield = $options['statefield'] ?? 'state'; - $options['access'] ??= 'true'; - $options['published'] ??= 1; - $options['countItems'] ??= 0; + $options['access'] ??= 'true'; + $options['published'] ??= 1; + $options['countItems'] ??= 0; $options['currentlang'] = Multilanguage::isEnabled() ? Factory::getLanguage()->getTag() : 0; $this->_options = $options; diff --git a/libraries/src/Editor/Button/ButtonsRegistry.php b/libraries/src/Editor/Button/ButtonsRegistry.php index 25c895b80652e..cbae9287a935f 100644 --- a/libraries/src/Editor/Button/ButtonsRegistry.php +++ b/libraries/src/Editor/Button/ButtonsRegistry.php @@ -89,7 +89,7 @@ public function initRegistry(array $options = []): ButtonsRegistryInterface $this->initialised = true; $options['subject'] = $this; - $options['editorType'] ??= ''; + $options['editorType'] ??= ''; $options['disabledButtons'] ??= []; $event = new EditorButtonsSetupEvent('onEditorButtonsSetup', $options); diff --git a/libraries/src/Editor/Editor.php b/libraries/src/Editor/Editor.php index d2d47a0f33aa4..746369b6e596b 100644 --- a/libraries/src/Editor/Editor.php +++ b/libraries/src/Editor/Editor.php @@ -204,8 +204,8 @@ public function display($name, $html, $width, $height, $col, $row, $buttons = tr { if ($this->provider) { $params['buttons'] ??= $buttons; - $params['asset'] ??= $asset; - $params['author'] ??= $author; + $params['asset'] ??= $asset; + $params['author'] ??= $author; $content = $html ?? ''; return $this->provider->display($name, $content, [ diff --git a/libraries/src/Event/View/DisplayEvent.php b/libraries/src/Event/View/DisplayEvent.php index 4b33287928549..bbf4046e723c6 100644 --- a/libraries/src/Event/View/DisplayEvent.php +++ b/libraries/src/Event/View/DisplayEvent.php @@ -59,7 +59,7 @@ public function __construct($name, array $arguments = []) $parts = explode('.', $arguments['extension']); $arguments['extensionName'] ??= $parts[0]; - $arguments['section'] ??= $parts[1]; + $arguments['section'] ??= $parts[1]; } parent::__construct($name, $arguments); diff --git a/libraries/src/Event/Workflow/AbstractEvent.php b/libraries/src/Event/Workflow/AbstractEvent.php index 106e1582d355a..f4d6ec09f4048 100644 --- a/libraries/src/Event/Workflow/AbstractEvent.php +++ b/libraries/src/Event/Workflow/AbstractEvent.php @@ -50,7 +50,7 @@ public function __construct($name, array $arguments = []) $parts = explode('.', $arguments['extension']); $arguments['extensionName'] ??= $parts[0]; - $arguments['section'] ??= $parts[1]; + $arguments['section'] ??= $parts[1]; } parent::__construct($name, $arguments); diff --git a/libraries/src/HTML/HTMLHelper.php b/libraries/src/HTML/HTMLHelper.php index d66622487f88b..5d02e65bbf4fa 100644 --- a/libraries/src/HTML/HTMLHelper.php +++ b/libraries/src/HTML/HTMLHelper.php @@ -796,10 +796,10 @@ public static function stylesheet($file, $options = [], $attribs = []) { @trigger_error('Method HTMLHelper::stylesheet() is deprecated, and will be removed in 7.0', \E_USER_DEPRECATED); - $options['relative'] ??= false; - $options['pathOnly'] ??= false; + $options['relative'] ??= false; + $options['pathOnly'] ??= false; $options['detectBrowser'] ??= false; - $options['detectDebug'] ??= true; + $options['detectDebug'] ??= true; $includes = static::includeRelativeFiles('css', $file, $options['relative'], $options['detectBrowser'], $options['detectDebug']); @@ -848,10 +848,10 @@ public static function script($file, $options = [], $attribs = []) { @trigger_error('Method HTMLHelper::script() is deprecated, and will be removed in 7.0', \E_USER_DEPRECATED); - $options['relative'] ??= false; - $options['pathOnly'] ??= false; + $options['relative'] ??= false; + $options['pathOnly'] ??= false; $options['detectBrowser'] ??= false; - $options['detectDebug'] ??= true; + $options['detectDebug'] ??= true; $includes = static::includeRelativeFiles('js', $file, $options['relative'], $options['detectBrowser'], $options['detectDebug']); diff --git a/libraries/src/Toolbar/Button/InlinehelpButton.php b/libraries/src/Toolbar/Button/InlinehelpButton.php index 378c8dbb89a74..9177b2bd21509 100644 --- a/libraries/src/Toolbar/Button/InlinehelpButton.php +++ b/libraries/src/Toolbar/Button/InlinehelpButton.php @@ -44,7 +44,7 @@ class InlinehelpButton extends BasicButton protected function prepareOptions(array &$options) { $options['text'] = $options['text'] ?: 'JINLINEHELP'; - $options['icon'] ??= 'fa-question-circle'; + $options['icon'] ??= 'fa-question-circle'; $options['button_class'] ??= 'btn btn-info'; $options['attributes'] = array_merge( $options['attributes'] ?? [], diff --git a/libraries/src/WebAuthn/Server.php b/libraries/src/WebAuthn/Server.php index a49c9f7409ce7..195faa4be33d2 100644 --- a/libraries/src/WebAuthn/Server.php +++ b/libraries/src/WebAuthn/Server.php @@ -237,7 +237,7 @@ public function generatePublicKeyCredentialCreationOptions(PublicKeyCredentialUs ); } - $criteria ??= new AuthenticatorSelectionCriteria(); + $criteria ??= new AuthenticatorSelectionCriteria(); $extensions ??= new AuthenticationExtensionsClientInputs(); $challenge = random_bytes($this->challengeSize);