Skip to content

Commit

Permalink
[Coding Style] Enable rules PSR2.Methods.FunctionCallSignature.* (#21926
Browse files Browse the repository at this point in the history
)

* [Coding Style] Enable rules PSR2.Methods.FunctionCallSignature.*

* Apply coding style around FunctionCallSignature #1 (#21927)

* Apply coding style around FunctionCallSignature #2 (#21928)

* Apply coding style around FunctionCallSignature #3 (#21929)

* Apply coding style around FunctionCallSignature #4 (#21930)

* Apply coding style around FunctionCallSignature #5 (#21931)

* Apply coding style around FunctionCallSignature #6 (#21932)

* Apply coding style around FunctionCallSignature #7 (#21933)

* Apply coding style around FunctionCallSignature #8 (#21934)

* Apply coding style around FunctionCallSignature #9 (#21935)
  • Loading branch information
sgiehl authored Feb 15, 2024
1 parent 260ae34 commit e61eb91
Show file tree
Hide file tree
Showing 269 changed files with 3,175 additions and 1,162 deletions.
3 changes: 2 additions & 1 deletion core/API/DataTableManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ protected function getApiMethodForSubtable($request)
if (empty($meta)) {
throw new Exception(sprintf(
"The DataTable cannot be manipulated: Metadata for report %s.%s could not be found. You can define the metadata in a hook, see example at: %s",
$this->apiModule, $this->apiMethod,
$this->apiModule,
$this->apiMethod,
Url::addCampaignParametersToMatomoLink('https://developer.matomo.org/api-reference/events#apigetreportmetadata')
));
}
Expand Down
12 changes: 10 additions & 2 deletions core/API/DataTablePostProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ public function applyProcessedMetricsGenericFilters($dataTable)
$addNormalProcessedMetrics = null;
try {
$addNormalProcessedMetrics = Common::getRequestVar(
'filter_add_columns_when_show_all_columns', null, 'integer', $this->request);
'filter_add_columns_when_show_all_columns',
null,
'integer',
$this->request
);
} catch (Exception $ex) {
// ignore
}
Expand All @@ -261,7 +265,11 @@ public function applyProcessedMetricsGenericFilters($dataTable)
$addGoalProcessedMetrics = null;
try {
$addGoalProcessedMetrics = Common::getRequestVar(
'filter_update_columns_when_show_all_goals', false, 'string', $this->request);
'filter_update_columns_when_show_all_goals',
false,
'string',
$this->request
);
if ((int) $addGoalProcessedMetrics === 0
&& $addGoalProcessedMetrics !== '0'
&& $addGoalProcessedMetrics != Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER
Expand Down
12 changes: 8 additions & 4 deletions core/API/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,10 @@ public static function checkTokenAuthIsNotLimited($module, $action)
}

if (Access::getInstance()->hasSuperUserAccess()) {
$ex = new \Piwik\Exception\Exception(Piwik::translate('Widgetize_TooHighAccessLevel',
['<a href="' . Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/troubleshooting/faq_147/') . '" rel="noreferrer noopener">', '</a>']));
$ex = new \Piwik\Exception\Exception(Piwik::translate(
'Widgetize_TooHighAccessLevel',
['<a href="' . Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/troubleshooting/faq_147/') . '" rel="noreferrer noopener">', '</a>']
));
$ex->setIsHtmlMessage();
throw $ex;
}
Expand All @@ -491,9 +493,11 @@ public static function checkTokenAuthIsNotLimited($module, $action)
//
// NOTE: this does not apply if the [General] enable_framed_allow_write_admin_token_auth INI
// option is set.
$ex = new \Piwik\Exception\Exception(Piwik::translate('Widgetize_ViewAccessRequired',
$ex = new \Piwik\Exception\Exception(Piwik::translate(
'Widgetize_ViewAccessRequired',
['<a href="' . Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/troubleshooting/faq_147/') .
'" rel="noreferrer noopener">https://matomo.org/faq/troubleshooting/faq_147/</a>']));
'" rel="noreferrer noopener">https://matomo.org/faq/troubleshooting/faq_147/</a>']
));
$ex->setIsHtmlMessage();
throw $ex;
}
Expand Down
21 changes: 12 additions & 9 deletions core/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,11 @@ public function getSitesIdWithAtLeastViewAccess()
$this->loadSitesIfNeeded();

return array_unique(array_merge(
$this->idsitesByAccess['view'],
$this->idsitesByAccess['write'],
$this->idsitesByAccess['admin'],
$this->idsitesByAccess['superuser']));
$this->idsitesByAccess['view'],
$this->idsitesByAccess['write'],
$this->idsitesByAccess['admin'],
$this->idsitesByAccess['superuser']
));
}

