Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply coding style around FunctionCallSignature #2 #21928

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions core/Db/Schema/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,14 @@ public function createTable($nameWithoutPrefix, $createDefinition)
$dbSettings = new Db\Settings();
$charset = $dbSettings->getUsedCharset();

$statement = sprintf("CREATE TABLE IF NOT EXISTS `%s` ( %s ) ENGINE=%s DEFAULT CHARSET=%s %s;",
Common::prefixTable($nameWithoutPrefix),
$createDefinition,
$this->getTableEngine(),
$charset,
$dbSettings->getRowFormat());
$statement = sprintf(
"CREATE TABLE IF NOT EXISTS `%s` ( %s ) ENGINE=%s DEFAULT CHARSET=%s %s;",
Common::prefixTable($nameWithoutPrefix),
$createDefinition,
$this->getTableEngine(),
$charset,
$dbSettings->getRowFormat()
);

try {
Db::exec($statement);
Expand Down
38 changes: 31 additions & 7 deletions core/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,26 @@ public static function sendHttpRequest(
$file = self::ensureDestinationDirectoryExists($destinationPath);

$acceptLanguage = $acceptLanguage ? 'Accept-Language: ' . $acceptLanguage : '';
return self::sendHttpRequestBy(self::getTransportMethod(), $aUrl, $timeout, $userAgent, $destinationPath, $file,
$followDepth, $acceptLanguage, $acceptInvalidSslCertificate = false, $byteRange, $getExtendedInfo, $httpMethod,
$httpUsername, $httpPassword, null, [], null, $checkHostIsAllowed);
return self::sendHttpRequestBy(
self::getTransportMethod(),
$aUrl,
$timeout,
$userAgent,
$destinationPath,
$file,
$followDepth,
$acceptLanguage,
$acceptInvalidSslCertificate = false,
$byteRange,
$getExtendedInfo,
$httpMethod,
$httpUsername,
$httpPassword,
null,
[],
null,
$checkHostIsAllowed
);
}

public static function ensureDestinationDirectoryExists($destinationPath)
Expand Down Expand Up @@ -882,7 +899,8 @@ public static function downloadChunk($url, $outputPath, $isContinuation)
) {
throw new Exception(
Piwik::translate('General_DownloadFail_FileExists', "'" . $outputPath . "'")
. ' ' . Piwik::translate('General_DownloadPleaseRemoveExisting'));
. ' ' . Piwik::translate('General_DownloadPleaseRemoveExisting')
);
}

// if we're starting a download, get the expected file size & save as an option
Expand Down Expand Up @@ -924,7 +942,8 @@ public static function downloadChunk($url, $outputPath, $isContinuation)
if ($existingSize >= $expectedFileSize) {
throw new Exception(
Piwik::translate('General_DownloadFail_FileExistsContinue', "'" . $outputPath . "'")
. ' ' . Piwik::translate('General_DownloadPleaseRemoveExisting'));
. ' ' . Piwik::translate('General_DownloadPleaseRemoveExisting')
);
}

// download a chunk of the file
Expand All @@ -944,8 +963,13 @@ public static function downloadChunk($url, $outputPath, $isContinuation)
|| $result['status'] > 299
) {
$result['data'] = self::truncateStr($result['data'], 1024);
Log::info("Failed to download range '%s-%s' of file from url '%s'. Got result: %s",
$byteRange[0], $byteRange[1], $url, print_r($result, true));
Log::info(
"Failed to download range '%s-%s' of file from url '%s'. Got result: %s",
$byteRange[0],
$byteRange[1],
$url,
print_r($result, true)
);

throw new Exception(Piwik::translate('General_DownloadFail_HttpRequestFail'));
}
Expand Down
17 changes: 14 additions & 3 deletions core/Menu/MenuAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,18 @@ private function buildMenuItem(
private function buildMenu()
{
foreach ($this->menuEntries as $menuEntry) {
$this->buildMenuItem($menuEntry[0], $menuEntry[1], $menuEntry[2], $menuEntry[3], $menuEntry[4],
$menuEntry[5], $menuEntry[6], $menuEntry[7], $menuEntry[8], $menuEntry[9]);
$this->buildMenuItem(
$menuEntry[0],
$menuEntry[1],
$menuEntry[2],
$menuEntry[3],
$menuEntry[4],
$menuEntry[5],
$menuEntry[6],
$menuEntry[7],
$menuEntry[8],
$menuEntry[9]
);
}
}

Expand Down Expand Up @@ -388,7 +398,8 @@ protected function menuCompare($itemOne, $itemTwo)
if ($itemOne['_order'] == $itemTwo['_order']) {
return strcmp(
$itemOne['_name'] ?? '',
$itemTwo['_name'] ?? '');
$itemTwo['_name'] ?? ''
);
}

