Skip to content

Commit

Permalink
[Coding Style] Enable rule PSR2.Methods.MethodDeclaration.Underscore (#…
Browse files Browse the repository at this point in the history
…22128)

* [Coding Style] Enable rule PSR2.Methods.MethodDeclaration.Underscore

* Apply CS
  • Loading branch information
sgiehl authored Apr 16, 2024
1 parent 2a63278 commit f6d02d9
Show file tree
Hide file tree
Showing 18 changed files with 328 additions and 329 deletions.
2 changes: 1 addition & 1 deletion core/Db/Adapter/Mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function getDefaultPort()
return 3306;
}

protected function _connect()
protected function _connect() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
if ($this->_connection) {
return;
Expand Down
4 changes: 2 additions & 2 deletions core/Db/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function getConnection()
return $this->_connection;
}

protected function _connect()
protected function _connect() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
if ($this->_connection) {
return;
Expand Down Expand Up @@ -341,7 +341,7 @@ public function query($sql, $bind = array())
* if unix_socket is set since setting both causes unexpected behaviour
* @see http://php.net/manual/en/ref.pdo-mysql.connection.php
*/
protected function _dsn()
protected function _dsn() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
if (!empty($this->_config['unix_socket'])) {
unset($this->_config['host']);
Expand Down
1 change: 0 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<exclude name="PSR12.Files.FileHeader" />
<exclude name="PSR12.Properties.ConstantVisibility" />
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
</rule>

<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
Expand Down
6 changes: 3 additions & 3 deletions plugins/Dashboard/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function init()
$this->dashboard = new Dashboard();
}

protected function _getDashboardView($template)
protected function getDashboardView($template)
{
$view = new View($template);
$this->setGeneralVariablesView($view);
Expand All @@ -48,14 +48,14 @@ protected function _getDashboardView($template)
// this
public function embeddedIndex()
{
$view = $this->_getDashboardView('@Dashboard/embeddedIndex');
$view = $this->getDashboardView('@Dashboard/embeddedIndex');
return $view->render();
}

// this is the exported widget
public function index()
{
$view = $this->_getDashboardView('@Dashboard/index');
$view = $this->getDashboardView('@Dashboard/index');
$view->hasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
$view->dashboards = array();
if (!Piwik::isUserIsAnonymous()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function filter($translations)
}

// ensure that translated strings have the same number of %s as the english source strings
$baseCount = $this->_getParametersCountToReplace($baseTranslation);
$translationCount = $this->_getParametersCountToReplace($translation);
$baseCount = $this->getParametersCountToReplace($baseTranslation);
$translationCount = $this->getParametersCountToReplace($translation);

if ($baseCount != $translationCount) {
$this->filteredData[$pluginName][$key] = $translation;
Expand All @@ -65,7 +65,7 @@ public function filter($translations)
* @param string $string
* @return array
*/
protected function _getParametersCountToReplace($string)
protected function getParametersCountToReplace($string)
{
$sprintfParameters = array('%s', '%1$s', '%2$s', '%3$s', '%4$s', '%5$s', '%6$s', '%7$s', '%8$s', '%9$s');
$count = array();
Expand Down
52 changes: 26 additions & 26 deletions plugins/Login/tests/Integration/LoginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function test_authenticate_successAnonymous()

public function test_authenticate_failureUserEmptyTokenAuth()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();

// empty token auth
$rc = $this->authenticate($login = $user['login'], $authToken = '');
Expand All @@ -150,7 +150,7 @@ public function test_authenticate_failureUserEmptyTokenAuth()

public function test_authenticate_failureUserInvalidTokenAuth()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();

// not a token auth
$rc = $this->authenticate($login = $user['login'], $authToken = $user['password']);
Expand All @@ -159,7 +159,7 @@ public function test_authenticate_failureUserInvalidTokenAuth()

public function test_authenticate_failureUserInvalidTokenAuth2()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();

// not a token auth
$rc = $this->authenticate($login = $user['login'], $authToken = md5($user['password']));
Expand All @@ -168,7 +168,7 @@ public function test_authenticate_failureUserInvalidTokenAuth2()

public function test_authenticate_failureUserEmptyLogin()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();

// empty login
$rc = $this->authenticate($login = '', $user['tokenAuth']);
Expand All @@ -177,8 +177,8 @@ public function test_authenticate_failureUserEmptyLogin()

public function test_authenticate_failureUserWithSuperUserAccessEmptyLogin()
{
$user = $this->_setUpUser();
$this->_setUpSuperUserAccessViaDb();
$user = $this->setUpUser();
$this->setUpSuperUserAccessViaDb();

// empty login
$rc = $this->authenticate($login = '', $user['tokenAuth']);
Expand All @@ -187,7 +187,7 @@ public function test_authenticate_failureUserWithSuperUserAccessEmptyLogin()

public function test_authenticate_failureUserLoginTokenAuthMissmatch()
{
$this->_setUpUser();
$this->setUpUser();

// not equal
$rc = $this->authenticate($login = 0, $authToken = 0);
Expand All @@ -196,7 +196,7 @@ public function test_authenticate_failureUserLoginTokenAuthMissmatch()

public function test_authenticate_failureUserLoginTokenAuthMissmatch2()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();

// not equal
$rc = $this->authenticate($login = 0, $user['tokenAuth']);
Expand All @@ -205,7 +205,7 @@ public function test_authenticate_failureUserLoginTokenAuthMissmatch2()

public function test_authenticate_failureUserLoginTokenAuthMissmatch3()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();

// not equal
$rc = $this->authenticate($user['login'], $authToken = 0);
Expand All @@ -214,8 +214,8 @@ public function test_authenticate_failureUserLoginTokenAuthMissmatch3()

public function test_authenticate_failureUserWithSuperUserAccessLoginTokenAuthMissmatch()
{
$user = $this->_setUpUser();
$this->_setUpSuperUserAccessViaDb();
$user = $this->setUpUser();
$this->setUpSuperUserAccessViaDb();

// not equal
$rc = $this->authenticate($login = null, $authToken = $user['password']);
Expand All @@ -224,7 +224,7 @@ public function test_authenticate_failureUserWithSuperUserAccessLoginTokenAuthMi

public function test_authenticate_successUserTokenAuth()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();

// API authentication
$rc = $this->authenticate($login = null, $user['tokenAuth']);
Expand All @@ -233,8 +233,8 @@ public function test_authenticate_successUserTokenAuth()

public function test_authenticate_successUserWithSuperUserAccessByTokenAuth()
{
$user = $this->_setUpUser();
$this->_setUpSuperUserAccessViaDb();
$user = $this->setUpUser();
$this->setUpSuperUserAccessViaDb();

// API authentication
$rc = $this->authenticate($login = null, $user['tokenAuth']);
Expand All @@ -245,7 +245,7 @@ public function test_authenticate_successUserLoginAndTokenAuthWithAnonymous()
{
DbHelper::createAnonymousUser();

$user = $this->_setUpUser();
$user = $this->setUpUser();

// valid login & token auth
$rc = $this->authenticate('anonymous', 'anonymous');
Expand All @@ -254,7 +254,7 @@ public function test_authenticate_successUserLoginAndTokenAuthWithAnonymous()

public function test_authenticate_successUserLoginAndTokenAuth()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();

// valid login & token auth
$rc = $this->authenticate($user['login'], $user['tokenAuth']);
Expand All @@ -263,8 +263,8 @@ public function test_authenticate_successUserLoginAndTokenAuth()

public function test_authenticate_successUserWithSuperUserAccessLoginAndTokenAuth()
{
$user = $this->_setUpUser();
$this->_setUpSuperUserAccessViaDb();
$user = $this->setUpUser();
$this->setUpSuperUserAccessViaDb();

// valid login & token auth
$rc = $this->authenticate($user['login'], $user['tokenAuth']);
Expand All @@ -273,7 +273,7 @@ public function test_authenticate_successUserWithSuperUserAccessLoginAndTokenAut

public function test_authenticate_successWithValidPassword()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();
$this->auth->setLogin($user['login']);
$this->auth->setPassword($user['password']);

Expand All @@ -286,8 +286,8 @@ public function test_authenticate_successWithValidPassword()

public function test_authenticate_successWithSuperUserPassword()
{
$user = $this->_setUpUser();
$this->_setUpSuperUserAccessViaDb();
$user = $this->setUpUser();
$this->setUpSuperUserAccessViaDb();

$this->auth->setLogin($user['login']);
$this->auth->setPassword($user['password']);
Expand All @@ -298,7 +298,7 @@ public function test_authenticate_successWithSuperUserPassword()

public function test_authenticate_failsWithInvalidPassword()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();
$this->auth->setLogin($user['login']);
$this->auth->setPassword('foo bar');

Expand All @@ -308,7 +308,7 @@ public function test_authenticate_failsWithInvalidPassword()

public function test_authenticate_prioritizesPasswordAuthentication()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();
$this->auth->setLogin($user['login']);
$this->auth->setPassword($user['password']); // correct password
$this->auth->setTokenAuth('foo bar'); // invalid token
Expand All @@ -327,7 +327,7 @@ public function test_authenticate_prioritizesPasswordAuthentication()
*/
public function test_authenticate_withPasswordIsCaseInsensitiveForLogin()
{
$user = $this->_setUpUser();
$user = $this->setUpUser();
$this->auth->setLogin('uSeR');
$this->auth->setPassword($user['password']);

Expand All @@ -339,7 +339,7 @@ public function test_authenticate_withPasswordIsCaseInsensitiveForLogin()
$this->assertTrue(ctype_xdigit($rc->getTokenAuth()));
}

protected function _setUpUser()
protected function setUpUser()
{
$user = array(
'login' => 'user',
Expand All @@ -359,7 +359,7 @@ protected function _setUpUser()
return $user;
}

private function _setUpSuperUserAccessViaDb()
private function setUpSuperUserAccessViaDb()
{
$userUpdater = new UserUpdater();
$userUpdater->setSuperUserAccessWithoutCurrentPassword('user', true);
Expand Down
Loading

0 comments on commit f6d02d9

Please sign in to comment.