Skip to content

Commit 50e0687

Browse files
gharlannicolas-grekas
authored andcommitted
optimize in_array calls
1 parent 03378f7 commit 50e0687

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

HeaderUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public static function unquote(string $s): string
164164
*/
165165
public static function makeDisposition(string $disposition, string $filename, string $filenameFallback = ''): string
166166
{
167-
if (!\in_array($disposition, [self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE])) {
167+
if (!\in_array($disposition, [self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE], true)) {
168168
throw new \InvalidArgumentException(\sprintf('The disposition must be either "%s" or "%s".', self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE));
169169
}
170170

Request.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,15 +1351,15 @@ public function isMethod(string $method): bool
13511351
*/
13521352
public function isMethodSafe(): bool
13531353
{
1354-
return \in_array($this->getMethod(), ['GET', 'HEAD', 'OPTIONS', 'TRACE']);
1354+
return \in_array($this->getMethod(), ['GET', 'HEAD', 'OPTIONS', 'TRACE'], true);
13551355
}
13561356

13571357
/**
13581358
* Checks whether or not the method is idempotent.
13591359
*/
13601360
public function isMethodIdempotent(): bool
13611361
{
1362-
return \in_array($this->getMethod(), ['HEAD', 'GET', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'PURGE']);
1362+
return \in_array($this->getMethod(), ['HEAD', 'GET', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'PURGE'], true);
13631363
}
13641364

13651365
/**
@@ -1369,7 +1369,7 @@ public function isMethodIdempotent(): bool
13691369
*/
13701370
public function isMethodCacheable(): bool
13711371
{
1372-
return \in_array($this->getMethod(), ['GET', 'HEAD']);
1372+
return \in_array($this->getMethod(), ['GET', 'HEAD'], true);
13731373
}
13741374

13751375
/**

Response.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ public function getCharset(): ?string
545545
*/
546546
public function isCacheable(): bool
547547
{
548-
if (!\in_array($this->statusCode, [200, 203, 300, 301, 302, 404, 410])) {
548+
if (!\in_array($this->statusCode, [200, 203, 300, 301, 302, 404, 410], true)) {
549549
return false;
550550
}
551551

@@ -1254,7 +1254,7 @@ public function isNotFound(): bool
12541254
*/
12551255
public function isRedirect(?string $location = null): bool
12561256
{
1257-
return \in_array($this->statusCode, [201, 301, 302, 303, 307, 308]) && (null === $location ?: $location == $this->headers->get('Location'));
1257+
return \in_array($this->statusCode, [201, 301, 302, 303, 307, 308], true) && (null === $location ?: $location == $this->headers->get('Location'));
12581258
}
12591259

12601260
/**
@@ -1264,7 +1264,7 @@ public function isRedirect(?string $location = null): bool
12641264
*/
12651265
public function isEmpty(): bool
12661266
{
1267-
return \in_array($this->statusCode, [204, 304]);
1267+
return \in_array($this->statusCode, [204, 304], true);
12681268
}
12691269

12701270
/**

ResponseHeaderBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function removeCookie(string $name, ?string $path = '/', ?string $domain
194194
*/
195195
public function getCookies(string $format = self::COOKIES_FLAT): array
196196
{
197-
if (!\in_array($format, [self::COOKIES_FLAT, self::COOKIES_ARRAY])) {
197+
if (!\in_array($format, [self::COOKIES_FLAT, self::COOKIES_ARRAY], true)) {
198198
throw new \InvalidArgumentException(\sprintf('Format "%s" invalid (%s).', $format, implode(', ', [self::COOKIES_FLAT, self::COOKIES_ARRAY])));
199199
}
200200

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy