Use null safe object operator where possible
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
82693daebc
commit
b0bc4f460e
@ -540,8 +540,8 @@ final class Common
|
||||
$db = DatabaseName::tryFromValue($request->getParam('db'));
|
||||
$table = TableName::tryFromValue($request->getParam('table'));
|
||||
|
||||
$GLOBALS['db'] = $db !== null ? $db->getName() : '';
|
||||
$GLOBALS['table'] = $table !== null ? $table->getName() : '';
|
||||
$GLOBALS['db'] = $db?->getName() ?? '';
|
||||
$GLOBALS['table'] = $table?->getName() ?? '';
|
||||
|
||||
if (! is_array($GLOBALS['urlParams'])) {
|
||||
$GLOBALS['urlParams'] = [];
|
||||
|
||||
@ -371,48 +371,26 @@ final class RelationParameters
|
||||
return [
|
||||
'version' => Version::VERSION,
|
||||
'user' => $this->user,
|
||||
'db' => $this->db !== null ? $this->db->getName() : null,
|
||||
'bookmark' => $this->bookmarkFeature !== null ? $this->bookmarkFeature->bookmark->getName() : null,
|
||||
'central_columns' => $this->centralColumnsFeature !== null
|
||||
? $this->centralColumnsFeature->centralColumns->getName()
|
||||
: null,
|
||||
'db' => $this->db?->getName(),
|
||||
'bookmark' => $this->bookmarkFeature?->bookmark->getName(),
|
||||
'central_columns' => $this->centralColumnsFeature?->centralColumns->getName(),
|
||||
'column_info' => $columnInfo,
|
||||
'designer_settings' => $this->databaseDesignerSettingsFeature !== null
|
||||
? $this->databaseDesignerSettingsFeature->designerSettings->getName()
|
||||
: null,
|
||||
'export_templates' => $this->exportTemplatesFeature !== null
|
||||
? $this->exportTemplatesFeature->exportTemplates->getName()
|
||||
: null,
|
||||
'favorite' => $this->favoriteTablesFeature !== null
|
||||
? $this->favoriteTablesFeature->favorite->getName()
|
||||
: null,
|
||||
'history' => $this->sqlHistoryFeature !== null ? $this->sqlHistoryFeature->history->getName() : null,
|
||||
'navigationhiding' => $this->navigationItemsHidingFeature !== null
|
||||
? $this->navigationItemsHidingFeature->navigationHiding->getName()
|
||||
: null,
|
||||
'pdf_pages' => $this->pdfFeature !== null ? $this->pdfFeature->pdfPages->getName() : null,
|
||||
'recent' => $this->recentlyUsedTablesFeature !== null
|
||||
? $this->recentlyUsedTablesFeature->recent->getName()
|
||||
: null,
|
||||
'designer_settings' => $this->databaseDesignerSettingsFeature?->designerSettings->getName(),
|
||||
'export_templates' => $this->exportTemplatesFeature?->exportTemplates->getName(),
|
||||
'favorite' => $this->favoriteTablesFeature?->favorite->getName(),
|
||||
'history' => $this->sqlHistoryFeature?->history->getName(),
|
||||
'navigationhiding' => $this->navigationItemsHidingFeature?->navigationHiding->getName(),
|
||||
'pdf_pages' => $this->pdfFeature?->pdfPages->getName(),
|
||||
'recent' => $this->recentlyUsedTablesFeature?->recent->getName(),
|
||||
'relation' => $relation,
|
||||
'savedsearches' => $this->savedQueryByExampleSearchesFeature !== null
|
||||
? $this->savedQueryByExampleSearchesFeature->savedSearches->getName()
|
||||
: null,
|
||||
'table_coords' => $this->pdfFeature !== null ? $this->pdfFeature->tableCoords->getName() : null,
|
||||
'table_info' => $this->displayFeature !== null ? $this->displayFeature->tableInfo->getName() : null,
|
||||
'table_uiprefs' => $this->uiPreferencesFeature !== null
|
||||
? $this->uiPreferencesFeature->tableUiPrefs->getName()
|
||||
: null,
|
||||
'tracking' => $this->trackingFeature !== null ? $this->trackingFeature->tracking->getName() : null,
|
||||
'userconfig' => $this->userPreferencesFeature !== null
|
||||
? $this->userPreferencesFeature->userConfig->getName()
|
||||
: null,
|
||||
'usergroups' => $this->configurableMenusFeature !== null
|
||||
? $this->configurableMenusFeature->userGroups->getName()
|
||||
: null,
|
||||
'users' => $this->configurableMenusFeature !== null
|
||||
? $this->configurableMenusFeature->users->getName()
|
||||
: null,
|
||||
'savedsearches' => $this->savedQueryByExampleSearchesFeature?->savedSearches->getName(),
|
||||
'table_coords' => $this->pdfFeature?->tableCoords->getName(),
|
||||
'table_info' => $this->displayFeature?->tableInfo->getName(),
|
||||
'table_uiprefs' => $this->uiPreferencesFeature?->tableUiPrefs->getName(),
|
||||
'tracking' => $this->trackingFeature?->tracking->getName(),
|
||||
'userconfig' => $this->userPreferencesFeature?->userConfig->getName(),
|
||||
'usergroups' => $this->configurableMenusFeature?->userGroups->getName(),
|
||||
'users' => $this->configurableMenusFeature?->users->getName(),
|
||||
'bookmarkwork' => $this->bookmarkFeature !== null,
|
||||
'mimework' => $this->browserTransformationFeature !== null,
|
||||
'centralcolumnswork' => $this->centralColumnsFeature !== null,
|
||||
|
||||
@ -51,7 +51,7 @@ class CheckRelationsController extends AbstractController
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
|
||||
$this->render('relation/check_relations', [
|
||||
'db' => $db !== null ? $db->getName() : '',
|
||||
'db' => $db?->getName() ?? '',
|
||||
'zero_conf' => $GLOBALS['cfg']['ZeroConf'],
|
||||
'relation_parameters' => $relationParameters->toArray(),
|
||||
'sql_dir' => SQL_DIR,
|
||||
|
||||
@ -219,7 +219,7 @@ class OperationsController extends AbstractController
|
||||
if ($this->response->isAjax()) {
|
||||
$this->response->setRequestStatus($GLOBALS['message']->isSuccess());
|
||||
$this->response->addJSON('message', $GLOBALS['message']);
|
||||
$this->response->addJSON('newname', $newDatabaseName !== null ? $newDatabaseName->getName() : '');
|
||||
$this->response->addJSON('newname', $newDatabaseName?->getName() ?? '');
|
||||
$this->response->addJSON(
|
||||
'sql_query',
|
||||
Generator::getMessage('', $GLOBALS['sql_query'])
|
||||
|
||||
@ -55,7 +55,7 @@ class Template
|
||||
|
||||
/** @var Config|null $config */
|
||||
$config = $GLOBALS['config'];
|
||||
$cacheDir = $config !== null ? $config->getTempDir('twig') : null;
|
||||
$cacheDir = $config?->getTempDir('twig');
|
||||
|
||||
static::$twig = self::getTwigEnvironment($cacheDir);
|
||||
}
|
||||
|
||||
@ -705,13 +705,13 @@ class Tracker
|
||||
|
||||
if ($options[6] === 'VIEW' || $options[6] === 'TABLE') {
|
||||
$result['identifier'] = 'CREATE ' . $options[6];
|
||||
$result['tablename'] = $statement->name !== null ? $statement->name->table : null;
|
||||
$result['tablename'] = $statement->name?->table;
|
||||
} elseif ($options[6] === 'DATABASE') {
|
||||
$result['identifier'] = 'CREATE DATABASE';
|
||||
$result['tablename'] = '';
|
||||
|
||||
// In case of CREATE DATABASE, database field of the CreateStatement is the name of the database
|
||||
$GLOBALS['db'] = $statement->name !== null ? $statement->name->database : null;
|
||||
$GLOBALS['db'] = $statement->name?->database;
|
||||
} elseif (
|
||||
$options[6] === 'INDEX'
|
||||
|| $options[6] === 'UNIQUE INDEX'
|
||||
|
||||
@ -48,9 +48,6 @@
|
||||
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment">
|
||||
<severity>4</severity>
|
||||
</rule>
|
||||
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullSafeObjectOperator.RequiredNullSafeObjectOperator">
|
||||
<severity>4</severity>
|
||||
</rule>
|
||||
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall.MissingTrailingComma">
|
||||
<severity>4</severity>
|
||||
</rule>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user