Skip to content

Commit

Permalink
Use null coalescing operator
Browse files Browse the repository at this point in the history
  • Loading branch information
SharkyKZ committed Jul 17, 2020
1 parent 1c63746 commit 8bebbf5
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions components/com_content/src/Helper/QueryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function orderbyPrimary($orderby)
*/
public static function orderbySecondary($orderby, $orderDate = 'created', DatabaseInterface $db = null)
{
$db = $db ?: Factory::getDbo();
$db = $db ?? Factory::getDbo();

$queryDate = self::getQueryDate($orderDate, $db);

Expand Down Expand Up @@ -179,7 +179,7 @@ public static function orderbySecondary($orderby, $orderDate = 'created', Databa
*/
public static function getQueryDate($orderDate, DatabaseInterface $db = null)
{
$db = $db ?: Factory::getDbo();
$db = $db ?? Factory::getDbo();

switch ($orderDate)
{
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Application/CLI/CliOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class CliOutput
*/
public function __construct(ProcessorInterface $processor = null)
{
$this->setProcessor($processor ?: new Output\Processor\ColorProcessor);
$this->setProcessor($processor ?? new Output\Processor\ColorProcessor);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Application/CMSApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ abstract class CMSApplication extends WebApplication implements ContainerAwareIn
*/
public function __construct(Input $input = null, Registry $config = null, WebClient $client = null, Container $container = null)
{
$container = $container ?: new Container;
$container = $container ?? new Container;
$this->setContainer($container);

parent::__construct($input, $config, $client);
Expand Down
6 changes: 3 additions & 3 deletions libraries/src/Application/CliApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ public function __construct(Input $input = null, Registry $config = null, CliOut
$this->close();
}

$container = $container ?: Factory::getContainer();
$container = $container ?? Factory::getContainer();
$this->setContainer($container);

$this->input = new \Joomla\CMS\Input\Cli;
$this->language = Factory::getLanguage();
$this->output = $output ?: new Stdout;
$this->cliInput = $cliInput ?: new CliInput;
$this->output = $output ?? new Stdout;
$this->cliInput = $cliInput ?? new CliInput;

if ($dispatcher)
{
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Application/IdentityAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getIdentity()
*/
public function loadIdentity(User $identity = null)
{
$this->identity = $identity ?: $this->userFactory->loadUserById(0);
$this->identity = $identity ?? $this->userFactory->loadUserById(0);

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Application/WebApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ abstract class WebApplication extends AbstractWebApplication
public function __construct(Input $input = null, Registry $config = null, WebClient $client = null, ResponseInterface $response = null)
{
// Ensure we have a CMS Input object otherwise the DI for \Joomla\CMS\Session\Storage\JoomlaStorage fails
$input = $input ?: new Input;
$input = $input ?? new Input;

parent::__construct($input, $config, $client, $response);

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Dispatcher/ComponentDispatcherFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ public function createDispatcher(CMSApplicationInterface $application, Input $in
}
}

return new $className($application, $input ?: $application->input, $this->mvcFactory);
return new $className($application, $input ?? $application->input, $this->mvcFactory);
}
}
2 changes: 1 addition & 1 deletion libraries/src/Dispatcher/ModuleDispatcherFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public function createDispatcher(\stdClass $module, CMSApplicationInterface $app
$className = ModuleDispatcher::class;
}

return new $className($module, $application, $input ?: $application->input);
return new $className($module, $application, $input ?? $application->input);
}
}
2 changes: 1 addition & 1 deletion libraries/src/Document/PreloadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PreloadManager implements PreloadManagerInterface
*/
public function __construct(EvolvableLinkProviderInterface $linkProvider = null)
{
$this->linkProvider = $linkProvider ?: new GenericLinkProvider;
$this->linkProvider = $linkProvider ?? new GenericLinkProvider;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions libraries/src/Language/Multilanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function isEnabled(CMSApplication $app = null, DatabaseInterface $
}

// Get application object.
$app = $app ?: Factory::getApplication();
$app = $app ?? Factory::getApplication();

// If being called from the frontend, we can avoid the database query.
if ($app->isClient('site'))
Expand All @@ -66,7 +66,7 @@ public static function isEnabled(CMSApplication $app = null, DatabaseInterface $
if (!$tested)
{
// Determine status of language filter plugin.
$db = $db ?: Factory::getDbo();
$db = $db ?? Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('enabled'))
->from($db->quoteName('#__extensions'))
Expand Down Expand Up @@ -103,7 +103,7 @@ public static function getSiteHomePages(DatabaseInterface $db = null)
if (!isset($multilangSiteHomePages))
{
// Check for Home pages languages.
$db = $db ?: Factory::getDbo();
$db = $db ?? Factory::getDbo();
$query = $db->getQuery(true)
->select(
[
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Pagination/Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function __construct($total, $limitstart, $limit, $prefix = '', CMSApplic
$this->limitstart = (int) max($limitstart, 0);
$this->limit = (int) max($limit, 0);
$this->prefix = $prefix;
$this->app = $app ?: Factory::getApplication();
$this->app = $app ?? Factory::getApplication();

if ($this->limit > $this->total)
{
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Pathway/SitePathway.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(SiteApplication $app = null)
{
$this->pathway = array();

$app = $app ?: Factory::getContainer()->get(SiteApplication::class);
$app = $app ?? Factory::getContainer()->get(SiteApplication::class);
$menu = $app->getMenu();
$lang = Factory::getLanguage();

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Plugin/PluginHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static function importPlugin($type, $plugin = null, $autocreate = true, D
}

// Ensure we have a dispatcher now so we can correctly track the loaded plugins
$dispatcher = $dispatcher ?: Factory::getApplication()->getDispatcher();
$dispatcher = $dispatcher ?? Factory::getApplication()->getDispatcher();

// Get the dispatcher's hash to allow plugins to be registered to unique dispatchers
$dispatcherHash = spl_object_hash($dispatcher);
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/Router/SiteRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class SiteRouter extends Router
*/
public function __construct(CMSApplication $app = null, AbstractMenu $menu = null)
{
$this->app = $app ?: Factory::getContainer()->get(SiteApplication::class);
$this->menu = $menu ?: $this->app->getMenu();
$this->app = $app ?? Factory::getContainer()->get(SiteApplication::class);
$this->menu = $menu ?? $this->app->getMenu();

// Add core rules
if ($this->app->get('force_ssl') === 2)
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/UCM/UCMBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct($alias = null, UCMType $type = null)
$input = Factory::getApplication()->input;
$this->alias = $alias ?: $input->get('option') . '.' . $input->get('view');

$this->type = $type ?: $this->getType();
$this->type = $type ?? $this->getType();
}

/**
Expand Down Expand Up @@ -132,7 +132,7 @@ public function getType()
*/
public function mapBase($original, UCMType $type = null)
{
$type = $type ?: $this->type;
$type = $type ?? $this->type;

$data = array(
'ucm_type_id' => $type->id,
Expand Down
8 changes: 4 additions & 4 deletions libraries/src/UCM/UCMContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct(TableInterface $table = null, $alias = null, UCMType
*/
public function save($original = null, UCMType $type = null)
{
$type = $type ?: $this->type;
$type = $type ?? $this->type;
$ucmData = $original ? $this->mapData($original, $type) : $this->ucmData;

// Store the Common fields
Expand Down Expand Up @@ -104,7 +104,7 @@ public function save($original = null, UCMType $type = null)
public function delete($pk, UCMType $type = null)
{
$db = Factory::getDbo();
$type = $type ?: $this->type;
$type = $type ?? $this->type;

if (!\is_array($pk))
{
Expand Down Expand Up @@ -135,7 +135,7 @@ public function delete($pk, UCMType $type = null)
*/
public function mapData($original, UCMType $type = null)
{
$contentType = $type ?: $this->type;
$contentType = $type ?? $this->type;

$fields = json_decode($contentType->type->field_mappings);

Expand Down Expand Up @@ -190,7 +190,7 @@ public function mapData($original, UCMType $type = null)
*/
protected function store($data, TableInterface $table = null, $primaryKey = null)
{
$table = $table ?: Table::getInstance('Corecontent');
$table = $table ?? Table::getInstance('Corecontent');

$typeId = $this->getType()->type->type_id;
$primaryKey = $primaryKey ?: $this->getPrimaryKey($typeId, $data['core_content_item_id']);
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/UCM/UCMType.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ class UCMType implements UCM
*/
public function __construct($alias = null, DatabaseDriver $database = null, AbstractApplication $application = null)
{
$this->db = $database ?: Factory::getDbo();
$app = $application ?: Factory::getApplication();
$this->db = $database ?? Factory::getDbo();
$app = $application ?? Factory::getApplication();

// Make the best guess we can in the absence of information.
$this->alias = $alias ?: $app->input->get('option') . '.' . $app->input->get('view');
Expand Down

0 comments on commit 8bebbf5

Please sign in to comment.