Skip to content

Commit 9629d15

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

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ public function restart()
662662
protected function getAbsoluteUri($uri)
663663
{
664664
// already absolute?
665-
if (0 === strpos($uri, 'http://') || 0 === strpos($uri, 'https://')) {
665+
if (str_starts_with($uri, 'http://') || str_starts_with($uri, 'https://')) {
666666
return $uri;
667667
}
668668

@@ -676,7 +676,7 @@ protected function getAbsoluteUri($uri)
676676
}
677677

678678
// protocol relative URL
679-
if (0 === strpos($uri, '//')) {
679+
if (str_starts_with($uri, '//')) {
680680
return parse_url($currentUri, \PHP_URL_SCHEME).':'.$uri;
681681
}
682682

Cookie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public static function fromString($cookie, $url = null)
132132
{
133133
$parts = explode(';', $cookie);
134134

135-
if (false === strpos($parts[0], '=')) {
135+
if (!str_contains($parts[0], '=')) {
136136
throw new \InvalidArgumentException(sprintf('The cookie string "%s" is not valid.', $parts[0]));
137137
}
138138

CookieJar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function get($name, $path = '/', $domain = null)
5252
}
5353

5454
foreach ($pathCookies as $cookiePath => $namedCookies) {
55-
if (0 !== strpos($path, $cookiePath)) {
55+
if (!str_starts_with($path, $cookiePath)) {
5656
continue;
5757
}
5858
if (isset($namedCookies[$name])) {

HttpBrowser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private function getHeaders(Request $request): array
100100
foreach ($request->getServer() as $key => $value) {
101101
$key = strtolower(str_replace('_', '-', $key));
102102
$contentHeaders = ['content-length' => true, 'content-md5' => true, 'content-type' => true];
103-
if (0 === strpos($key, 'http-')) {
103+
if (str_starts_with($key, 'http-')) {
104104
$headers[substr($key, 5)] = $value;
105105
} elseif (isset($contentHeaders[$key])) {
106106
// CONTENT_* are not prefixed with HTTP_

0 commit comments

Comments
 (0)