Skip to content

Commit 0dd7f03

Browse files
authored
Merge pull request #1122 from CakeDC/issue/fix-cs-new-ruleset
Fix CS issues after new rule added to CakePHP rule set
2 parents 898d784 + dbc1285 commit 0dd7f03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+160
-160
lines changed

src/Authenticator/SocialPendingEmailAuthenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function _buildLoginUrlErrorResult($request)
6767
sprintf(
6868
'Login URL `%s` did not match `%s`.',
6969
(string)$request->getUri(),
70-
implode('` or `', (array)$this->getConfig('loginUrl'))
70+
implode('` or `', (array)$this->getConfig('loginUrl')),
7171
),
7272
];
7373

src/Command/UsersPasswordEmailCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public function execute(Arguments $args, ConsoleIo $io)
5454
if ($resetUser) {
5555
$msg = __d(
5656
'cake_d_c/users',
57-
'Please ask the user to check the email to continue with password reset process'
57+
'Please ask the user to check the email to continue with password reset process',
5858
);
5959
$io->out($msg);
6060
} else {
6161
$msg = __d(
6262
'cake_d_c/users',
63-
'The password token could not be generated. Please try again'
63+
'The password token could not be generated. Please try again',
6464
);
6565
$io->abort($msg);
6666
}

src/Controller/Component/LoginComponent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ protected function afterIdentifyUser($user)
165165
$userId = $user['id'] ?? null;
166166
Log::info(
167167
"Unsafe redirect `$queryRedirect` ignored, user id `{$userId}` " .
168-
"redirected to `$redirectUrl` after successful login"
168+
"redirected to `$redirectUrl` after successful login",
169169
);
170170
$queryRedirect = $redirectUrl;
171171
}
@@ -243,7 +243,7 @@ protected function updateLastLogin($user)
243243
$user->set($field, $now);
244244
$this->getController()->getUsersTable()->updateAll(
245245
[$field => $now->format('Y-m-d H:i:s')],
246-
['id' => $user->id]
246+
['id' => $user->id],
247247
);
248248
}
249249

src/Controller/Traits/LinkSocialTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function callbackLinkSocial($alias = null)
8383
$log = sprintf(
8484
'Error linking social account: %s %s',
8585
$e->getMessage(),
86-
$e
86+
$e,
8787
);
8888
$this->log($log);
8989

src/Controller/Traits/OneTimePasswordVerifyTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ public function verify()
3434
Configure::read('Auth.AuthenticationComponent.loginAction'),
3535
[
3636
'?' => $this->getRequest()->getQueryParams(),
37-
]
37+
],
3838
);
3939
if (!$this->isVerifyAllowed()) {
4040
return $this->redirect($loginAction);
4141
}
4242

4343
$temporarySession = $this->getRequest()->getSession()->read(
44-
AuthenticationService::TWO_FACTOR_VERIFY_SESSION_KEY
44+
AuthenticationService::TWO_FACTOR_VERIFY_SESSION_KEY,
4545
);
4646
$secretVerified = $temporarySession['secret_verified'] ?? null;
4747
// showing QR-code until shared secret is verified
@@ -53,7 +53,7 @@ public function verify()
5353

5454
$secretDataUri = $this->OneTimePasswordAuthenticator->getQRCodeImageAsDataUri(
5555
$temporarySession['email'],
56-
$secret
56+
$secret,
5757
);
5858
$this->set(['secretDataUri' => $secretDataUri]);
5959
}
@@ -83,7 +83,7 @@ protected function isVerifyAllowed()
8383
}
8484

8585
$temporarySession = $this->getRequest()->getSession()->read(
86-
AuthenticationService::TWO_FACTOR_VERIFY_SESSION_KEY
86+
AuthenticationService::TWO_FACTOR_VERIFY_SESSION_KEY,
8787
);
8888

8989
if (empty($temporarySession) || !isset($temporarySession['id'])) {

src/Controller/Traits/OneTimeTokenTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public function requestLoginLink()
3939
$Users->sendLoginLink($email);
4040
} catch (RecordNotFoundException $e) {
4141
$this->log(
42-
sprintf('A user is trying to get a login link for the email %s but it does not exist.', $email)
42+
sprintf('A user is trying to get a login link for the email %s but it does not exist.', $email),
4343
);
4444
}
4545
$msg = __d(
4646
'cake_d_c/users',
4747
'If your user is registered in the system you will receive an email ' .
48-
'with a link so you can access your user area.'
48+
'with a link so you can access your user area.',
4949
);
5050
$this->Flash->success($msg);
5151
$this->setRequest($this->getRequest()->withoutData('email'));

