Skip to content

Commit

Permalink
[Coding Style] Enable rules Squiz.Functions.FunctionDeclarationArgume…
Browse files Browse the repository at this point in the history
…ntSpacing.* (#21826)

* Enable rules Squiz.Functions.FunctionDeclarationArgumentSpacing.*

* Apply CS

---------

Co-authored-by: Marc Neudert <[email protected]>
  • Loading branch information
sgiehl and mneudert committed Jan 18, 2024
1 parent d12b0a7 commit 1d0691c
Show file tree
Hide file tree
Showing 21 changed files with 26 additions and 35 deletions.
2 changes: 1 addition & 1 deletion core/Db/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Adapter
* @param bool $connect
* @return AdapterInterface
*/
public static function factory($adapterName, & $dbInfos, $connect = true)
public static function factory($adapterName, &$dbInfos, $connect = true)
{
if ($connect) {
if (isset($dbInfos['port']) && is_string($dbInfos['port']) && $dbInfos['port'][0] === '/') {
Expand Down
2 changes: 1 addition & 1 deletion core/DeviceDetector/DeviceDetectorCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function fetch($id)
* @throws \Exception
* @return bool True if the entry was successfully stored
*/
public function save($id, $content, $ttl=0): bool
public function save($id, $content, $ttl = 0): bool
{
if (empty($id)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion core/Exception/RedirectException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RedirectException extends \Piwik\Exception\Exception implements IRedirectE
* @param string $redirectTo
* @param int $countdown
*/
public function __construct($message, $redirectTo, $countdown=5)
public function __construct($message, $redirectTo, $countdown = 5)
{
$this->redirectTo = $redirectTo;
$this->countdown = $countdown;
Expand Down
2 changes: 1 addition & 1 deletion core/Intl/Data/Provider/DateTimeFormatProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function uses12HourClock()
*
* @return string
*/
public function getRangeFormatPattern($short=false, $maxDifference='Y')
public function getRangeFormatPattern($short = false, $maxDifference = 'Y')
{
if ($short) {
return 'MMM d, y – MMM d, y';
Expand Down
10 changes: 5 additions & 5 deletions core/NumberFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function parsePattern($pattern)
* @param int $minimumFractionDigits
* @return mixed|string
*/
public function format($value, $maximumFractionDigits=0, $minimumFractionDigits=0)
public function format($value, $maximumFractionDigits = 0, $minimumFractionDigits = 0)
{
if (is_string($value)
&& trim($value, '%') != $value
Expand All @@ -86,7 +86,7 @@ public function format($value, $maximumFractionDigits=0, $minimumFractionDigits=
* @param int $minimumFractionDigits
* @return mixed|string
*/
public function formatNumber($value, $maximumFractionDigits=0, $minimumFractionDigits=0)
public function formatNumber($value, $maximumFractionDigits = 0, $minimumFractionDigits = 0)
{
$pattern = $this->getPattern($value, 'Intl_NumberFormatNumber');

Expand All @@ -100,7 +100,7 @@ public function formatNumber($value, $maximumFractionDigits=0, $minimumFractionD
* @param int $minimumFractionDigits
* @return mixed|string
*/
public function formatPercent($value, $maximumFractionDigits=0, $minimumFractionDigits=0)
public function formatPercent($value, $maximumFractionDigits = 0, $minimumFractionDigits = 0)
{
$newValue = trim($value, " \0\x0B%");
if (!is_numeric($newValue)) {
Expand Down Expand Up @@ -140,7 +140,7 @@ public function formatPercentEvolution($value)
* @param int $precision
* @return mixed|string
*/
public function formatCurrency($value, $currency, $precision=2)
public function formatCurrency($value, $currency, $precision = 2)
{
$newValue = trim(strval($value), " \0\x0B$currency");
if (!is_numeric($newValue)) {
Expand Down Expand Up @@ -190,7 +190,7 @@ protected function getPattern($value, $translationId)
* @param int $minimumFractionDigits
* @return mixed|string
*/
protected function formatNumberWithPattern($pattern, $value, $maximumFractionDigits=0, $minimumFractionDigits=0)
protected function formatNumberWithPattern($pattern, $value, $maximumFractionDigits = 0, $minimumFractionDigits = 0)
{
if (!is_numeric($value)) {
return $value;
Expand Down
2 changes: 1 addition & 1 deletion core/Tracker/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static function factory(Request $request)
* @return bool
* @throws Exception
*/
public static function isCustomActionRequest(Request $request)
public static function isCustomActionRequest(Request $request)
{
return $request->hasParam('ca') && $request->getParam('ca');
}
Expand Down
2 changes: 1 addition & 1 deletion core/Tracker/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function __construct($params, $tokenAuth = false)
$this->getIdSiteIfExists());
}

protected function replaceUnsupportedUtf8Chars($value, $key=false)
protected function replaceUnsupportedUtf8Chars($value, $key = false)
{
$dbSettings = new \Piwik\Db\Settings();
$charset = $dbSettings->getUsedCharset();
Expand Down
8 changes: 0 additions & 8 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@
<exclude name="Squiz.ControlStructures.ForLoopDeclaration.NoSpaceAfterFirst" />
<exclude name="Squiz.ControlStructures.ForLoopDeclaration.NoSpaceAfterSecond" />
<exclude name="Squiz.Functions.FunctionDeclaration.Found" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceAfterEquals" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceBeforeComma" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceBeforeEquals" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterReference" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeArg" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeHint" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBetween" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.CloseBracketLine" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.FirstParamSpacing" />
Expand Down
2 changes: 1 addition & 1 deletion plugins/Actions/ArchivingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public static function updateActionsTableWithRowQuery($query, $fieldQueried, $ac
* @return int Number of rows processed
* @throws \Exception
*/
public static function updateActionsTableWithGoals($resultSet, bool $isPages): int
public static function updateActionsTableWithGoals($resultSet, bool $isPages): int
{
$rowsProcessed = 0;

Expand Down
4 changes: 2 additions & 2 deletions plugins/Dashboard/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function createNewDashboardForUser($login, $dashboardName = '', $addDefau
* @param int $idDashboard id of the dashboard to be removed
* @param string $login Login of the dashboard user [defaults to current user]
*/
public function removeDashboard($idDashboard, $login='')
public function removeDashboard($idDashboard, $login = '')
{
$login = $login ? $login : Piwik::getCurrentUserLogin();

Expand Down Expand Up @@ -150,7 +150,7 @@ public function copyDashboardToUser($idDashboard, $copyToUser, $dashboardName =
* @param string $login user the dashboard belongs
*
*/
public function resetDashboardLayout($idDashboard, $login='')
public function resetDashboardLayout($idDashboard, $login = '')
{
$login = $login ?: Piwik::getCurrentUserLogin();

Expand Down
4 changes: 2 additions & 2 deletions plugins/Ecommerce/Columns/Revenue.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function configureSegments(SegmentsList $segmentsList, DimensionSegmentFa
$segment->setName(Piwik::translate('Ecommerce_RevenueLeftInCart'));
$segment->setSegment('revenueAbandonedCart');
$segment->setSqlSegment('log_conversion.idvisit');
$segment->setSqlFilter(function ($valueToMatch, $sqlField , $matchType) {
$segment->setSqlFilter(function ($valueToMatch, $sqlField, $matchType) {
return $this->getRevenueQuery($valueToMatch, $sqlField, $matchType, -1);
});
$segmentsList->addSegment($dimensionSegmentFactory->createSegment($segment));
Expand All @@ -67,7 +67,7 @@ public function configureSegments(SegmentsList $segmentsList, DimensionSegmentFa
* @param false $cart
* @return array
*/
private function getRevenueQuery($valueToMatch, $sqlField , $matchType, $idGoal)
private function getRevenueQuery($valueToMatch, $sqlField, $matchType, $idGoal)
{
//supported operator type
$supportType = [
Expand Down
2 changes: 1 addition & 1 deletion plugins/Feedback/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function sendFeedbackForFeature($featureName, $like = null, $choice = nul
* @throws \Piwik\NoAccessException
* @throws \Exception
*/
public function sendFeedbackForSurvey($question, $message = false)
public function sendFeedbackForSurvey($question, $message = false)
{
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasSomeViewAccess();
Expand Down
2 changes: 1 addition & 1 deletion plugins/Intl/Commands/GenerateIntl.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ protected function fetchTimeZoneData($langCode, $requestLangCode, &$translations
}
}

protected function transformDateFormat($dateFormat, $changes=array())
protected function transformDateFormat($dateFormat, $changes = array())
{
if(!empty($changes)) {
$dateFormat = str_replace(array_keys($changes), array_values($changes), $dateFormat);
Expand Down
2 changes: 1 addition & 1 deletion plugins/Intl/DateTimeFormatProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getFormatPattern($format)
*
* @return string
*/
public function getRangeFormatPattern($short=false, $maxDifference='Y')
public function getRangeFormatPattern($short = false, $maxDifference = 'Y')
{
return $this->translator->translate(
sprintf(
Expand Down
2 changes: 1 addition & 1 deletion plugins/LanguagesManager/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function getAvailableLanguages($_ignoreConfig = false)
*
* @return array Array of arrays
*/
public function getAvailableLanguagesInfo($excludeNonCorePlugins=true, $_ignoreConfig = false)
public function getAvailableLanguagesInfo($excludeNonCorePlugins = true, $_ignoreConfig = false)
{
$data = file_get_contents(PIWIK_INCLUDE_PATH . '/lang/en.json');
$englishTranslation = json_decode($data, true);
Expand Down
2 changes: 1 addition & 1 deletion plugins/Live/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private function loadLastVisitsDetailsFromDatabase($idSite, $period, $date, $seg
* @return DataTable
* @throws Exception
*/
private function makeVisitorTableFromArray($data, $hasMoreVisits=null)
private function makeVisitorTableFromArray($data, $hasMoreVisits = null)
{
$dataTable = new DataTable();

Expand Down
2 changes: 1 addition & 1 deletion plugins/Live/tests/Integration/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public function test_splitDatesIntoMultipleQueries_noStartDate()
$this->assertEquals(array('2012-02-19 04:01:00 2012-02-20 04:01:00', '2012-02-12 04:01:00 2012-02-19 04:00:59', '2012-01-13 04:01:00 2012-02-12 04:00:59', '2011-01-01 04:01:00 2012-01-13 04:00:59', ' 2011-01-01 04:00:59'), $dates);
}

private function splitDatesIntoMultipleQueries($startDate, $endDate, $limit, $offset, $order='desc')
private function splitDatesIntoMultipleQueries($startDate, $endDate, $limit, $offset, $order = 'desc')
{
if ($startDate) {
$startDate = Date::factory($startDate);
Expand Down
2 changes: 1 addition & 1 deletion plugins/MobileMessaging/MobileMessaging.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function getReportRecipients(&$recipients, $reportType, $report)
* @param $force
*/
public function sendReport($reportType, $report, $contents, $filename, $prettyDate, $reportSubject, $reportTitle,
$additionalFiles, $period, $force)
$additionalFiles, $period, $force)
{
if (self::manageEvent($reportType)) {
$parameters = $report['parameters'];
Expand Down
2 changes: 1 addition & 1 deletion plugins/PagePerformance/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function getEvolutionTable()
* @return string|void
* @throws \Exception
*/
public function getRowEvolutionGraph($dataTable=null)
public function getRowEvolutionGraph($dataTable = null)
{
$this->checkSitePermission();

Expand Down
3 changes: 1 addition & 2 deletions plugins/UsersManager/tests/Integration/UsersManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,7 @@ public function test_addUser_shouldNotAllowAdminUsersToCreateUsers_WithNoInitial
$this->api->addUser('userLogin2', 'password', '[email protected]');
}

public function test_addUser_shouldNotAllowAdminUsersToCreateUsersWithAccessToSite_ThatAdminUserDoesNotHaveAccessTo(
)
public function test_addUser_shouldNotAllowAdminUsersToCreateUsersWithAccessToSite_ThatAdminUserDoesNotHaveAccessTo()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('checkUserHasAdminAccess Fake exception');
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPUnit/Integration/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public function getProtocolUrls()
/**
* @dataProvider getBlockedHostUrls
*/
public function test_blocked_hosts($url, $isValid, $message='')
public function test_blocked_hosts($url, $isValid, $message = '')
{
EventDispatcher::getInstance()->addObserver('Http.sendHttpRequest', function($aUrl, $httpEventParams, &$response, &$status, &$headers) {
$response = 'prevented request';
Expand Down

0 comments on commit 1d0691c

Please sign in to comment.