diff options
author | Stefan Giehl <stefan@matomo.org> | 2021-01-15 10:53:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-15 10:53:48 +0300 |
commit | b38578b468d694534db5fabe356db5ffdc58bd6e (patch) | |
tree | f9d0307513b614d966075d946ac5e68bed1c660a /plugins | |
parent | 6f957d15b4db3b0d8d54f046de33207044f87681 (diff) |
Introduce PHP CS to improve code quality (#16755)
* Adds PHP CS with a basic config
* automatically check coding style for pull requests
* Disallow usage of eval & create_function and force using Common::safe_unserialize instead of unserialize
* Forbid inline control structures
* fix test
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/API/ProcessedReport.php | 4 | ||||
-rw-r--r-- | plugins/CoreHome/DataTableRowAction/RowEvolution.php | 4 | ||||
-rw-r--r-- | plugins/ImageGraph/StaticGraph/GridGraph.php | 4 | ||||
-rw-r--r-- | plugins/MobileMessaging/SMSProvider.php | 8 | ||||
-rw-r--r-- | plugins/ScheduledReports/Menu.php | 3 | ||||
-rw-r--r-- | plugins/ScheduledReports/tests/Integration/ApiTest.php | 4 |
6 files changed, 20 insertions, 7 deletions
diff --git a/plugins/API/ProcessedReport.php b/plugins/API/ProcessedReport.php index a41142eaeb..607134095f 100644 --- a/plugins/API/ProcessedReport.php +++ b/plugins/API/ProcessedReport.php @@ -358,7 +358,9 @@ class ProcessedReport 'idSubtable' => $idSubtable, )); - if (!empty($segment)) $parameters['segment'] = $segment; + if (!empty($segment)) { + $parameters['segment'] = $segment; + } if (!empty($reportMetadata['processedMetrics']) && !empty($reportMetadata['metrics']['nb_visits']) diff --git a/plugins/CoreHome/DataTableRowAction/RowEvolution.php b/plugins/CoreHome/DataTableRowAction/RowEvolution.php index 20e8960f3a..07c5804b8b 100644 --- a/plugins/CoreHome/DataTableRowAction/RowEvolution.php +++ b/plugins/CoreHome/DataTableRowAction/RowEvolution.php @@ -95,7 +95,9 @@ class RowEvolution } $this->label = Common::unsanitizeInputValue($this->label[0]); - if ($this->label === '') throw new Exception("Parameter label not set."); + if ($this->label === '') { + throw new Exception("Parameter label not set."); + } $this->period = Common::getRequestVar('period', '', 'string'); PeriodFactory::checkPeriodIsEnabled($this->period); diff --git a/plugins/ImageGraph/StaticGraph/GridGraph.php b/plugins/ImageGraph/StaticGraph/GridGraph.php index 5ddb2cb40e..9a95577892 100644 --- a/plugins/ImageGraph/StaticGraph/GridGraph.php +++ b/plugins/ImageGraph/StaticGraph/GridGraph.php @@ -140,7 +140,9 @@ abstract class GridGraph extends StaticGraph // rounding top scale value to the next multiple of 10 if ($maxOrdinateValue > 10) { $modTen = $maxOrdinateValue % 10; - if ($modTen) $maxOrdinateValue += 10 - $modTen; + if ($modTen) { + $maxOrdinateValue += 10 - $modTen; + } } $gridColor = $this->gridColor; diff --git a/plugins/MobileMessaging/SMSProvider.php b/plugins/MobileMessaging/SMSProvider.php index e4bda11822..297308b14a 100644 --- a/plugins/MobileMessaging/SMSProvider.php +++ b/plugins/MobileMessaging/SMSProvider.php @@ -188,7 +188,9 @@ abstract class SMSProvider $maxCharsAllowed = self::maxCharsAllowed($maximumNumberOfConcatenatedSMS, $smsContentContainsUCS2Chars); $sizeOfSMSContent = self::sizeOfSMSContent($string, $smsContentContainsUCS2Chars); - if ($sizeOfSMSContent <= $maxCharsAllowed) return $string; + if ($sizeOfSMSContent <= $maxCharsAllowed) { + return $string; + } $smsContentContainsUCS2Chars = $smsContentContainsUCS2Chars || self::containsUCS2Characters($appendedString); $maxCharsAllowed = self::maxCharsAllowed($maximumNumberOfConcatenatedSMS, $smsContentContainsUCS2Chars); @@ -214,7 +216,9 @@ abstract class SMSProvider private static function sizeOfSMSContent($smsContent, $containsUCS2Chars) { - if ($containsUCS2Chars) return Common::mb_strlen($smsContent); + if ($containsUCS2Chars) { + return Common::mb_strlen($smsContent); + } $sizeOfSMSContent = 0; foreach (self::mb_str_split($smsContent) as $char) { diff --git a/plugins/ScheduledReports/Menu.php b/plugins/ScheduledReports/Menu.php index c40910d3db..d1cb6a5b3e 100644 --- a/plugins/ScheduledReports/Menu.php +++ b/plugins/ScheduledReports/Menu.php @@ -35,8 +35,9 @@ class Menu extends \Piwik\Plugin\Menu function getTopMenuTranslationKey() { // if MobileMessaging is not activated, display 'Email reports' - if (!\Piwik\Plugin\Manager::getInstance()->isPluginActivated('MobileMessaging')) + if (!\Piwik\Plugin\Manager::getInstance()->isPluginActivated('MobileMessaging')) { return self::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY; + } if (Piwik::isUserIsAnonymous()) { return self::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY; diff --git a/plugins/ScheduledReports/tests/Integration/ApiTest.php b/plugins/ScheduledReports/tests/Integration/ApiTest.php index 240af9fab7..0eab86b3ad 100644 --- a/plugins/ScheduledReports/tests/Integration/ApiTest.php +++ b/plugins/ScheduledReports/tests/Integration/ApiTest.php @@ -742,7 +742,9 @@ class ApiTest extends IntegrationTestCase private function assertReportsEqual($report, $data) { foreach ($data as $key => $value) { - if ($key == 'description') $value = substr($value, 0, 250); + if ($key == 'description') { + $value = substr($value, 0, 250); + } $this->assertEquals($value, $report[$key], "Error for $key for report " . var_export($report, true) . " and data " . var_export($data, true)); } } |