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 diff --git a/administrator/components/com_content/src/Event/Model/FeatureEvent.php b/administrator/components/com_content/src/Event/Model/FeatureEvent.php index b470c31822f8a..4a8e699cf8e70 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 59949e6ce58c1..aa438b6852164 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 0f52c5269e6fc..4ab707b1de506 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 38cea8ea6dc4d..a012cc94b3269 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 b98de9cb3dd9e..f78139d165180 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 16f7c1003ae27..4595910bf9fce 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 b8d7175856d14..7144be82153c2 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..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 = $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..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 = $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..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 = $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..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 = $view ?? $jinput->get('view'); + $view ??= $jinput->get('view'); $id = empty($id) ? $jinput->getInt('id') : $id; if ($view === 'newsfeed') { 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);