Skip to content

Commit

Permalink
Apply coding style around FunctionCallSignature #6 (#21932)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl authored Feb 15, 2024
1 parent 81048d5 commit 2d83ba4
Show file tree
Hide file tree
Showing 30 changed files with 333 additions and 147 deletions.
18 changes: 12 additions & 6 deletions plugins/Goals/Commands/CalculateConversionPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ protected function configure()
$this->setDescription('Calculate the pages before metric for historic conversions');
$this->addOptionalValueOption('dates', null, 'Calculate for conversions in this date range. Eg, 2012-01-01,2013-01-01', null);
$this->addOptionalValueOption('last-n', null, 'Calculate just the last n conversions', 0);
$this->addOptionalValueOption('idsite', null,
'Calculate for conversions belonging to the site with this ID. Comma separated list of website id. Eg, 1, 2, 3, etc. By default conversions from all sites are calculated.', null);
$this->addOptionalValueOption(
'idsite',
null,
'Calculate for conversions belonging to the site with this ID. Comma separated list of website id. Eg, 1, 2, 3, etc. By default conversions from all sites are calculated.',
null
);
$this->addOptionalValueOption('idgoal', null, 'Calculate conversions for this goal. A comma separated list of goal ids can be used only if a single site is specified. Eg, 1, 2, 3, etc. By default conversions for all goals are calculated.', null);
$this->addOptionalValueOption('force-recalc', null, 'Recalculate for conversions which already have a pages before value', 0);
}
Expand Down Expand Up @@ -70,8 +74,8 @@ protected function doExecute(): int
"<info>Preparing to calculate the pages before metric for %s conversions belonging to %s %sfor %s.</info>",
$lastN ? "the last " . $lastN : 'all',
$idSite ? "website $idSite" : "ALL websites",
!empty($dates) ? "between " . $from . " and " . $to . " " : '',
$idGoal ? "goal id $idGoal" : "ALL goals"
!empty($dates) ? "between " . $from . " and " . $to . " " : '',
$idGoal ? "goal id $idGoal" : "ALL goals"
));