return ($itemOne['_order'] < $itemTwo['_order']) ? -1 : 1;
Expand Down
5 changes: 3 additions & 2 deletions core/Nonce.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,16 @@ public static function verifyNonceWithErrorMessage($id, $cnonce, $allowedReferre
// The Session cookie is set to a secure cookie, when SSL is mis-configured, it can cause the PHP session cookie ID to change on each page view.
// Indicate to user how to solve this particular use case by forcing secure connections.
if (Url::isSecureConnectionAssumedByPiwikButNotForcedYet()) {
$additionalErrors = '<br/><br/>' . Piwik::translate('Login_InvalidNonceSSLMisconfigured',
$additionalErrors = '<br/><br/>' . Piwik::translate(
'Login_InvalidNonceSSLMisconfigured',
array(
'<a target="_blank" rel="noreferrer noopener" href="' . Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/how-to/faq_91/') . '">',
'</a>',
'config/config.ini.php',
'<pre>force_ssl=1</pre>',
'<pre>[General]</pre>',
)
);
);
}

// validate token
Expand Down
4 changes: 2 additions & 2 deletions core/Period/Year.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ protected function generate()
$year = $this->date->toString("Y");
for ($i = 1; $i <= 12; $i++) {
$this->addSubperiod(new Month(
Date::factory("$year-$i-01")
));
Date::factory("$year-$i-01")
));
}
}

Expand Down
16 changes: 11 additions & 5 deletions core/Piwik.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,13 @@ public static function getQuotientSafe($dividend, $divisor, $precision = 0)
$dividend = 0;
}
if (!is_numeric($dividend) || !is_numeric($divisor)) {
throw new \Exception(sprintf('Trying to round unsupported operands for dividend %s (%s) and divisor %s (%s)',
$dividend, gettype($dividend), $divisor, gettype($divisor)));
throw new \Exception(sprintf(
'Trying to round unsupported operands for dividend %s (%s) and divisor %s (%s)',
$dividend,
gettype($dividend),
$divisor,
gettype($divisor)
));
}
return round($dividend / $divisor, $precision);
}
Expand Down Expand Up @@ -365,7 +370,8 @@ public static function requestTemporarySystemAuthToken($reason, $validForHours)
'System generated ' . $reason,
Date::now()->getDatetime(),
$expireDate,
true);
true
);

return $token[$reason];
}
Expand Down Expand Up @@ -722,9 +728,9 @@ public static function getArrayFromApiParameter($columns, $unique = true)
public static function redirectToModule($newModule, $newAction = '', $parameters = array())
{
$newUrl = 'index.php' . Url::getCurrentQueryStringWithParametersModified(
array('module' => $newModule, 'action' => $newAction)
array('module' => $newModule, 'action' => $newAction)
+ $parameters
);
);
Url::redirectToUrl($newUrl);
}

Expand Down
9 changes: 7 additions & 2 deletions core/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,13 @@ public function findComponent($componentName, $expectedSubclass)
}

if (!empty($expectedSubclass) && !is_subclass_of($classname, $expectedSubclass)) {
Log::warning(sprintf('Cannot use component %s for plugin %s, class %s does not extend %s',
$componentName, $this->pluginName, $classname, $expectedSubclass));
Log::warning(sprintf(
'Cannot use component %s for plugin %s, class %s does not extend %s',
$componentName,
$this->pluginName,
$classname,
$expectedSubclass
));
return null;
}

