Skip to content

Commit 90efb0f

Browse files
committed
fix: replace all usage of empty
1 parent 9580861 commit 90efb0f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Controller/AuthorizationController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@ public function indexAction(Request $request): Response
125125
// "application/x-www-form-urlencoded" format
126126
//
127127
// so if redirectUri is not already set, we try to set request redirect_uri params, fallback to first redirectUri of client
128-
/** @psalm-suppress RiskyTruthyFalsyComparison !empty($e->getHint()),empty($e->getRedirectUri()) we really want to check null and empty */
129-
if (isset($client) && $client !== null
128+
if (isset($client) && null !== $client
130129
&& ('invalid_client' === $e->getErrorType()
131-
|| ('invalid_request' === $e->getErrorType() && !empty($e->getHint())
130+
|| ('invalid_request' === $e->getErrorType() && null !== $e->getHint() && 0 < \strlen($e->getHint())
132131
&& !\in_array(sscanf($e->getHint() ?? '', 'Check the `%s` parameter')[0] ?? null, ['client_id', 'client_secret', 'redirect_uri'])))
133-
&& empty($e->getRedirectUri())) {
132+
&& (null === $e->getRedirectUri() || 0 === \strlen($e->getRedirectUri()))) {
134133
/** @var \League\Bundle\OAuth2ServerBundle\Model\ClientInterface $client */
135134
$redirectUri = $request->query->get('redirect_uri', // query string has priority
136-
(string)$request->request->get('redirect_uri', // then we check body to support POST request
137-
$client->getRedirectUris()[0]?->__toString() ?? '')); // then first client redirect uri
138-
if (!empty($redirectUri)) {
135+
(string) $request->request->get('redirect_uri', // then we check body to support POST request
136+
$client->getRedirectUris()[0]?->__toString() ?? '') // then first client redirect uri
137+
);
138+
if (0 < \strlen($redirectUri)) {
139139
$e = new OAuthServerException(
140140
$e->getMessage(),
141141
$e->getCode(),

0 commit comments

Comments
 (0)