src/Controller/Traits/PasswordManagementTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function changePassword($id = null)
6161
$redirect = Configure::read('Users.Profile.route');
6262
} else {
6363
$this->Flash->error(
64-
__d('cake_d_c/users', 'Changing another user\'s password is not allowed')
64+
__d('cake_d_c/users', 'Changing another user\'s password is not allowed'),
6565
);
6666
$this->redirect(Configure::read('Users.Profile.route'));
6767

@@ -72,8 +72,8 @@ public function changePassword($id = null)
7272
$user->set(
7373
'id',
7474
$this->getRequest()->getSession()->read(
75-
Configure::read('Users.Key.Session.resetPasswordUserId')
76-
)
75+
Configure::read('Users.Key.Session.resetPasswordUserId'),
76+
),
7777
);
7878
$validatePassword = false;
7979
$redirect = $this->Authentication->getConfig('loginAction');
@@ -102,7 +102,7 @@ public function changePassword($id = null)
102102
'password' => true,
103103
'password_confirm' => true,
104104
],
105-
]
105+
],
106106
);
107107

108108
if ($user->getErrors()) {
@@ -171,7 +171,7 @@ public function requestResetPassword()
171171
if ($resetUser) {
172172
$msg = __d(
173173
'cake_d_c/users',
174-
'If the account is valid, the system will send an instructional email to the address on record.'
174+
'If the account is valid, the system will send an instructional email to the address on record.',
175175
);
176176
$this->Flash->success($msg);
177177
} else {
@@ -183,7 +183,7 @@ public function requestResetPassword()
183183
} catch (UserNotFoundException | UserNotActiveException $exception) {
184184
$msg = __d(
185185
'cake_d_c/users',
186-
'If the account is valid, the system will send an instructional email to the address on record.'
186+
'If the account is valid, the system will send an instructional email to the address on record.',
187187
);
188188
$this->Flash->success($msg);
189189
} catch (Exception $exception) {

src/Controller/Traits/RegisterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function _validateRegisterPost()
135135

136136
return $this->validateReCaptcha(
137137
$this->getRequest()->getData('g-recaptcha-response'),
138-
$this->getRequest()->clientIp()
138+
$this->getRequest()->clientIp(),
139139
);
140140
}
141141

src/Controller/Traits/UserValidationTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function validate($type = null, $token = null)
4545
if ($result) {
4646
$event = $this->dispatchEvent(
4747
Plugin::EVENT_AFTER_EMAIL_TOKEN_VALIDATION,
48-
['user' => $result]
48+
['user' => $result],
4949
);
5050
$eventResult = $event->getResult();
5151
if (!empty($eventResult) && is_array($eventResult)) {
@@ -65,7 +65,7 @@ public function validate($type = null, $token = null)
6565
$this->Flash->success(__d('cake_d_c/users', 'Reset password token was validated successfully'));
6666
$this->getRequest()->getSession()->write(
6767
Configure::read('Users.Key.Session.resetPasswordUserId'),
68-
$result->id
68+
$result->id,
6969
);
7070

7171
return $this->redirect(['action' => 'changePassword']);
@@ -119,7 +119,7 @@ public function resendTokenValidation()
119119
}
120120
$this->Flash->success(__d(
121121
'cake_d_c/users',
122-
'Token has been reset successfully. Please check your email.'
122+
'Token has been reset successfully. Please check your email.',
123123
));
124124
} else {
125125
$this->Flash->error(__d('cake_d_c/users', 'Token could not be reset'));

src/Controller/Traits/Webauthn2faTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function webauthn2faRegisterOptions(?RegisterAdapter $adapter = null)
5252
}
5353

5454
throw new BadRequestException(
55-
__d('cake_d_c/users', 'User already has configured webauthn2fa')
55+
__d('cake_d_c/users', 'User already has configured webauthn2fa'),
5656
);
5757
}
5858

