Skip to content

Commit c1e3f64

Browse files
Merge branch '5.2' into 5.3
* 5.2: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents 00f9b35 + ed7ebe2 commit c1e3f64

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

Cookie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static function fromString(string $cookie, string $url = null)
129129
{
130130
$parts = explode(';', $cookie);
131131

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

CookieJar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ public function get(string $name, string $path = '/', string $domain = null)
4242
foreach ($this->cookieJar as $cookieDomain => $pathCookies) {
4343
if ($cookieDomain && $domain) {
4444
$cookieDomain = '.'.ltrim($cookieDomain, '.');
45-
if ($cookieDomain !== substr('.'.$domain, -\strlen($cookieDomain))) {
45+
if (!str_ends_with('.'.$domain, $cookieDomain)) {
4646
continue;
4747
}
4848
}
4949

5050
foreach ($pathCookies as $cookiePath => $namedCookies) {
51-
if (0 !== strpos($path, $cookiePath)) {
51+
if (!str_starts_with($path, $cookiePath)) {
5252
continue;
5353
}
5454
if (isset($namedCookies[$name])) {

HttpBrowser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected 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_

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"require": {
1919
"php": ">=7.2.5",
20-
"symfony/dom-crawler": "^4.4|^5.0"
20+
"symfony/dom-crawler": "^4.4|^5.0",
21+
"symfony/polyfill-php80": "^1.16"
2122
},
2223
"require-dev": {
2324
"symfony/css-selector": "^4.4|^5.0",

0 commit comments

Comments
 (0)