Skip to content

Commit ffd0ba0

Browse files
derrabusnicolas-grekas
authored andcommitted
Leverage str_contains/str_starts_with
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent b0eb9ba commit ffd0ba0

5 files changed

+6
-5
lines changed

Firewall/ChannelListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function supports(Request $request): ?bool
5151
if (null !== $this->logger) {
5252
if ('https' === $request->headers->get('X-Forwarded-Proto')) {
5353
$this->logger->info('Redirecting to HTTPS. ("X-Forwarded-Proto" header is set to "https" - did you set "trusted_proxies" correctly?)');
54-
} elseif (false !== strpos($request->headers->get('Forwarded'), 'proto=https')) {
54+
} elseif (str_contains($request->headers->get('Forwarded'), 'proto=https')) {
5555
$this->logger->info('Redirecting to HTTPS. ("Forwarded" header is set to "proto=https" - did you set "trusted_proxies" correctly?)');
5656
} else {
5757
$this->logger->info('Redirecting to HTTPS.');

Firewall/UsernamePasswordJsonAuthenticationListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
8282

8383
public function supports(Request $request): ?bool
8484
{
85-
if (false === strpos($request->getRequestFormat() ?? '', 'json')
86-
&& false === strpos($request->getContentType() ?? '', 'json')
85+
if (!str_contains($request->getRequestFormat() ?? '', 'json')
86+
&& !str_contains($request->getContentType() ?? '', 'json')
8787
) {
8888
return false;
8989
}

HttpUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function checkRequestPath(Request $request, $path)
149149
*/
150150
public function generateUri($request, $path)
151151
{
152-
if (0 === strpos($path, 'http') || !$path) {
152+
if (str_starts_with($path, 'http') || !$path) {
153153
return $path;
154154
}
155155

RememberMe/AbstractRememberMeServices.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ protected function decodeCookie($rawCookie)
260260
protected function encodeCookie(array $cookieParts)
261261
{
262262
foreach ($cookieParts as $cookiePart) {
263-
if (false !== strpos($cookiePart, self::COOKIE_DELIMITER)) {
263+
if (str_contains($cookiePart, self::COOKIE_DELIMITER)) {
264264
throw new \InvalidArgumentException(sprintf('$cookieParts should not contain the cookie delimiter "%s".', self::COOKIE_DELIMITER));
265265
}
266266
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"symfony/security-core": "^4.4.8",
2121
"symfony/http-foundation": "^3.4.40|^4.4.7|^5.0.7",
2222
"symfony/http-kernel": "^4.4",
23+
"symfony/polyfill-php80": "^1.16",
2324
"symfony/property-access": "^3.4|^4.0|^5.0"
2425
},
2526
"require-dev": {

0 commit comments

Comments
 (0)