Skip to content

Commit 1945935

Browse files
authored
[5.3] Use null coalescing assignment operator for libraries code (#44920)
1 parent 1bb3315 commit 1945935

File tree

22 files changed

+44
-44
lines changed

22 files changed

+44
-44
lines changed

libraries/src/Button/TransitionButton.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function render(?int $value = null, ?int $row = null, array $options = []
6262
{
6363
$default = $this->unknownState;
6464

65-
$options['tip_title'] = $options['tip_title'] ?? ($options['title'] ?? $default['title']);
65+
$options['tip_title'] ??= $options['title'] ?? $default['title'];
6666

6767
return parent::render($value, $row, $options);
6868
}

libraries/src/Categories/Categories.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public function __construct($options)
117117
$this->_key = isset($options['key']) && $options['key'] ? $options['key'] : 'id';
118118
$this->_statefield = $options['statefield'] ?? 'state';
119119

120-
$options['access'] = $options['access'] ?? 'true';
121-
$options['published'] = $options['published'] ?? 1;
122-
$options['countItems'] = $options['countItems'] ?? 0;
120+
$options['access'] ??= 'true';
121+
$options['published'] ??= 1;
122+
$options['countItems'] ??= 0;
123123
$options['currentlang'] = Multilanguage::isEnabled() ? Factory::getLanguage()->getTag() : 0;
124124

125125
$this->_options = $options;

libraries/src/Editor/Button/ButtonsRegistry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public function initRegistry(array $options = []): ButtonsRegistryInterface
8989
$this->initialised = true;
9090

9191
$options['subject'] = $this;
92-
$options['editorType'] = $options['editorType'] ?? '';
93-
$options['disabledButtons'] = $options['disabledButtons'] ?? [];
92+
$options['editorType'] ??= '';
93+
$options['disabledButtons'] ??= [];
9494

9595
$event = new EditorButtonsSetupEvent('onEditorButtonsSetup', $options);
9696
$dispatcher = $this->getDispatcher();

libraries/src/Editor/Editor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function __construct(string $editor = 'none', ?DispatcherInterface $dispa
9797
$this->_name = $editor;
9898

9999
/** @var EditorsRegistry $registry */
100-
$registry = $registry ?? Factory::getContainer()->get(EditorsRegistry::class);
100+
$registry ??= Factory::getContainer()->get(EditorsRegistry::class);
101101

102102
if ($registry->has($editor)) {
103103
$this->provider = $registry->get($editor);
@@ -203,9 +203,9 @@ public function initialise()
203203
public function display($name, $html, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = [])
204204
{
205205
if ($this->provider) {
206-
$params['buttons'] = $params['buttons'] ?? $buttons;
207-
$params['asset'] = $params['asset'] ?? $asset;
208-
$params['author'] = $params['author'] ?? $author;
206+
$params['buttons'] ??= $buttons;
207+
$params['asset'] ??= $asset;
208+
$params['author'] ??= $author;
209209
$content = $html ?? '';
210210

211211
return $this->provider->display($name, $content, [

libraries/src/Event/Model/PrepareDataEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class PrepareDataEvent extends ModelEvent
4545
public function __construct($name, array $arguments = [])
4646
{
4747
// This event has a dummy subject for now
48-
$this->arguments['subject'] = $this->arguments['subject'] ?? new \stdClass();
48+
$this->arguments['subject'] ??= new \stdClass();
4949

5050
parent::__construct($name, $arguments);
5151

libraries/src/Event/Module/AfterRenderModulesEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class AfterRenderModulesEvent extends ModuleEvent
4545
public function __construct($name, array $arguments = [])
4646
{
4747
// This event has a dummy subject for now
48-
$this->arguments['subject'] = $this->arguments['subject'] ?? new \stdClass();
48+
$this->arguments['subject'] ??= new \stdClass();
4949

5050
parent::__construct($name, $arguments);
5151

libraries/src/Event/Module/ModuleListEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class ModuleListEvent extends ModuleEvent
4343
public function __construct($name, array $arguments = [])
4444
{
4545
// This event has a dummy subject for now
46-
$this->arguments['subject'] = $this->arguments['subject'] ?? new \stdClass();
46+
$this->arguments['subject'] ??= new \stdClass();
4747

4848
parent::__construct($name, $arguments);
4949

libraries/src/Event/Plugin/AjaxEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getApplication(): AbstractApplication
8282
*/
8383
public function addResult($data): void
8484
{
85-
$this->arguments['result'] = $this->arguments['result'] ?? [];
85+
$this->arguments['result'] ??= [];
8686

8787
if (\is_array($this->arguments['result'])) {
8888
$this->arguments['result'][] = $data;

libraries/src/Event/Result/ResultAware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function addResult($data): void
6363
$this->typeCheckResult($data);
6464

6565
// Append the result. We use the arguments property directly to allow this to work on immutable events.
66-
$this->arguments['result'] = $this->arguments['result'] ?? [];
66+
$this->arguments['result'] ??= [];
6767
$this->arguments['result'][] = $data;
6868
}
6969

libraries/src/Event/View/DisplayEvent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public function __construct($name, array $arguments = [])
5858
if (!\array_key_exists('extensionName', $arguments) || !\array_key_exists('section', $arguments)) {
5959
$parts = explode('.', $arguments['extension']);
6060

61-
$arguments['extensionName'] = $arguments['extensionName'] ?? $parts[0];
62-
$arguments['section'] = $arguments['section'] ?? $parts[1];
61+
$arguments['extensionName'] ??= $parts[0];
62+
$arguments['section'] ??= $parts[1];
6363
}
6464

6565
parent::__construct($name, $arguments);

0 commit comments

Comments
 (0)