Skip to content

Commit a00d679

Browse files
committed
minor #11 Fix CI (static analysis and unstable tests) (mtarld)
This PR was squashed before being merged into the 0.1-dev branch. Discussion ---------- Fix CI (static analysis and unstable tests) - Fix Psalm tests - Fix unstable tests Commits ------- ae929e4 Fix unstable tests 90d22d7 Fix static analysis
2 parents cc5f9e4 + ae929e4 commit a00d679

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

src/Command/CreateClientCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ private function buildClientFromInput(InputInterface $input): Client
111111
/** @var string $identifier */
112112
$identifier = $input->getArgument('identifier') ?? hash('md5', random_bytes(16));
113113

114-
/** @var bool $isPublic */
115114
$isPublic = $input->getOption('public');
116115

117116
if ($isPublic && null !== $input->getArgument('secret')) {

src/Controller/AuthorizationController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use League\OAuth2\Server\AuthorizationServer;
1414
use League\OAuth2\Server\Exception\OAuthServerException;
1515
use Psr\Http\Message\ResponseFactoryInterface;
16+
use Psr\Http\Message\ResponseInterface;
1617
use Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface;
1718
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
1819
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -106,7 +107,10 @@ public function indexAction(Request $request): Response
106107
$authRequest->setUser($this->userConverter->toLeague($event->getUser()));
107108

108109
if ($event->hasResponse()) {
109-
return $this->httpFoundationFactory->createResponse($event->getResponse());
110+
/** @var ResponseInterface $response */
111+
$response = $event->getResponse();
112+
113+
return $this->httpFoundationFactory->createResponse($response);
110114
}
111115

112116
$authRequest->setAuthorizationApproved($event->getAuthorizationResolution());

src/Event/ScopeResolveEvent.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function getScopes(): array
5252

5353
public function setScopes(Scope ...$scopes): self
5454
{
55+
/** @var list<Scope> $scopes */
5556
$this->scopes = $scopes;
5657

5758
return $this;

src/Manager/InMemory/ClientManager.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,10 @@ private static function passesFilter(array $clientValues, array $filterValues):
6969
return true;
7070
}
7171

72-
/** @var list<string> $clientValues */
73-
$clientValues = array_map('strval', $clientValues);
74-
/** @var list<string> $filterValues */
75-
$filterValues = array_map('strval', $filterValues);
76-
77-
/** @var list<string> $valuesPassed */
78-
$valuesPassed = array_intersect($filterValues, $clientValues);
72+
$valuesPassed = array_intersect(
73+
array_map('strval', $filterValues),
74+
array_map('strval', $clientValues)
75+
);
7976

8077
return \count($valuesPassed) > 0;
8178
}

src/Model/Client.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function getRedirectUris(): array
8686

8787
public function setRedirectUris(RedirectUri ...$redirectUris): self
8888
{
89+
/** @var list<RedirectUri> $redirectUris */
8990
$this->redirectUris = $redirectUris;
9091

9192
return $this;
@@ -103,6 +104,7 @@ public function getGrants(): array
103104

104105
public function setGrants(Grant ...$grants): self
105106
{
107+
/** @var list<Grant> $grants */
106108
$this->grants = $grants;
107109

108110
return $this;
@@ -120,6 +122,7 @@ public function getScopes(): array
120122

121123
public function setScopes(Scope ...$scopes): self
122124
{
125+
/** @var list<Scope> $scopes */
123126
$this->scopes = $scopes;
124127

125128
return $this;

tests/Acceptance/TokenEndpointTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public function testSuccessfulClientCredentialsRequest(): void
4444
$jsonResponse = json_decode($response->getContent(), true);
4545

4646
$this->assertSame('Bearer', $jsonResponse['token_type']);
47-
$this->assertSame(3600, $jsonResponse['expires_in']);
47+
$this->assertLessThanOrEqual(3600, $jsonResponse['expires_in']);
48+
$this->assertGreaterThan(0, $jsonResponse['expires_in']);
4849
$this->assertNotEmpty($jsonResponse['access_token']);
4950
}
5051

@@ -73,7 +74,8 @@ public function testSuccessfulPasswordRequest(): void
7374
$jsonResponse = json_decode($response->getContent(), true);
7475

7576
$this->assertSame('Bearer', $jsonResponse['token_type']);
76-
$this->assertSame(3600, $jsonResponse['expires_in']);
77+
$this->assertLessThanOrEqual(3600, $jsonResponse['expires_in']);
78+
$this->assertGreaterThan(0, $jsonResponse['expires_in']);
7779
$this->assertNotEmpty($jsonResponse['access_token']);
7880
$this->assertNotEmpty($jsonResponse['refresh_token']);
7981
}
@@ -100,7 +102,8 @@ public function testSuccessfulRefreshTokenRequest(): void
100102
$jsonResponse = json_decode($response->getContent(), true);
101103

102104
$this->assertSame('Bearer', $jsonResponse['token_type']);
103-
$this->assertSame(3600, $jsonResponse['expires_in']);
105+
$this->assertLessThanOrEqual(3600, $jsonResponse['expires_in']);
106+
$this->assertGreaterThan(0, $jsonResponse['expires_in']);
104107
$this->assertNotEmpty($jsonResponse['access_token']);
105108
$this->assertNotEmpty($jsonResponse['refresh_token']);
106109
}
@@ -128,7 +131,8 @@ public function testSuccessfulAuthorizationCodeRequest(): void
128131
$jsonResponse = json_decode($response->getContent(), true);
129132

130133
$this->assertSame('Bearer', $jsonResponse['token_type']);
131-
$this->assertSame(3600, $jsonResponse['expires_in']);
134+
$this->assertLessThanOrEqual(3600, $jsonResponse['expires_in']);
135+
$this->assertGreaterThan(0, $jsonResponse['expires_in']);
132136
$this->assertNotEmpty($jsonResponse['access_token']);
133137
}
134138

@@ -154,7 +158,8 @@ public function testSuccessfulAuthorizationCodeRequestWithPublicClient(): void
154158
$jsonResponse = json_decode($response->getContent(), true);
155159

156160
$this->assertSame('Bearer', $jsonResponse['token_type']);
157-
$this->assertSame(3600, $jsonResponse['expires_in']);
161+
$this->assertLessThanOrEqual(3600, $jsonResponse['expires_in']);
162+
$this->assertGreaterThan(0, $jsonResponse['expires_in']);
158163
$this->assertNotEmpty($jsonResponse['access_token']);
159164
}
160165

0 commit comments

Comments
 (0)