Expand Down
33 changes: 25 additions & 8 deletions core/Plugin/ComponentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ class ComponentFactory
public static function factory($pluginName, $componentClassSimpleName, $componentTypeClass)
{
if (empty($pluginName) || empty($componentClassSimpleName)) {
Log::debug("ComponentFactory::%s: empty plugin name or component simple name requested (%s, %s)",
__FUNCTION__, $pluginName, $componentClassSimpleName);
Log::debug(
"ComponentFactory::%s: empty plugin name or component simple name requested (%s, %s)",
__FUNCTION__,
$pluginName,
$componentClassSimpleName
);

return null;
}
Expand All @@ -58,8 +62,13 @@ public static function factory($pluginName, $componentClassSimpleName, $componen
}
}

Log::debug("ComponentFactory::%s: Could not find requested component (args = ['%s', '%s', '%s']).",
__FUNCTION__, $pluginName, $componentClassSimpleName, $componentTypeClass);
Log::debug(
"ComponentFactory::%s: Could not find requested component (args = ['%s', '%s', '%s']).",
__FUNCTION__,
$pluginName,
$componentClassSimpleName,
$componentTypeClass
);

return null;
}
Expand Down Expand Up @@ -99,8 +108,13 @@ public static function getComponentIf($componentTypeClass, $pluginName, $predica
}
}

Log::debug("ComponentFactory::%s: Could not find component that satisfies predicate (args = ['%s', '%s', '%s']).",
__FUNCTION__, $componentTypeClass, $pluginName, get_class($predicate));
Log::debug(
"ComponentFactory::%s: Could not find component that satisfies predicate (args = ['%s', '%s', '%s']).",
__FUNCTION__,
$componentTypeClass,
$pluginName,
get_class($predicate)
);

return null;
}
Expand All @@ -115,8 +129,11 @@ private static function getActivatedPlugin($function, $pluginName)
$pluginManager = PluginManager::getInstance();
try {
if (!$pluginManager->isPluginActivated($pluginName)) {
Log::debug("ComponentFactory::%s: component for deactivated plugin ('%s') requested.",
$function, $pluginName);
Log::debug(
"ComponentFactory::%s: component for deactivated plugin ('%s') requested.",
$function,
$pluginName
);

return null;
}
Expand Down
6 changes: 5 additions & 1 deletion core/Plugin/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,11 @@ protected function renderReport($apiAction, $controllerAction = false)
protected function getLastUnitGraph($currentModuleName, $currentControllerAction, $apiMethod)
{
$view = ViewDataTableFactory::build(
Evolution::ID, $apiMethod, $currentModuleName . '.' . $currentControllerAction, $forceDefault = true);
Evolution::ID,
$apiMethod,
$currentModuleName . '.' . $currentControllerAction,
$forceDefault = true
);
$view->config->show_goals = false;
return $view;
}
Expand Down
3 changes: 2 additions & 1 deletion core/Plugin/Dimension/DimensionMetadataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public function getActionReferenceColumnsByTable()

$dimensionIdActionColumns = $this->getVisitActionTableActionReferences();
$result['log_link_visit_action'] = array_unique(
array_merge($result['log_link_visit_action'], $dimensionIdActionColumns));
array_merge($result['log_link_visit_action'], $dimensionIdActionColumns)
);