/**
Expand All @@ -381,9 +382,10 @@ public function getSitesIdWithAtLeastWriteAccess()
$this->loadSitesIfNeeded();

return array_unique(array_merge(
$this->idsitesByAccess['write'],
$this->idsitesByAccess['admin'],
$this->idsitesByAccess['superuser']));
$this->idsitesByAccess['write'],
$this->idsitesByAccess['admin'],
$this->idsitesByAccess['superuser']
));
}

/**
Expand All @@ -397,8 +399,9 @@ public function getSitesIdWithAdminAccess()
$this->loadSitesIfNeeded();

return array_unique(array_merge(
$this->idsitesByAccess['admin'],
$this->idsitesByAccess['superuser']));
$this->idsitesByAccess['admin'],
$this->idsitesByAccess['superuser']
));
}

/**
Expand Down
16 changes: 11 additions & 5 deletions core/Application/Kernel/EnvironmentValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ private function getMessageWhenFileExistsButNotReadable($path)
$format = "\n » %s \n";
}

return sprintf($format,
$this->translator->translate('General_ExceptionConfigurationFilePleaseCheckReadableByUser',
array($path, Filechecks::getUser())));
return sprintf(
$format,
$this->translator->translate(
'General_ExceptionConfigurationFilePleaseCheckReadableByUser',
array($path, Filechecks::getUser())
)
);
}

/**
Expand All @@ -137,8 +141,10 @@ private function getSpecificMessageWhetherFileExistsOrNot($path)
$message .= $this->getMessageWhenFileExistsButNotReadable($path);
}
} else {
$message = $this->translator->translate('General_ExceptionConfigurationFileExistsButNotReadable',
array($path));
$message = $this->translator->translate(
'General_ExceptionConfigurationFileExistsButNotReadable',
array($path)
);
$message .= $this->getMessageWhenFileExistsButNotReadable($path);
}

Expand Down
11 changes: 9 additions & 2 deletions core/Archive/ArchiveInvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,15 @@ public function reArchiveReport($idSites, string $plugin = null, string $report
) {
foreach ($idSites as $idSite) {
foreach (Rules::getSegmentsToProcess([$idSite]) as $segment) {
$this->markArchivesAsInvalidated($idSites, $dates, 'day', new Segment($segment, [$idSite]),
$cascadeDown = false, $forceInvalidateRanges = false, $name);
$this->markArchivesAsInvalidated(
$idSites,
$dates,
'day',
new Segment($segment, [$idSite]),
$cascadeDown = false,
$forceInvalidateRanges = false,
$name
);
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions core/Archive/ArchivePurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ protected function getDeletedSegmentArchiveIds(Date $date, array $deletedSegment
{
$archiveTable = ArchiveTableCreator::getNumericTable($date);
return $this->model->getArchiveIdsForSegments(
$archiveTable, $deletedSegments, $this->getOldestTemporaryArchiveToKeepThreshold()
$archiveTable,
$deletedSegments,
$this->getOldestTemporaryArchiveToKeepThreshold()
);
}

Expand Down Expand Up @@ -236,7 +238,11 @@ public function purgeArchivesWithPeriodRange(Date $date)
$blobTable = ArchiveTableCreator::getBlobTable($date);

$deletedCount = $this->model->deleteArchivesWithPeriod(
$numericTable, $blobTable, Piwik::$idPeriods['range'], $this->purgeCustomRangesOlderThan);
$numericTable,
$blobTable,
Piwik::$idPeriods['range'],
$this->purgeCustomRangesOlderThan
);

$level = $deletedCount == 0 ? 'debug' : 'info';
$this->logger->$level("Purged {count} range archive rows from {numericTable} & {blobTable}.", array(
Expand Down
24 changes: 21 additions & 3 deletions core/Archive/DataCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,13 @@ public function getIndexedArray($resultIndices)
public function getDataTable($resultIndices)
{
$dataTableFactory = new DataTableFactory(
$this->dataNames, $this->dataType, $this->sitesId, $this->periods, $this->segment, $this->defaultRow);
$this->dataNames,
$this->dataType,
$this->sitesId,
$this->periods,
$this->segment,
$this->defaultRow
);

$index = $this->getIndexedArray($resultIndices);

Expand All @@ -254,7 +260,13 @@ public function getDataTable($resultIndices)
public function getMergedDataTable($resultIndices)
{
$dataTableFactory = new DataTableFactory(
$this->dataNames, $this->dataType, $this->sitesId, $this->periods, $this->segment, $this->defaultRow);
$this->dataNames,
$this->dataType,
$this->sitesId,
$this->periods,
$this->segment,
$this->defaultRow
);

$index = $this->getIndexedArray($resultIndices);

Expand Down Expand Up @@ -286,7 +298,13 @@ public function getExpandedDataTable($resultIndices, $idSubTable = null, $depth
$this->checkExpandedMethodPrerequisites();

$dataTableFactory = new DataTableFactory(
$this->dataNames, 'blob', $this->sitesId, $this->periods, $this->segment, $this->defaultRow);
$this->dataNames,
'blob',
$this->sitesId,
$this->periods,
$this->segment,
$this->defaultRow
);
$dataTableFactory->expandDataTable($depth, $addMetadataSubTableId);
$dataTableFactory->useSubtable($idSubTable);

Expand Down
17 changes: 13 additions & 4 deletions core/ArchiveProcessor/ArchivingStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,19 @@ public function getSitesCurrentlyArchiving()
*/
private function makeArchivingLock(Parameters $params)
{
$doneFlag = Rules::getDoneStringFlagFor([$params->getSite()->getId()], $params->getSegment(),
$params->getPeriod()->getLabel(), $params->getRequestedPlugin());
return $this->makeArchivingLockFromDoneFlag($params->getSite()->getId(), $params->getSite()->getId(), $params->getPeriod()->getDateStart()->toString(),
$params->getPeriod()->getDateEnd()->toString(), $doneFlag);
$doneFlag = Rules::getDoneStringFlagFor(
[$params->getSite()->getId()],
$params->getSegment(),
$params->getPeriod()->getLabel(),
$params->getRequestedPlugin()
);
return $this->makeArchivingLockFromDoneFlag(
$params->getSite()->getId(),
$params->getSite()->getId(),
$params->getPeriod()->getDateStart()->toString(),
$params->getPeriod()->getDateEnd()->toString(),
$doneFlag
);
}

