Skip to content

Commit

Permalink
[Coding Style] Enable rule Squiz.ControlStructures.ControlSignature.S…
Browse files Browse the repository at this point in the history
…paceAfterKeyword (#22098)

* [Coding Style] Enable rule Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword

* Apply CS
  • Loading branch information
michalkleiner committed Apr 11, 2024
1 parent 6ca6c34 commit 73823f7
Show file tree
Hide file tree
Showing 120 changed files with 212 additions and 214 deletions.
6 changes: 3 additions & 3 deletions core/API/DocumentationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function prepareMethodToDisplay($moduleName, $info, $methods, $class,
{
$str = '';
$str .= "\n<a name='$moduleName' id='$moduleName'></a>";
if($displayTitlesAsEnrichedHeadline) {
if ($displayTitlesAsEnrichedHeadline) {
$str .= "<div vue-entry=\"CoreHome.ContentBlock\" content-title='Module " . $moduleName . "'>";
} else {
$str .= "<h2>Module " . $moduleName . "</h2>";
Expand All @@ -105,7 +105,7 @@ protected function prepareMethodToDisplay($moduleName, $info, $methods, $class,
$str .= "</div>\n";
}

if($displayTitlesAsEnrichedHeadline) {
if ($displayTitlesAsEnrichedHeadline) {
$str .= "</div>";
}

Expand Down Expand Up @@ -343,7 +343,7 @@ protected function getParametersString($class, $name)

$str = '';

if(!empty($parameter['type'])) {
if (!empty($parameter['type'])) {
$prefix = $parameter['allowsNull'] ? '?' : '';
$str = '<i>' . $prefix . $parameter['type'] . '</i> ';
}
Expand Down
8 changes: 4 additions & 4 deletions core/Application/Kernel/EnvironmentValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ public function validate()
{
$this->checkConfigFileExists($this->settingsProvider->getPathGlobal());

if(SettingsPiwik::isMatomoInstalled()) {
if (SettingsPiwik::isMatomoInstalled()) {
$this->checkConfigFileExists($this->settingsProvider->getPathLocal(), $startInstaller = false);
return;
}

$startInstaller = true;

if(SettingsServer::isTrackerApiRequest()) {
if (SettingsServer::isTrackerApiRequest()) {
// if Piwik is not installed yet, the piwik.php should do nothing and not return an error
throw new NotYetInstalledException("As Matomo is not installed yet, the Tracking API cannot proceed and will exit without error.");
}

if(Common::isPhpCliMode()) {
if (Common::isPhpCliMode()) {
// in CLI, do not start/redirect to installer, simply output the exception at the top
$startInstaller = false;
}
Expand Down Expand Up @@ -117,7 +117,7 @@ private function startInstallation($exception)
private function getMessageWhenFileExistsButNotReadable($path)
{
$format = " \n<b>» %s </b>";
if(Common::isPhpCliMode()) {
if (Common::isPhpCliMode()) {
$format = "\n » %s \n";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function getMergedAssets()
$this->lessCompiler->setFormatter('classic');
try {
$compiled = $this->lessCompiler->compile($concatenatedAssets);
} catch(\Exception $e) {
} catch (\Exception $e) {
// save the concated less files so we can debug the issue
$this->saveConcatenatedAssets($concatenatedAssets);

Expand Down
2 changes: 1 addition & 1 deletion core/Changes/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function removeChanges(string $pluginName): void
*/
public function addChange(string $pluginName, array $change): void
{
if(!isset($change['version']) || !isset($change['title']) || !isset($change['description'])) {
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]
Expand Down
4 changes: 2 additions & 2 deletions core/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ public static function isPhpCliMode()
return self::$isCliMode;
}

if(PHP_SAPI === 'cli') {
if (PHP_SAPI === 'cli') {
return true;
}

if(self::isPhpCgiType() && (!isset($_SERVER['REMOTE_ADDR']) || empty($_SERVER['REMOTE_ADDR']))) {
if (self::isPhpCgiType() && (!isset($_SERVER['REMOTE_ADDR']) || empty($_SERVER['REMOTE_ADDR']))) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion core/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function deleteLocalConfig()
{
$configLocal = $this->getLocalPath();

if(file_exists($configLocal)) {
if (file_exists($configLocal)) {
@unlink($configLocal);
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private function getCommandsFromPluginsMarkedInConfig()
$plugins = explode(',', $plugins);

$commands = array();
foreach($plugins as $plugin) {
foreach ($plugins as $plugin) {
$instance = new Plugin($plugin);
$commands = array_merge($commands, $instance->findMultipleComponents('Commands', 'Piwik\\Plugin\\ConsoleCommand'));
}
Expand Down
2 changes: 1 addition & 1 deletion core/CronArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ private function logNetworkError($url, $response)
if (empty($response)) {
$message .= "The response was empty. This usually means a server error. A solution to this error is generally to increase the value of 'memory_limit' in your php.ini file. ";

if($this->supportsAsync) {
if ($this->supportsAsync) {
$message .= " For more information and the error message please check in your PHP CLI error log file. As this core:archive command triggers PHP processes over the CLI, you can find where PHP CLI logs are stored by running this command: php -i | grep error_log";
} else {
$message .= " For more information and the error message please check your web server's error Log file. As this core:archive command triggers PHP processes over HTTP, you can find the error message in your Matomo's web server error logs. ";
Expand Down
2 changes: 1 addition & 1 deletion core/DataAccess/LogQueryBuilder/JoinGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function findJoinCriteriasForTables(LogTable $logTable, $availableLogTabl

$otherJoins = $logTable->getWaysToJoinToOtherLogTables();
foreach ($otherJoins as $joinTable => $column) {
if($availableLogTable->getName() == $joinTable) {
if ($availableLogTable->getName() == $joinTable) {
$join = sprintf("`%s`.`%s` = `%s`.`%s`", $table, $column, $availableLogTable->getName(), $column);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion core/DataTable/Filter/ExcludeLowPopulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function __construct($table, $columnToFilter, $minimumValue, $minimumPerc
*/
public function filter($table)
{
if(empty($this->columnToFilter)) {
if (empty($this->columnToFilter)) {
return;
}
$minimumValue = $this->minimumValue;
Expand Down
2 changes: 1 addition & 1 deletion core/DataTable/Renderer/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ protected function formatFormulas($value)

$firstCharCellValue = $valueWithoutFirstPercentSign[0];
$isFormula = in_array($firstCharCellValue, $formulaStartsWith);
if($isFormula) {
if ($isFormula) {
return "'" . $value;
}

Expand Down
2 changes: 1 addition & 1 deletion core/DataTable/Renderer/Rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected function renderTable($table)
$pudDate = date('r', $timestamp);

$dateInSiteTimezone = Date::factory($timestamp);
if($site) {
if ($site) {
$dateInSiteTimezone = $dateInSiteTimezone->setTimezone($site->getTimezone());
}
$dateInSiteTimezone = $dateInSiteTimezone->toString('Y-m-d');
Expand Down
2 changes: 1 addition & 1 deletion core/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ private static function logExtraInfoIfDeadlock($ex)

// log using exception so backtrace appears in log output
Log::debug(new Exception("Encountered deadlock: " . print_r($deadlockInfo, true)));
} catch(\Exception $e) {
} catch (\Exception $e) {
// 1227 Access denied; you need (at least one of) the PROCESS privilege(s) for this operation
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/Db/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function factory($adapterName, &$dbInfos, $connect = true)
Zend_Db_Table::setDefaultAdapter($adapter);
// we don't want the connection information to appear in the logs
$adapter->resetConfig();
} catch(\Exception $e) {
} catch (\Exception $e) {
// we don't want certain exceptions to leak information
$msg = self::overriddenExceptionMessage($e->getMessage());
if ('' !== $msg) {
Expand Down
22 changes: 11 additions & 11 deletions core/FileIntegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected static function getMessagesFilesFoundButNotExpected($messages)
protected static function getDirectoriesFoundButNotExpected()
{
static $cache = null;
if(!is_null($cache)) {
if (!is_null($cache)) {
return $cache;
}

Expand All @@ -191,7 +191,7 @@ protected static function getDirectoriesFoundButNotExpected()
$file = ltrim($file, "\\/");
$directory = dirname($file);

if(in_array($directory, $directoriesInManifest)) {
if (in_array($directory, $directoriesInManifest)) {
continue;
}

Expand Down Expand Up @@ -252,8 +252,8 @@ protected static function getFilesFoundButNotExpected()
protected static function isFileFromDirectoryThatShouldBeDeleted($file)
{
$directoriesWillBeDeleted = self::getDirectoriesFoundButNotExpected();
foreach($directoriesWillBeDeleted as $directoryWillBeDeleted) {
if(strpos($file, $directoryWillBeDeleted) === 0) {
foreach ($directoriesWillBeDeleted as $directoryWillBeDeleted) {
if (strpos($file, $directoryWillBeDeleted) === 0) {
return true;
}
}
Expand All @@ -265,11 +265,11 @@ protected static function getDirectoriesFoundInManifest()
$files = \Piwik\Manifest::$files;

$directories = array();
foreach($files as $file => $manifestIntegrityInfo) {
foreach ($files as $file => $manifestIntegrityInfo) {
$directory = $file;

// add this directory and each parent directory
while(($directory = dirname($directory)) && $directory != '.' && $directory != '/') {
while (($directory = dirname($directory)) && $directory != '.' && $directory != '/') {
$directories[] = $directory;
}
}
Expand All @@ -282,8 +282,8 @@ protected static function getPluginsFoundInManifest()
$files = \Piwik\Manifest::$files;

$pluginsInManifest = array();
foreach($files as $file => $manifestIntegrityInfo) {
if(strpos($file, 'plugins/') === 0) {
foreach ($files as $file => $manifestIntegrityInfo) {
if (strpos($file, 'plugins/') === 0) {
$pluginName = self::getPluginNameFromFilepath($file);
$pluginsInManifest[] = $pluginName;
}
Expand Down Expand Up @@ -311,7 +311,7 @@ protected static function isFileFromPluginNotInManifest($file, $pluginsInManifes
}

$pluginName = self::getPluginNameFromFilepath($file);
if(in_array($pluginName, $pluginsInManifest)) {
if (in_array($pluginName, $pluginsInManifest)) {
return false;
}

Expand Down Expand Up @@ -446,7 +446,7 @@ protected static function getParentDirectoriesFromListOfDirectories($directories
$parentDirectoriesOnly = array();
foreach ($directoriesFoundButNotExpected as $directory) {
$directoryParent = self::getDirectoryParentFromList($directory, $directoriesFoundButNotExpected);
if($directoryParent) {
if ($directoryParent) {
$parentDirectoriesOnly[] = $directoryParent;
}
}
Expand All @@ -464,7 +464,7 @@ protected static function getParentDirectoriesFromListOfDirectories($directories
*/
protected static function getDirectoryParentFromList($directory, $directories)
{
foreach($directories as $directoryMaybeParent) {
foreach ($directories as $directoryMaybeParent) {
if ($directory == $directoryMaybeParent) {
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions core/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private static function generateSafeModeOutputFromError($lastError)
try {
$controller->init();
$message = $controller->dispatch('CorePluginsAdmin', 'safemode', array($lastError));
} catch(Exception $e) {
} catch (Exception $e) {
// may fail in safe mode (eg. global.ini.php not found)
$message = sprintf("Matomo encountered an error: %s (which lead to: %s)", $lastError['message'], $e->getMessage());
}
Expand Down Expand Up @@ -189,10 +189,10 @@ public function dispatch($module = null, $action = null, $parameters = null)
echo $this->generateSafeModeOutputFromException($e);
exit;
}
} catch(StylesheetLessCompileException $e) {
} catch (StylesheetLessCompileException $e) {
echo $this->generateSafeModeOutputFromException($e);
exit;
} catch(\Error $e) {
} catch (\Error $e) {
echo $this->generateSafeModeOutputFromException($e);
exit;
}
Expand Down
2 changes: 1 addition & 1 deletion core/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ public static function sendHttpRequestBy(
while (substr($response, 0, 5) == "HTTP/") {
$split = explode("\r\n\r\n", $response, 2);

if(count($split) == 2) {
if (count($split) == 2) {
[$header, $response] = $split;
} else {
$response = '';
Expand Down
2 changes: 1 addition & 1 deletion core/IP.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private static function getIpsFromList(string $csv, ?array $excludedIps)
$elements = explode(',', $csv);
foreach ($elements as $ipString) {
$element = trim(Common::sanitizeInputValue($ipString));
if(empty($element)) {
if (empty($element)) {
continue;
}
$ip = \Matomo\Network\IP::fromStringIP(IPUtils::sanitizeIp($element));
Expand Down
6 changes: 3 additions & 3 deletions core/Intl/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ class Locale
*/
public static function setLocale($locale)
{
if(!is_array($locale)) {
if (!is_array($locale)) {
$locale = array($locale);
}

$newLocale = array();
foreach($locale as $localePart) {
foreach ($locale as $localePart) {
$newLocale[] = $localePart;

$localeVariant = str_replace('UTF-8', 'UTF8', $localePart);
if($localeVariant != $localePart) {
if ($localeVariant != $localePart) {
$newLocale[] = $localeVariant;
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ public function getMissingDependenciesAsString($piwikVersion = null)

$missingDependencies = $dependency->getMissingDependencies($this->pluginInformation['require']);

if(empty($missingDependencies)) {
if (empty($missingDependencies)) {
return '';
}

Expand Down
2 changes: 1 addition & 1 deletion core/Plugin/MetadataLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function load()

// look for a license file
$licenseFile = $this->getPathToLicenseFile();
if(!empty($licenseFile)) {
if (!empty($licenseFile)) {
$plugin['license_file'] = $licenseFile;
}

Expand Down
2 changes: 1 addition & 1 deletion core/Plugin/ViewDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ private function overrideViewPropertiesWithParams($overrideParams)
public function throwWhenSettingNonOverridableParameter($overrideParams)
{
$nonOverridableParams = $this->getNonOverridableParams($overrideParams);
if(count($nonOverridableParams) > 0) {
if (count($nonOverridableParams) > 0) {
throw new \Exception(sprintf(
"Setting parameters %s is not allowed. Please report this bug to the Matomo team.",
implode(" and ", $nonOverridableParams)
Expand Down
2 changes: 1 addition & 1 deletion core/Scheduler/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function run()

// Task has thrown an exception and should be scheduled for a retry
if ($this->scheduleRetry) {
if($this->timetable->getRetryCount($taskName) == 3) {
if ($this->timetable->getRetryCount($taskName) == 3) {
// Task has already been retried three times, give up
$this->timetable->clearRetryCount($taskName);

Expand Down
2 changes: 1 addition & 1 deletion core/Segment.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ public function getSelectQuery($select, $from, $where = false, $bind = array(),
$segmentExpression = $this->segmentExpression;

$limitAndOffset = null;
if($limit > 0) {
if ($limit > 0) {
$limitAndOffset = (int) $offset . ', ' . (int) $limit;
}

Expand Down
2 changes: 1 addition & 1 deletion core/SettingsPiwik.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public static function isInternetEnabled(): bool
public static function isAutoUpdateEnabled(): bool
{
$enableAutoUpdate = (bool) Config::getInstance()->General['enable_auto_update'];
if(self::isInternetEnabled() === true && $enableAutoUpdate === true) {
if (self::isInternetEnabled() === true && $enableAutoUpdate === true) {
return true;
}

Expand Down
Loading

0 comments on commit 73823f7

Please sign in to comment.