foreach ($this->actionReferenceColumnsOverride as $table => $columns) {
if (empty($result[$table])) {
Expand Down
6 changes: 4 additions & 2 deletions core/Plugin/ViewDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ public function __construct($controllerAction, $apiMethodToRequestDataTable, $ov

$relatedReportName = $relatedReport->getName();

$this->config->addRelatedReport($relatedReport->getModule() . '.' . $relatedReport->getAction(),
$relatedReportName);
$this->config->addRelatedReport(
$relatedReport->getModule() . '.' . $relatedReport->getAction(),
$relatedReportName
);
}
}

Expand Down
6 changes: 4 additions & 2 deletions core/Plugin/Visualization.php
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,10 @@ private function logMessageIfRequestPropertiesHaveChanged(array $requestProperti
{
$requestProperties = $this->requestConfig->getProperties();

$diff = array_diff_assoc($this->makeSureArrayContainsOnlyStrings($requestProperties),
$this->makeSureArrayContainsOnlyStrings($requestPropertiesBefore));
$diff = array_diff_assoc(
$this->makeSureArrayContainsOnlyStrings($requestProperties),
$this->makeSureArrayContainsOnlyStrings($requestPropertiesBefore)
);

if (!empty($diff['filter_sort_column'])) {
// this here might be ok as it can be changed after data loaded but before filters applied
Expand Down
3 changes: 2 additions & 1 deletion core/ProfessionalServices/Advertising.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public function areAdsForProfessionalServicesEnabled()
*/
public function getPromoUrlForProfessionalServices($campaignMedium, $campaignContent = '')
{
return Url::addCampaignParametersToMatomoLink('https://matomo.org/support-plans/',
return Url::addCampaignParametersToMatomoLink(
'https://matomo.org/support-plans/',
self::CAMPAIGN_NAME_PROFESSIONAL_SERVICES,
null,
$campaignMedium
Expand Down
11 changes: 9 additions & 2 deletions core/ReportRenderer/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,15 @@ private function epilogue()

public function renderFrontPage($reportTitle, $prettyDate, $description, $reportMetadata, $segment)
{
$frontPageView = new View\HtmlReportEmailHeaderView($reportTitle, $prettyDate, $description, $reportMetadata,
$segment, $this->idSite, $this->report['period']);
$frontPageView = new View\HtmlReportEmailHeaderView(
$reportTitle,
$prettyDate,
$description,
$reportMetadata,
$segment,
$this->idSite,
$this->report['period']
);
$this->rendering .= $frontPageView->render();
}

Expand Down
3 changes: 2 additions & 1 deletion core/Scheduler/Schedule/Daily.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public function getRescheduledTime()
$currentTime = $this->getTime();

// Add one day
$rescheduledTime = mktime(date('H', $currentTime),
$rescheduledTime = mktime(
date('H', $currentTime),
date('i', $currentTime),
date('s', $currentTime),
date('n', $currentTime),
Expand Down
3 changes: 2 additions & 1 deletion core/Scheduler/Schedule/Hourly.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public function getRescheduledTime()
$currentTime = $this->getTime();

// Adds one hour and reset the number of minutes
$rescheduledTime = mktime(date('H', $currentTime) + 1,
$rescheduledTime = mktime(
date('H', $currentTime) + 1,
0,
date('s', $currentTime),
date('n', $currentTime),
Expand Down
3 changes: 2 additions & 1 deletion core/Scheduler/Schedule/Monthly.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public function getRescheduledTime()
$currentTime = $this->getTime();

// Adds one month
$rescheduledTime = mktime(date('H', $currentTime),
$rescheduledTime = mktime(
date('H', $currentTime),
date('i', $currentTime),
date('s', $currentTime),
date('n', $currentTime) + 1,
Expand Down
3 changes: 2 additions & 1 deletion core/Scheduler/Schedule/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ protected function adjustHour($rescheduledTime)
{
if ($this->hour !== null) {
// Reset the number of minutes and set the scheduled hour to the one specified with setHour()
$rescheduledTime = mktime($this->hour,
$rescheduledTime = mktime(
$this->hour,
0,
date('s', $rescheduledTime),
date('n', $rescheduledTime),
Expand Down
3 changes: 2 additions & 1 deletion core/Scheduler/Schedule/Weekly.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public function getRescheduledTime()
}

// Adds correct number of days
$rescheduledTime = mktime(date('H', $currentTime),
$rescheduledTime = mktime(
date('H', $currentTime),
date('i', $currentTime),
date('s', $currentTime),
date('n', $currentTime),
Expand Down