private function makeArchivingLockFromDoneFlag($idSite, $date1, $date2, $period, $doneFlag)
Expand Down
14 changes: 11 additions & 3 deletions core/ArchiveProcessor/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,12 @@ protected function insertArchiveData($visits, $visitsConverted, $existingArchive
*/
private function makeArchivingLockId()
{
$doneFlag = Rules::getDoneStringFlagFor([$this->params->getSite()->getId()], $this->params->getSegment(),
$this->params->getPeriod()->getLabel(), $this->params->getRequestedPlugin());
$doneFlag = Rules::getDoneStringFlagFor(
[$this->params->getSite()->getId()],
$this->params->getSegment(),
$this->params->getPeriod()->getLabel(),
$this->params->getRequestedPlugin()
);

return $this->params->getPeriod()->getDateStart()->toString() . $this->params->getPeriod()->getDateEnd()->toString() . '.' . $doneFlag;
}
Expand Down Expand Up @@ -605,7 +609,11 @@ private function shouldForceInvalidatedArchive($value, $tsArchived)

// if coming from a browser request, and period does contain today, check the ttl for the period (done just below this)
$minDatetimeArchiveProcessedUTC = Rules::getMinTimeProcessedForInProgressArchive(
$params->getDateStart(), $params->getPeriod(), $params->getSegment(), $params->getSite());
$params->getDateStart(),
$params->getPeriod(),
$params->getSegment(),
$params->getSite()
);
$minDatetimeArchiveProcessedUTC = Date::factory($minDatetimeArchiveProcessedUTC);
if ($minDatetimeArchiveProcessedUTC
&& Date::factory($tsArchived)->isEarlier($minDatetimeArchiveProcessedUTC)
Expand Down
21 changes: 14 additions & 7 deletions core/ArchiveProcessor/PluginsArchiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,12 @@ public function callAggregateCoreMetrics()
*/
public function callAggregateAllPlugins($visits, $visitsConverted, $forceArchivingWithoutVisits = false)
{
Log::debug("PluginsArchiver::%s: Initializing archiving process for all plugins [visits = %s, visits converted = %s]",
__FUNCTION__, $visits, $visitsConverted);
Log::debug(
"PluginsArchiver::%s: Initializing archiving process for all plugins [visits = %s, visits converted = %s]",
__FUNCTION__,
$visits,
$visitsConverted
);

/** @var Logger $performanceLogger */
$performanceLogger = StaticContainer::get(Logger::class);
Expand Down Expand Up @@ -189,7 +193,8 @@ public function callAggregateAllPlugins($visits, $visitsConverted, $forceArchivi

$performanceLogger->logMeasurement('plugin', $pluginName, $this->params, $timer);

Log::debug("PluginsArchiver::%s: %s while archiving %s reports for plugin '%s' %s.",
Log::debug(
"PluginsArchiver::%s: %s while archiving %s reports for plugin '%s' %s.",
__FUNCTION__,
$timer->getMemoryLeak(),
$this->params->getPeriod()->getLabel(),
Expand Down Expand Up @@ -284,10 +289,12 @@ protected function shouldProcessReportsForPlugin($pluginName)
return false;
}

if (Rules::shouldProcessReportsAllPlugins(
array($this->params->getSite()->getId()),
$this->params->getSegment(),
$this->params->getPeriod()->getLabel())
if (
Rules::shouldProcessReportsAllPlugins(
[$this->params->getSite()->getId()],
$this->params->getSegment(),
$this->params->getPeriod()->getLabel()
)
) {
return true;
}
Expand Down
6 changes: 4 additions & 2 deletions core/ArchiveProcessor/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ public static function getMinTimeProcessedForInProgressArchive(
// This week, this month, this year:
// accept any archive that was processed today after 00:00:01 this morning
$timezone = $site->getTimezone();
$minimumArchiveTime = Date::factory(Date::factory('now',
$timezone)->getDateStartUTC())->setTimezone($timezone)->getTimestamp();
$minimumArchiveTime = Date::factory(Date::factory(
'now',
$timezone
)->getDateStartUTC())->setTimezone($timezone)->getTimestamp();
}
}
return $minimumArchiveTime;
Expand Down
3 changes: 2 additions & 1 deletion core/Changes/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public function addChange(string $pluginName, array $change): void
if(!isset($change['version']) || !isset($change['title']) || !isset($change['description'])) {
StaticContainer::get(LoggerInterface::class)->warning(
"Change item for plugin {plugin} missing version, title or description fields - ignored",
['plugin' => $pluginName]);
['plugin' => $pluginName]
);
return;
}

Expand Down
12 changes: 10 additions & 2 deletions core/CliMulti.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,16 @@ private function buildCommand($hostname, $query, $outputFileIfAsync, $doEsacpeAr
$query = escapeshellarg($query);
}

return sprintf('%s %s %s/console climulti:request -q --matomo-domain=%s %s %s %s',
$bin, $this->phpCliOptions, PIWIK_INCLUDE_PATH, $hostname, $superuserCommand, $query, $append);
return sprintf(
'%s %s %s/console climulti:request -q --matomo-domain=%s %s %s %s',
$bin,
$this->phpCliOptions,
PIWIK_INCLUDE_PATH,
$hostname,
$superuserCommand,
$query,
$append
);
}

private function getResponse()
Expand Down
6 changes: 4 additions & 2 deletions core/Concurrency/LockBackend/MySqlLockBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ public function setIfNotExists($key, $value, $ttlInSeconds)
Db::query($sql, array($key));
}

$query = sprintf('INSERT INTO %s (`key`, `value`, `expiry_time`)
$query = sprintf(
'INSERT INTO %s (`key`, `value`, `expiry_time`)
VALUES (?,?,(UNIX_TIMESTAMP() + ?))',
$tablePrefixed);
$tablePrefixed
);
// we make sure to update the row if the key is expired and consider it as "deleted"

try {
Expand Down
Loading

0 comments on commit e61eb91

Please sign in to comment.