Skip to content

Commit ad55675

Browse files
committed
Stan cleanup
1 parent 49f3723 commit ad55675

File tree

7 files changed

+12
-31
lines changed

7 files changed

+12
-31
lines changed

.phive/phars.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="phpstan" version="2.1.0" installed="2.1.0" location="./tools/phpstan" copy="false"/>
4-
<phar name="psalm" version="5.26.1" installed="5.26.1" location="./tools/psalm" copy="false"/>
3+
<phar name="phpstan" version="2.1.11" installed="2.1.11" location="./tools/phpstan" copy="false"/>
54
</phive>

src/AuthenticationService.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,13 @@ public function authenticate(ServerRequestInterface $request): ResultInterface
212212
* @param \Psr\Http\Message\ServerRequestInterface $request The request.
213213
* @param \Psr\Http\Message\ResponseInterface $response The response.
214214
* @return array Return an array containing the request and response objects.
215-
* @psalm-return array{request: \Psr\Http\Message\ServerRequestInterface, response: \Psr\Http\Message\ResponseInterface}
215+
* @return array{request: \Psr\Http\Message\ServerRequestInterface, response: \Psr\Http\Message\ResponseInterface}
216216
*/
217217
public function clearIdentity(ServerRequestInterface $request, ResponseInterface $response): array
218218
{
219219
foreach ($this->authenticators() as $authenticator) {
220220
if ($authenticator instanceof PersistenceInterface) {
221221
if ($authenticator instanceof ImpersonationInterface && $authenticator->isImpersonating($request)) {
222-
/** @psalm-var array{request: \Cake\Http\ServerRequest, response: \Cake\Http\Response} $stopImpersonationResult */
223222
$stopImpersonationResult = $authenticator->stopImpersonating($request, $response);
224223
['request' => $request, 'response' => $response] = $stopImpersonationResult;
225224
}
@@ -241,8 +240,7 @@ public function clearIdentity(ServerRequestInterface $request, ResponseInterface
241240
* @param \Psr\Http\Message\ServerRequestInterface $request The request.
242241
* @param \Psr\Http\Message\ResponseInterface $response The response.
243242
* @param \ArrayAccess|array $identity Identity data.
244-
* @return array
245-
* @psalm-return array{request: \Psr\Http\Message\ServerRequestInterface, response: \Psr\Http\Message\ResponseInterface}
243+
* @return array{request: \Psr\Http\Message\ServerRequestInterface, response: \Psr\Http\Message\ResponseInterface}
246244
*/
247245
public function persistIdentity(
248246
ServerRequestInterface $request,

src/Authenticator/ImpersonationInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface ImpersonationInterface
2929
* @param \Psr\Http\Message\ResponseInterface $response The response
3030
* @param \ArrayAccess $impersonator User who impersonates
3131
* @param \ArrayAccess $impersonated User impersonated
32-
* @return array
32+
* @return array{request: \Psr\Http\Message\ServerRequestInterface, response: \Psr\Http\Message\ResponseInterface}
3333
*/
3434
public function impersonate(
3535
ServerRequestInterface $request,
@@ -43,7 +43,7 @@ public function impersonate(
4343
*
4444
* @param \Psr\Http\Message\ServerRequestInterface $request The request
4545
* @param \Psr\Http\Message\ResponseInterface $response The response
46-
* @return array
46+
* @return array{request: \Psr\Http\Message\ServerRequestInterface, response: \Psr\Http\Message\ResponseInterface}
4747
*/
4848
public function stopImpersonating(ServerRequestInterface $request, ResponseInterface $response): array;
4949

src/Authenticator/PersistenceInterface.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ interface PersistenceInterface
2828
* @param \Psr\Http\Message\ServerRequestInterface $request The request object.
2929
* @param \Psr\Http\Message\ResponseInterface $response The response object.
3030
* @param \ArrayAccess|array $identity Identity data to persist.
31-
* @return array
32-
* @psalm-return array{request: \Psr\Http\Message\ServerRequestInterface, response: \Psr\Http\Message\ResponseInterface} Returns an array containing the request and response object
31+
* @return array{request: \Psr\Http\Message\ServerRequestInterface, response: \Psr\Http\Message\ResponseInterface} Returns an array containing the request and response object
3332
*/
3433
public function persistIdentity(
3534
ServerRequestInterface $request,
@@ -42,8 +41,7 @@ public function persistIdentity(
4241
*
4342
* @param \Psr\Http\Message\ServerRequestInterface $request The request object.
4443
* @param \Psr\Http\Message\ResponseInterface $response The response object.
45-
* @return array
46-
* @psalm-return array{request: \Psr\Http\Message\ServerRequestInterface, response: \Psr\Http\Message\ResponseInterface} Returns an array containing the request and response object
44+
* @return array{request: \Psr\Http\Message\ServerRequestInterface, response: \Psr\Http\Message\ResponseInterface} Returns an array containing the request and response object
4745
*/
4846
public function clearIdentity(ServerRequestInterface $request, ResponseInterface $response): array;
4947
}

src/Controller/Component/AuthenticationComponent.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function setIdentity(ArrayAccess $identity)
299299

300300
$service->clearIdentity($controller->getRequest(), $controller->getResponse());
301301

302-
/** @psalm-var array{request: \Cake\Http\ServerRequest, response: \Cake\Http\Response} $result */
302+
/** @var array{request: \Cake\Http\ServerRequest, response: \Cake\Http\Response} $result */
303303
$result = $service->persistIdentity(
304304
$controller->getRequest(),
305305
$controller->getResponse(),
@@ -322,7 +322,7 @@ public function setIdentity(ArrayAccess $identity)
322322
public function logout(): ?string
323323
{
324324
$controller = $this->getController();
325-
/** @psalm-var array{request: \Cake\Http\ServerRequest, response: \Cake\Http\Response} $result */
325+
/** @var array{request: \Cake\Http\ServerRequest, response: \Cake\Http\Response} $result */
326326
$result = $this->getAuthenticationService()->clearIdentity(
327327
$controller->getRequest(),
328328
$controller->getResponse(),
@@ -391,7 +391,7 @@ public function impersonate(ArrayAccess $impersonated)
391391
$impersonator = new ArrayObject($impersonator);
392392
}
393393
$controller = $this->getController();
394-
/** @psalm-var array{request: \Cake\Http\ServerRequest, response: \Cake\Http\Response} $result */
394+
/** @var array{request: \Cake\Http\ServerRequest, response: \Cake\Http\Response} $result */
395395
$result = $service->impersonate(
396396
$controller->getRequest(),
397397
$controller->getResponse(),
@@ -421,7 +421,7 @@ public function stopImpersonating()
421421

422422
$controller = $this->getController();
423423

424-
/** @psalm-var array{request: \Cake\Http\ServerRequest, response: \Cake\Http\Response} $result */
424+
/** @var array{request: \Cake\Http\ServerRequest, response: \Cake\Http\Response} $result */
425425
$result = $service->stopImpersonating(
426426
$controller->getRequest(),
427427
$controller->getResponse(),

src/Middleware/AuthenticationMiddleware.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
106106
$response = $handler->handle($request);
107107
$authenticator = $service->getAuthenticationProvider();
108108

109-
if ($authenticator !== null && !$authenticator instanceof StatelessInterface) {
110-
/**
111-
* @psalm-suppress PossiblyNullArgument
112-
* @phpstan-ignore-next-line
113-
*/
109+
if ($authenticator !== null && !$authenticator instanceof StatelessInterface && $result->getData()) {
114110
$return = $service->persistIdentity($request, $response, $result->getData());
115111
$response = $return['response'];
116112
}

src/View/Helper/IdentityHelper.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,6 @@ class IdentityHelper extends Helper
5656
public function initialize(array $config): void
5757
{
5858
$this->_identity = $this->_View->getRequest()->getAttribute($this->getConfig('identityAttribute'));
59-
60-
if (empty($this->_identity)) {
61-
return;
62-
}
63-
64-
if (!$this->_identity instanceof IdentityInterface) {
65-
throw new RuntimeException(
66-
sprintf('Identity found in request does not implement %s', IdentityInterface::class),
67-
);
68-
}
6959
}
7060

7161
/**

0 commit comments

Comments
 (0)