@@ -73,7 +73,7 @@ public function webauthn2faRegister(?RegisterAdapter $adapter = null): \Cake\Htt
7373
return $this->getResponse()->withStringBody(json_encode(['success' => true]));
7474
}
7575
throw new BadRequestException(
76-
__d('cake_d_c/users', 'User already has configured webauthn2fa')
76+
__d('cake_d_c/users', 'User already has configured webauthn2fa'),
7777
);
7878
} catch (\Throwable $e) {
7979
$user = $this->request->getSession()->read('Webauthn2fa.User');
@@ -93,7 +93,7 @@ public function webauthn2faAuthenticateOptions(?AuthenticateAdapter $adapter = n
9393
$adapter = $adapter ?? $this->getWebauthn2faAuthenticateAdapter();
9494

9595
return $this->getResponse()->withStringBody(
96-
json_encode($adapter->getOptions())
96+
json_encode($adapter->getOptions()),
9797
);
9898
}
9999

@@ -115,7 +115,7 @@ public function webauthn2faAuthenticate(?AuthenticateAdapter $adapter = null): \
115115
$this->getRequest()->getSession()->delete('Webauthn2fa');
116116
$this->getRequest()->getSession()->write(
117117
TwoFactorAuthenticator::USER_SESSION_KEY,
118-
$adapter->getUser()
118+
$adapter->getUser(),
119119
);
120120

121121
return $this->getResponse()->withStringBody(json_encode([

src/Controller/UsersController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function initialize(): void
6565
'webauthn2faRegisterOptions',
6666
'webauthn2faAuthenticate',
6767
'webauthn2faAuthenticateOptions',
68-
]
68+
],
6969
);
7070
}
7171
}

src/Identifier/PasswordLockout/LockoutHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ protected function getTimeWindow(): DateTime
155155
throw new \UnexpectedValueException(
156156
__d(
157157
'cake_d_c/users',
158-
'Config "timeWindowInSeconds" must be integer greater than 60'
159-
)
158+
'Config "timeWindowInSeconds" must be integer greater than 60',
159+
),
160160
);
161161
}
162162

@@ -172,8 +172,8 @@ protected function getNumberOfAttemptsFail(): int
172172
throw new \UnexpectedValueException(
173173
__d(
174174
'cake_d_c/users',
175-
'Config "numberOfAttemptsFail" must be integer greater or equal 0'
176-
)
175+
'Config "numberOfAttemptsFail" must be integer greater or equal 0',
176+
),
177177
);
178178
}
179179

@@ -190,8 +190,8 @@ protected function getLockoutTime(): int
190190
throw new \UnexpectedValueException(
191191
__d(
192192
'cake_d_c/users',
193-
'Config "lockoutTimeInSeconds" must be integer greater than 60'
194-
)
193+
'Config "lockoutTimeInSeconds" must be integer greater than 60',
194+
),
195195
);
196196
}
197197

src/Identifier/PasswordLockoutIdentifier.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ protected function buildLockoutHandler(array|string $config): LockoutHandlerInte
8888
throw new \InvalidArgumentException(
8989
__d(
9090
'cake_d_c/users',
91-
'Option `className` for lockout handler is not present.'
92-
)
91+
'Option `className` for lockout handler is not present.',
92+
),
9393
);
9494
}
9595
$className = $config['className'];

src/Loader/AuthenticationServiceLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function loadAuthenticators($service)
8585
*/
8686
protected function loadTwoFactorAuthenticator($service, $processors)
8787
{
88-
if (collection($processors)->some(fn ($processor) => $processor->enabled())) {
88+
if (collection($processors)->some(fn($processor) => $processor->enabled())) {
8989
$service->loadAuthenticator('CakeDC/Auth.TwoFactor', [
9090
'skipTwoFactorVerify' => true,
9191
]);
@@ -106,7 +106,7 @@ protected function _getItemLoadData($item, $key)
106106
$options = $item;
107107
if (!isset($options['className'])) {
108108
throw new \InvalidArgumentException(
109-
__d('cake_d_c/users', 'Property {0}.className should be defined', $key)
109+
__d('cake_d_c/users', 'Property {0}.className should be defined', $key),
110110
);
111111
}
112112
$className = $options['className'];

src/Loader/AuthorizationServiceLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __invoke(ServerRequestInterface $request)
4040
new CollectionPolicy([
4141
SuperuserPolicy::class,
4242
new RbacPolicy(Configure::read('Auth.RbacPolicy')),
43-
])
43+
]),
4444
);
4545

4646
$orm = new OrmResolver();

src/Loader/LoginComponentLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public static function forSocial($controller)
5353
'messages' => [
5454
'FAILURE_USER_NOT_ACTIVE' => __d(
5555
'cake_d_c/users',
56-
'Your user has not been validated yet. Please check your inbox for instructions'
56+
'Your user has not been validated yet. Please check your inbox for instructions',
5757
),
5858
'FAILURE_ACCOUNT_NOT_ACTIVE' => __d(
5959
'cake_d_c/users',
60-
'Your social account has not been validated yet. Please check your inbox for instructions'
60+
'Your social account has not been validated yet. Please check your inbox for instructions',
6161
),
6262
],
6363
'targetAuthenticator' => \CakeDC\Users\Authenticator\SocialAuthenticator::class,