$timer = new Timer();
Expand Down Expand Up @@ -108,8 +112,10 @@ public static function calculateYesterdayAndToday(): void
{
$migration = StaticContainer::get(MigrationFactory::class);

$queries = self::getQueries(Date::factory('yesterday')->getDatetime(),
Date::factory('today')->getEndOfDay()->getDatetime());
$queries = self::getQueries(
Date::factory('yesterday')->getDatetime(),
Date::factory('today')->getEndOfDay()->getDatetime()
);

$migrations = [];
foreach ($queries as $query) {
Expand Down
10 changes: 8 additions & 2 deletions plugins/Goals/RecordBuilders/GeneralGoalsRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ protected function aggregate(ArchiveProcessor $archiveProcessor): array
if ($siteHasEcommerceOrGoals) {
$selects = [];
$selects = array_merge($selects, LogAggregator::getSelectsFromRangedColumn(
self::VISITS_COUNT_FIELD, Archiver::$visitCountRanges, self::LOG_CONVERSION_TABLE, $prefixes[Archiver::VISITS_UNTIL_RECORD_NAME]
self::VISITS_COUNT_FIELD,
Archiver::$visitCountRanges,
self::LOG_CONVERSION_TABLE,
$prefixes[Archiver::VISITS_UNTIL_RECORD_NAME]
));
$selects = array_merge($selects, LogAggregator::getSelectsFromRangedColumn(
'FLOOR(log_conversion.' . self::SECONDS_SINCE_FIRST_VISIT_FIELD . ' / 86400)', Archiver::$daysToConvRanges, self::LOG_CONVERSION_TABLE, $prefixes[Archiver::DAYS_UNTIL_CONV_RECORD_NAME]
'FLOOR(log_conversion.' . self::SECONDS_SINCE_FIRST_VISIT_FIELD . ' / 86400)',
Archiver::$daysToConvRanges,
self::LOG_CONVERSION_TABLE,
$prefixes[Archiver::DAYS_UNTIL_CONV_RECORD_NAME]
));

$query = $logAggregator->queryConversionsByDimension([], false, $selects);
Expand Down
9 changes: 6 additions & 3 deletions plugins/Goals/TranslationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,22 @@ protected function getTranslationForPattern($patternType, $pattern)
{
switch ($patternType) {
case 'regex':
return sprintf('%s %s',
return sprintf(
'%s %s',
Piwik::translate('Goals_Pattern'),
Piwik::translate('Goals_MatchesExpression', array($pattern))
);

case 'contains':
return sprintf('%s %s',
return sprintf(
'%s %s',
Piwik::translate('Goals_Pattern'),
Piwik::translate('Goals_Contains', array($pattern))
);

case 'exact':
return sprintf('%s %s',
return sprintf(
'%s %s',
Piwik::translate('Goals_Pattern'),
Piwik::translate('Goals_IsExactly', array($pattern))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ public function test_CommandSuccessfullyCalculates_ForLastN()
*/
private function unsetPageviewsBefore(): void
{
Db::query('UPDATE ' . Common::prefixTable('log_conversion') . ' SET pageviews_before = NULL WHERE idsite = ?',
[self::$fixture->idSite]);
Db::query(
'UPDATE ' . Common::prefixTable('log_conversion') . ' SET pageviews_before = NULL WHERE idsite = ?',
[self::$fixture->idSite]
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ protected static function configureFixture($fixture)

private function getConversionCount($idGoal)
{
return Db::fetchOne('SELECT COUNT(*) FROM ' . Common::prefixTable('log_conversion') . ' WHERE idsite = ? AND idgoal = ?',
[$this->idSite, $idGoal]);
return Db::fetchOne(
'SELECT COUNT(*) FROM ' . Common::prefixTable('log_conversion') . ' WHERE idsite = ? AND idgoal = ?',
[$this->idSite, $idGoal]
);
}
}
8 changes: 4 additions & 4 deletions plugins/ImageGraph/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ public function get(
$ordinateColumns[] = key($metadata['metrics']);
} else {
throw new Exception(
Piwik::translate(
'ImageGraph_ColumnOrdinateMissing',
array(self::DEFAULT_ORDINATE_METRIC, implode(',', array_keys($reportColumns)))
)
Piwik::translate(
'ImageGraph_ColumnOrdinateMissing',
array(self::DEFAULT_ORDINATE_METRIC, implode(',', array_keys($reportColumns)))
)
);
}
} else {
Expand Down
4 changes: 3 additions & 1 deletion plugins/ImageGraph/StaticGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,9 @@ protected function getTextWidthHeight($text, $fontSize = false)

// could not find a way to get pixel perfect width & height info using imageftbbox
$textInfo = $this->pImage->drawText(
0, 0, $text,
0,
0,
$text,
array(
'Alpha' => 0,
'FontSize' => $fontSize,
Expand Down
35 changes: 30 additions & 5 deletions plugins/Insights/tests/Unit/InsightReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,19 @@ private function generateMoverAndShaker($totalValue, $lastTotalValue, $orderBy =
$reportMetadata = array('name' => 'TestReport', 'metrics' => array('nb_visits' => 'Visits'));

$report = $this->insightReport->generateMoverAndShaker(
$reportMetadata, 'day', '2012-12-12', '2012-12-11', 'nb_visits', $this->currentTable, $this->pastTable,
$totalValue, $lastTotalValue, $orderBy, $limitIncreaser, $limitDecreaser);
$reportMetadata,
'day',
'2012-12-12',
'2012-12-11',
'nb_visits',
$this->currentTable,
$this->pastTable,
$totalValue,
$lastTotalValue,
$orderBy,
$limitIncreaser,
$limitDecreaser
);

return $report;
}
Expand All @@ -453,9 +464,23 @@ private function generateInsight($minMoversPercent, $minNewPercent, $minDisappea
$reportMetadata = array('name' => 'TestReport', 'metrics' => array('nb_visits' => 'Visits'));

$report = $this->insightReport->generateInsight(
$reportMetadata, 'day', '2012-12-12', '2012-12-11', 'nb_visits', $this->currentTable, $this->pastTable,
$totalValue = 200, $minMoversPercent, $minNewPercent, $minDisappearedPercent,
$minGrowthPercentPositive, $minGrowthPercentNegative, $orderBy, $limitIncreaser, $limitDecreaser);
$reportMetadata,
'day',
'2012-12-12',
'2012-12-11',
'nb_visits',
$this->currentTable,
$this->pastTable,
$totalValue = 200,
$minMoversPercent,
$minNewPercent,
$minDisappearedPercent,
$minGrowthPercentPositive,
$minGrowthPercentNegative,
$orderBy,
$limitIncreaser,
$limitDecreaser
);

return $report;
}
Expand Down
11 changes: 7 additions & 4 deletions plugins/Installation/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,11 @@ function setupSuperUser()
$loginName = $form->getSubmitValue('login');
$email = $form->getSubmitValue('email');

$this->createSuperUser($loginName,
$form->getSubmitValue('password'),
$email);
$this->createSuperUser(
$loginName,
$form->getSubmitValue('password'),
$email
);

$newsletterPiwikORG = $form->getSubmitValue('subscribe_newsletter_piwikorg');
$newsletterProfessionalServices = $form->getSubmitValue('subscribe_newsletter_professionalservices');
Expand Down Expand Up @@ -628,7 +630,8 @@ private function checkPiwikIsNotInstalled($possibleErrorMessage = null)
$possibleErrorMessage = $possibleErrorMessage ? sprintf('<br/><br/>Original error was "%s".<br/>', $possibleErrorMessage) : '';

\Piwik\Plugins\Login\Controller::clearSession();
$message = Piwik::translate('Installation_InvalidStateError',
$message = Piwik::translate(
'Installation_InvalidStateError',
array($possibleErrorMessage . '<br /><strong>',
// piwik-is-already-installed is checked against in checkPiwikServerWorking
'</strong><a id="piwik-is-already-installed" href=\'' . Common::sanitizeInputValue(Url::getCurrentUrlWithoutFileName()) . '\'>',
Expand Down
8 changes: 5 additions & 3 deletions plugins/Installation/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ class Menu extends \Piwik\Plugin\Menu
public function configureAdminMenu(MenuAdmin $menu)
{
if (Piwik::hasUserSuperUserAccess() && Manager::getInstance()->isPluginActivated('Diagnostics')) {
$menu->addDiagnosticItem('Installation_SystemCheck',
$this->urlForAction('systemCheckPage'),
$order = 1);
$menu->addDiagnosticItem(
'Installation_SystemCheck',
$this->urlForAction('systemCheckPage'),
$order = 1
);
}
}
}
12 changes: 8 additions & 4 deletions plugins/Installation/ServerFilesGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ protected static function createWebConfigFiles()
if (!SettingsServer::isIIS()) {
return;
}
@file_put_contents(PIWIK_INCLUDE_PATH . '/web.config',
@file_put_contents(
PIWIK_INCLUDE_PATH . '/web.config',
'<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
Expand Down Expand Up @@ -167,7 +168,8 @@ protected static function createWebConfigFiles()
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>
</configuration>');
</configuration>'
);

// deny direct access to .php files
$directoriesToProtect = array(
Expand All @@ -183,7 +185,8 @@ protected static function createWebConfigFiles()
</alwaysAllowedUrls>';

foreach ($directoriesToProtect as $directoryToProtect) {
@file_put_contents(PIWIK_INCLUDE_PATH . $directoryToProtect . '/web.config',
@file_put_contents(
PIWIK_INCLUDE_PATH . $directoryToProtect . '/web.config',
'<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
Expand All @@ -195,7 +198,8 @@ protected static function createWebConfigFiles()
</requestFiltering>
</security>
</system.webServer>
</configuration>');
</configuration>'
);
}
}

Expand Down
3 changes: 2 additions & 1 deletion plugins/Intl/DateTimeFormatProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public function getRangeFormatPattern($short = false, $maxDifference = 'Y')
'Intl_Format_Interval_%s_%s',
$short ? 'Short' : 'Long',
$maxDifference
));
)
);
}

protected function getTimeFormat()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ private function setUpWebsites()
{
if (!self::siteCreated($this->idSite)) {
Fixture::createWebsite(
'2014-01-02 03:04:05', $ecommerce = 0, $siteName = false, $siteUrl = false,
$siteSearch = 1, $searchKeywordParameters = null,
$searchCategoryParameters = null, $timezone = null, Type::ID
'2014-01-02 03:04:05',
$ecommerce = 0,
$siteName = false,
$siteUrl = false,
$siteSearch = 1,
$searchKeywordParameters = null,
$searchCategoryParameters = null,
$timezone = null,
Type::ID
);
}

Expand Down
6 changes: 4 additions & 2 deletions plugins/LanguagesManager/Commands/SetTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ protected function doExecute(): int
$languageCodes = (new API())->getAvailableLanguages(true);

if (empty($languageCode) || !in_array($languageCode, $languageCodes)) {
$languageCode = $this->askAndValidate('Please provide a valid language code: ',
$languageCode = $this->askAndValidate(
'Please provide a valid language code: ',
function ($code) use ($languageCodes) {
if (!in_array($code, array_values($languageCodes))) {
throw new \InvalidArgumentException(sprintf('Language code "%s" is invalid.', $code));
}

return $code;
});
}
);
}

if (empty($filename) || !file_exists($filename)) {
Expand Down
6 changes: 4 additions & 2 deletions plugins/LanguagesManager/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public function configureTopMenu(MenuTop $menu)
public function configureAdminMenu(MenuAdmin $menu)
{
if (Development::isEnabled() && Piwik::isUserHasSomeAdminAccess()) {
$menu->addDevelopmentItem('LanguagesManager_TranslationSearch',
$this->urlForAction('searchTranslation'));
$menu->addDevelopmentItem(
'LanguagesManager_TranslationSearch',
$this->urlForAction('searchTranslation')
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,11 @@ function testTranslationsUseNumberedPlaceholders()
$translations = $translator->getAllTranslations();
foreach ($translations as $plugin => $pluginTranslations) {
foreach ($pluginTranslations as $key => $pluginTranslation) {
$this->assertLessThanOrEqual(1, substr_count($pluginTranslation, '%s'),
sprintf('%s.%s must use numbered placeholders instead of multiple %%s', $plugin, $key));
$this->assertLessThanOrEqual(
1,
substr_count($pluginTranslation, '%s'),
sprintf('%s.%s must use numbered placeholders instead of multiple %%s', $plugin, $key)
);
}
}
}
Expand All @@ -173,8 +176,11 @@ function testTranslationsUseEscapedPercentSigns()
foreach ($pluginTranslations as $key => $pluginTranslation) {
$pluginTranslation = preg_replace('/(%(?:[1-9]\$)?[a-z])/', '', $pluginTranslation); // remove placeholders
$pluginTranslation = str_replace('%%', '', $pluginTranslation); // remove already escaped symbols
$this->assertEquals(0, substr_count($pluginTranslation, '%'),
sprintf('%s.%s must use escaped %% symbols', $plugin, $key));
$this->assertEquals(
0,
substr_count($pluginTranslation, '%'),
sprintf('%s.%s must use escaped %% symbols', $plugin, $key)
);
}
}
}
Expand Down
Loading

0 comments on commit 2d83ba4

Please sign in to comment.