From 356e32fc44238f2c0a5d8c6c0d6820f682888edd Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Thu, 15 Feb 2024 02:43:52 +0100 Subject: [PATCH] Apply coding style around FunctionCallSignature #2 (#21928) --- core/Db/Schema/Mysql.php | 14 ++++--- core/Http.php | 38 +++++++++++++++---- core/Menu/MenuAbstract.php | 17 +++++++-- core/Nonce.php | 5 ++- core/Period/Year.php | 4 +- core/Piwik.php | 16 +++++--- core/Plugin.php | 9 ++++- core/Plugin/ComponentFactory.php | 33 ++++++++++++---- core/Plugin/Controller.php | 6 ++- .../Dimension/DimensionMetadataProvider.php | 3 +- core/Plugin/ViewDataTable.php | 6 ++- core/Plugin/Visualization.php | 6 ++- core/ProfessionalServices/Advertising.php | 3 +- core/ReportRenderer/Html.php | 11 +++++- core/Scheduler/Schedule/Daily.php | 3 +- core/Scheduler/Schedule/Hourly.php | 3 +- core/Scheduler/Schedule/Monthly.php | 3 +- core/Scheduler/Schedule/Schedule.php | 3 +- core/Scheduler/Schedule/Weekly.php | 3 +- core/Scheduler/Scheduler.php | 18 ++++++--- core/Segment.php | 12 +++++- core/Session.php | 3 +- core/Session/SessionAuth.php | 3 +- core/Settings/Setting.php | 18 ++++++--- core/SettingsPiwik.php | 25 ++++++------ core/SiteContentDetector.php | 15 +++++++- core/Tracker/GoalManager.php | 8 +++- core/Tracker/Model.php | 4 +- core/Tracker/Request.php | 9 +++-- core/Tracker/Settings.php | 3 +- 30 files changed, 218 insertions(+), 86 deletions(-) diff --git a/core/Db/Schema/Mysql.php b/core/Db/Schema/Mysql.php index 7762c2a03f5..eb6352231f6 100644 --- a/core/Db/Schema/Mysql.php +++ b/core/Db/Schema/Mysql.php @@ -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); diff --git a/core/Http.php b/core/Http.php index 0f52b763b7c..bc1729a5d85 100644 --- a/core/Http.php +++ b/core/Http.php @@ -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) @@ -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 @@ -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 @@ -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')); } diff --git a/core/Menu/MenuAbstract.php b/core/Menu/MenuAbstract.php index d97225dbbb0..347d5876e3f 100644 --- a/core/Menu/MenuAbstract.php +++ b/core/Menu/MenuAbstract.php @@ -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] + ); } } @@ -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; diff --git a/core/Nonce.php b/core/Nonce.php index 5a248639ac5..d1d13dd9b76 100644 --- a/core/Nonce.php +++ b/core/Nonce.php @@ -101,7 +101,8 @@ 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 = '

' . Piwik::translate('Login_InvalidNonceSSLMisconfigured', + $additionalErrors = '