src/Loader/MiddlewareQueueLoader.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MiddlewareQueueLoader
4949
public function __invoke(
5050
MiddlewareQueue $middlewareQueue,
5151
AuthenticationServiceProviderInterface $authenticationServiceProvider,
52-
AuthorizationServiceProviderInterface $authorizationServiceProvider
52+
AuthorizationServiceProviderInterface $authorizationServiceProvider,
5353
) {
5454
$this->loadSocialMiddleware($middlewareQueue);
5555
$this->loadAuthenticationMiddleware($middlewareQueue, $authenticationServiceProvider);
@@ -82,7 +82,7 @@ protected function loadSocialMiddleware(MiddlewareQueue $middlewareQueue)
8282
*/
8383
protected function loadAuthenticationMiddleware(
8484
MiddlewareQueue $middlewareQueue,
85-
AuthenticationServiceProviderInterface $authenticationServiceProvider
85+
AuthenticationServiceProviderInterface $authenticationServiceProvider,
8686
) {
8787
$authentication = new AuthenticationMiddleware($authenticationServiceProvider);
8888
$middlewareQueue->add($authentication);
@@ -97,7 +97,7 @@ protected function loadAuthenticationMiddleware(
9797
protected function load2faMiddleware(MiddlewareQueue $middlewareQueue)
9898
{
9999
$processors = TwoFactorProcessorLoader::processors();
100-
if (collection($processors)->some(fn ($processor) => $processor->enabled())) {
100+
if (collection($processors)->some(fn($processor) => $processor->enabled())) {
101101
$middlewareQueue->add(TwoFactorMiddleware::class);
102102
}
103103
}
@@ -111,16 +111,16 @@ protected function load2faMiddleware(MiddlewareQueue $middlewareQueue)
111111
*/
112112
protected function loadAuthorizationMiddleware(
113113
MiddlewareQueue $middlewareQueue,
114-
AuthorizationServiceProviderInterface $authorizationServiceProvider
114+
AuthorizationServiceProviderInterface $authorizationServiceProvider,
115115
) {
116116
if (Configure::read('Auth.Authorization.enable') === false) {
117117
return $middlewareQueue;
118118
}
119119
$middlewareQueue->add(
120120
new AuthorizationMiddleware(
121121
$authorizationServiceProvider,
122-
Configure::read('Auth.AuthorizationMiddleware')
123-
)
122+
Configure::read('Auth.AuthorizationMiddleware'),
123+
),
124124
);
125125
if (Configure::read('Auth.AuthorizationMiddleware.requireAuthorizationCheck') !== false) {
126126
$middlewareQueue->add(new RequestAuthorizationMiddleware());

src/Middleware/SocialAuthMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function onAuthenticationException(ServerRequest $request, $exception)
4848

4949
$request->getSession()->write(
5050
Configure::read('Users.Key.Session.social'),
51-
$exception->getAttributes()['rawData']
51+
$exception->getAttributes()['rawData'],
5252
);
5353

5454
return $this->responseWithActionLocation($response, 'socialEmail');

src/Middleware/UnauthorizedHandler/DefaultRedirectHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class DefaultRedirectHandler extends CakeRedirectHandler
5555
public function handle(
5656
Exception $exception,
5757
ServerRequestInterface $request,
58-
array $options = []
58+
array $options = [],
5959
): ResponseInterface {
6060
$options += $this->defaultOptions;
6161
$response = parent::handle($exception, $request, $options);

src/Model/Behavior/PasswordBehavior.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function changePassword(EntityInterface $user)
147147
if ($user->current_password === $user->password_confirm) {
148148
throw new WrongPasswordException(__d(
149149
'cake_d_c/users',
150-
'You cannot use the current password as the new one'
150+
'You cannot use the current password as the new one',
151151
));
152152
}
153153
}

src/Model/Behavior/RegisterBehavior.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function register($user, $data, $options)
7373
$user = $this->_table->patchEntity(
7474
$user,
7575
$data,
76-
['validate' => $validate]
76+
['validate' => $validate],
7777
);
7878
$user['role'] = Configure::read('Users.Registration.defaultRole') ?: 'user';
7979
$user->validated = false;

0 commit comments

Comments
 (0)