' . Piwik::translate( + 'Login_InvalidNonceSSLMisconfigured', array( '', '', @@ -109,7 +110,7 @@ public static function verifyNonceWithErrorMessage($id, $cnonce, $allowedReferre '
force_ssl=1
', '
[General]
', ) - ); + ); } // validate token diff --git a/core/Period/Year.php b/core/Period/Year.php index 13c70baac31..0d81c5e0c3b 100644 --- a/core/Period/Year.php +++ b/core/Period/Year.php @@ -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") + )); } } diff --git a/core/Piwik.php b/core/Piwik.php index 0cf7d2b5be6..5402a22cfcd 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -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); } @@ -365,7 +370,8 @@ public static function requestTemporarySystemAuthToken($reason, $validForHours) 'System generated ' . $reason, Date::now()->getDatetime(), $expireDate, - true); + true + ); return $token[$reason]; } @@ -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); } diff --git a/core/Plugin.php b/core/Plugin.php index 7106803dc97..edc81936391 100644 --- a/core/Plugin.php +++ b/core/Plugin.php @@ -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; } diff --git a/core/Plugin/ComponentFactory.php b/core/Plugin/ComponentFactory.php index d79a2f2959e..7654dbdcd0d 100644 --- a/core/Plugin/ComponentFactory.php +++ b/core/Plugin/ComponentFactory.php @@ -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; } @@ -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; } @@ -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; } @@ -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; } diff --git a/core/Plugin/Controller.php b/core/Plugin/Controller.php index ad183e790e1..97a86522e41 100644 --- a/core/Plugin/Controller.php +++ b/core/Plugin/Controller.php @@ -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; } diff --git a/core/Plugin/Dimension/DimensionMetadataProvider.php b/core/Plugin/Dimension/DimensionMetadataProvider.php index 6484e323f9c..d767fcecec3 100644 --- a/core/Plugin/Dimension/DimensionMetadataProvider.php +++ b/core/Plugin/Dimension/DimensionMetadataProvider.php @@ -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])) { diff --git a/core/Plugin/ViewDataTable.php b/core/Plugin/ViewDataTable.php index 529b19d2ead..5f61c484eaa 100644 --- a/core/Plugin/ViewDataTable.php +++ b/core/Plugin/ViewDataTable.php @@ -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 + ); } } diff --git a/core/Plugin/Visualization.php b/core/Plugin/Visualization.php index 034fe63f2ae..2f454760f6e 100644 --- a/core/Plugin/Visualization.php +++ b/core/Plugin/Visualization.php @@ -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 diff --git a/core/ProfessionalServices/Advertising.php b/core/ProfessionalServices/Advertising.php index ad16a15ec67..29a0665c702 100644 --- a/core/ProfessionalServices/Advertising.php +++ b/core/ProfessionalServices/Advertising.php @@ -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 diff --git a/core/ReportRenderer/Html.php b/core/ReportRenderer/Html.php index 71b77c00dcc..79c28175eda 100644 --- a/core/ReportRenderer/Html.php +++ b/core/ReportRenderer/Html.php @@ -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(); } diff --git a/core/Scheduler/Schedule/Daily.php b/core/Scheduler/Schedule/Daily.php index 8c402300885..7e1ac006a04 100644 --- a/core/Scheduler/Schedule/Daily.php +++ b/core/Scheduler/Schedule/Daily.php @@ -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), diff --git a/core/Scheduler/Schedule/Hourly.php b/core/Scheduler/Schedule/Hourly.php index 69f48891482..ac1815eaf92 100644 --- a/core/Scheduler/Schedule/Hourly.php +++ b/core/Scheduler/Schedule/Hourly.php @@ -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), diff --git a/core/Scheduler/Schedule/Monthly.php b/core/Scheduler/Schedule/Monthly.php index fb5e7dabb0e..46d6a866698 100644 --- a/core/Scheduler/Schedule/Monthly.php +++ b/core/Scheduler/Schedule/Monthly.php @@ -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, diff --git a/core/Scheduler/Schedule/Schedule.php b/core/Scheduler/Schedule/Schedule.php index e7b40321218..552d9926c1b 100644 --- a/core/Scheduler/Schedule/Schedule.php +++ b/core/Scheduler/Schedule/Schedule.php @@ -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), diff --git a/core/Scheduler/Schedule/Weekly.php b/core/Scheduler/Schedule/Weekly.php index 95c4f6cd6fc..b847036de5a 100644 --- a/core/Scheduler/Schedule/Weekly.php +++ b/core/Scheduler/Schedule/Weekly.php @@ -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), diff --git a/core/Scheduler/Scheduler.php b/core/Scheduler/Scheduler.php index 2a265fc7e6d..0c34910cdec 100644 --- a/core/Scheduler/Scheduler.php +++ b/core/Scheduler/Scheduler.php @@ -161,16 +161,20 @@ public function run() // Task has already been retried three times, give up $this->timetable->clearRetryCount($task->getName()); - $this->logger->warning("Scheduler: '{task}' has already been retried three times, giving up", - ['task' => $task->getName()]); + $this->logger->warning( + "Scheduler: '{task}' has already been retried three times, giving up", + ['task' => $task->getName()] + ); } else { $readFromOption = true; $rescheduledDate = $this->timetable->rescheduleTaskAndRunInOneHour($task); $this->timetable->incrementRetryCount($task->getName()); - $this->logger->info("Scheduler: '{task}' retry scheduled for {date}", - ['task' => $task->getName(), 'date' => $rescheduledDate]); + $this->logger->info( + "Scheduler: '{task}' retry scheduled for {date}", + ['task' => $task->getName(), 'date' => $rescheduledDate] + ); } $this->scheduleRetry = false; } else { @@ -308,8 +312,10 @@ private function executeTask($task) call_user_func($callable, $task->getMethodParameter()); $message = $timer->__toString(); } catch (\Exception $e) { - $this->logger->error("Scheduler: Error {errorMessage} for task '{task}'", - ['errorMessage' => $e->getMessage(), 'task' => $task->getName()]); + $this->logger->error( + "Scheduler: Error {errorMessage} for task '{task}'", + ['errorMessage' => $e->getMessage(), 'task' => $task->getName()] + ); $message = 'ERROR: ' . $e->getMessage(); // If the task has indicated that retrying on exception is safe then flag for rescheduling diff --git a/core/Segment.php b/core/Segment.php index 28c88e70285..b6c1c5ac279 100644 --- a/core/Segment.php +++ b/core/Segment.php @@ -592,8 +592,16 @@ public function getSelectQuery($select, $from, $where = false, $bind = array(), if ($forceGroupBy && $groupBy) { $this->segmentQueryBuilder->forceInnerGroupBySubselect(LogQueryBuilder::FORCE_INNER_GROUP_BY_NO_SUBSELECT); } - $result = $this->segmentQueryBuilder->getSelectQueryString($segmentExpression, $select, $from, $where, $bind, - $groupBy, $orderBy, $limitAndOffset); + $result = $this->segmentQueryBuilder->getSelectQueryString( + $segmentExpression, + $select, + $from, + $where, + $bind, + $groupBy, + $orderBy, + $limitAndOffset + ); } catch (Exception $e) { if ($forceGroupBy && $groupBy) { $this->segmentQueryBuilder->forceInnerGroupBySubselect(''); diff --git a/core/Session.php b/core/Session.php index 78f773cfba1..ae374ce2157 100644 --- a/core/Session.php +++ b/core/Session.php @@ -127,7 +127,8 @@ public static function start($options = false) $pathToSessions = Filechecks::getErrorMessageMissingPermissions(self::getSessionsDirectory()); } - $message = sprintf("Error: %s %s\n
Debug: the original error was \n%s
", + $message = sprintf( + "Error: %s %s\n
Debug: the original error was \n%s
", Piwik::translate('General_ExceptionUnableToStartSession'), $pathToSessions, $e->getMessage() diff --git a/core/Session/SessionAuth.php b/core/Session/SessionAuth.php index 2051eeb4d1f..43695d919f6 100644 --- a/core/Session/SessionAuth.php +++ b/core/Session/SessionAuth.php @@ -238,7 +238,8 @@ private function checkIfSessionFailedToRead() { if (Session\SaveHandler\DbTable::$wasSessionToLargeToRead) { StaticContainer::get(LoggerInterface::class)->warning( - "Too much data stored in the session so it could not be read properly. If you were logged out, this is why."); + "Too much data stored in the session so it could not be read properly. If you were logged out, this is why." + ); } } } diff --git a/core/Settings/Setting.php b/core/Settings/Setting.php index 02fa8759715..42aa094676f 100644 --- a/core/Settings/Setting.php +++ b/core/Settings/Setting.php @@ -255,8 +255,10 @@ private function validateValue($value) } // TODO move error message creation to a subclass, eg in MeasurableSettings we do not want to mention plugin name - $errorMsg = Piwik::translate('CoreAdminHome_PluginSettingsValueNotAllowed', - array(strip_tags($config->title), $this->pluginName)); + $errorMsg = Piwik::translate( + 'CoreAdminHome_PluginSettingsValueNotAllowed', + array(strip_tags($config->title), $this->pluginName) + ); if (is_array($value) && $this->type === FieldConfig::TYPE_ARRAY) { foreach ($value as $val) { @@ -272,15 +274,19 @@ private function validateValue($value) } elseif ($this->type === FieldConfig::TYPE_INT || $this->type === FieldConfig::TYPE_FLOAT) { if (!is_numeric($value)) { - $errorMsg = Piwik::translate('CoreAdminHome_PluginSettingsValueNotAllowed', - array(strip_tags($config->title), $this->pluginName)); + $errorMsg = Piwik::translate( + 'CoreAdminHome_PluginSettingsValueNotAllowed', + array(strip_tags($config->title), $this->pluginName) + ); throw new \Exception($errorMsg); } } elseif ($this->type === FieldConfig::TYPE_BOOL) { if (!in_array($value, array(true, false, '0', '1', 0, 1), true)) { - $errorMsg = Piwik::translate('CoreAdminHome_PluginSettingsValueNotAllowed', - array(strip_tags($config->title), $this->pluginName)); + $errorMsg = Piwik::translate( + 'CoreAdminHome_PluginSettingsValueNotAllowed', + array(strip_tags($config->title), $this->pluginName) + ); throw new \Exception($errorMsg); } } diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php index 4a2862c7be7..ae839bcecf1 100644 --- a/core/SettingsPiwik.php +++ b/core/SettingsPiwik.php @@ -166,8 +166,10 @@ public static function getKnownSegmentsToArchiveForSite($idSite): array */ public static function getWebsitesCountToDisplay(): int { - $count = max(Config::getInstance()->General['site_selector_max_sites'], - Config::getInstance()->General['autocomplete_min_sites']); + $count = max( + Config::getInstance()->General['site_selector_max_sites'], + Config::getInstance()->General['autocomplete_min_sites'] + ); return (int)$count; } @@ -369,15 +371,16 @@ public static function checkPiwikServerWorking(string $piwikServerUrl, bool $acc { // Now testing if the webserver is running try { - $fetched = Http::sendHttpRequestBy('curl', - $piwikServerUrl, - $timeout = 45, - $userAgent = null, - $destinationPath = null, - $file = null, - $followDepth = 0, - $acceptLanguage = false, - $acceptInvalidSSLCertificates + $fetched = Http::sendHttpRequestBy( + 'curl', + $piwikServerUrl, + $timeout = 45, + $userAgent = null, + $destinationPath = null, + $file = null, + $followDepth = 0, + $acceptLanguage = false, + $acceptInvalidSSLCertificates ); } catch (Exception $e) { $fetched = "ERROR fetching: " . $e->getMessage(); diff --git a/core/SiteContentDetector.php b/core/SiteContentDetector.php index 7c563c0cf7c..68af539d074 100644 --- a/core/SiteContentDetector.php +++ b/core/SiteContentDetector.php @@ -372,8 +372,19 @@ private function requestSiteResponse(string $url, int $timeOut): array $siteData = []; try { - $siteData = Http::sendHttpRequestBy(Http::getTransportMethod(), $url, $timeOut, null, null, - null, 0, false, true, false, true); + $siteData = Http::sendHttpRequestBy( + Http::getTransportMethod(), + $url, + $timeOut, + null, + null, + null, + 0, + false, + true, + false, + true + ); } catch (\Exception $e) { } diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php index c2c307c237e..f7785fd1187 100644 --- a/core/Tracker/GoalManager.php +++ b/core/Tracker/GoalManager.php @@ -389,7 +389,10 @@ protected function recordEcommerceGoal(VisitProperties $visitProperties, Request if ($isThereExistingCartInVisit) { $recorded = $this->getModel()->updateConversion( - $visitProperties->getProperty('idvisit'), self::IDGOAL_CART, $conversion); + $visitProperties->getProperty('idvisit'), + self::IDGOAL_CART, + $conversion + ); } else { $recorded = $this->insertNewConversion($conversion, $visitProperties->getProperties(), $request, $action); } @@ -457,7 +460,8 @@ protected function recordEcommerceItems($goal, $items) //Item in the cart in the DB, but not anymore in the cart if (!isset($itemInCartBySku[$itemInDb[0]])) { - $itemToUpdate = array_merge($itemInDb, + $itemToUpdate = array_merge( + $itemInDb, array('deleted' => 1, 'idorder_original_value' => $itemInDbOriginal['idorder_original_value'] ) diff --git a/core/Tracker/Model.php b/core/Tracker/Model.php index 153237b7e7b..1f80029e904 100644 --- a/core/Tracker/Model.php +++ b/core/Tracker/Model.php @@ -568,8 +568,8 @@ private function findVisitorByVisitorId($idVisitor, $select, $from, $where, $bin $cache = Cache::getCacheGeneral(); // use INDEX index_idsite_idvisitor_time (idsite, idvisitor, visit_last_action_time) if available - if (array_key_exists(self::CACHE_KEY_INDEX_IDSITE_IDVISITOR_TIME, - $cache) && true === $cache[self::CACHE_KEY_INDEX_IDSITE_IDVISITOR_TIME]) { + if (array_key_exists(self::CACHE_KEY_INDEX_IDSITE_IDVISITOR_TIME, $cache) + && true === $cache[self::CACHE_KEY_INDEX_IDSITE_IDVISITOR_TIME]) { $from .= ' FORCE INDEX (index_idsite_idvisitor_time) '; } diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php index 49f747c9860..439e91c3be3 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -92,8 +92,10 @@ public function __construct($params, $tokenAuth = false) // check for 4byte utf8 characters in all tracking params and replace them with � if not support by database $this->params = $this->replaceUnsupportedUtf8Chars($this->params); - $this->customTimestampDoesNotRequireTokenauthWhenNewerThan = (int) TrackerConfig::getConfigValue('tracking_requests_require_authentication_when_custom_timestamp_newer_than', - $this->getIdSiteIfExists()); + $this->customTimestampDoesNotRequireTokenauthWhenNewerThan = (int) TrackerConfig::getConfigValue( + 'tracking_requests_require_authentication_when_custom_timestamp_newer_than', + $this->getIdSiteIfExists() + ); } protected function replaceUnsupportedUtf8Chars($value, $key = false) @@ -693,7 +695,8 @@ protected function makeThirdPartyCookieUID() $cookie = new Cookie( $this->getCookieName(), $this->getCookieExpire(), - $this->getCookiePath()); + $this->getCookiePath() + ); $domain = $this->getCookieDomain(); if (!empty($domain)) { diff --git a/core/Tracker/Settings.php b/core/Tracker/Settings.php index ec46e0cc869..96e640164fe 100644 --- a/core/Tracker/Settings.php +++ b/core/Tracker/Settings.php @@ -110,7 +110,8 @@ public function getConfigId(Request $request, $ipAddress) $plugin_Cookie, $ipAddress, $browserLang, - $fingerprintSalt); + $fingerprintSalt + ); } /**