minor #26566 [BrowserKit] Improves CookieJar::get (dunglas)

This PR was merged into the 2.7 branch.

Discussion
----------

[BrowserKit] Improves CookieJar::get

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      |no
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

* change a call to `substr` + `strlen` to a single `strpos`

Commits
-------

57993143a9 [BrowserKit] Improves CookieJar::get
This commit is contained in:
Fabien Potencier 2018-03-16 11:26:57 -07:00
commit 1390529b0f
1 changed files with 2 additions and 2 deletions

View File

@ -47,13 +47,13 @@ class CookieJar
foreach ($this->cookieJar as $cookieDomain => $pathCookies) {
if ($cookieDomain) {
$cookieDomain = '.'.ltrim($cookieDomain, '.');
if ($cookieDomain != substr('.'.$domain, -strlen($cookieDomain))) {
if ($cookieDomain !== substr('.'.$domain, -\strlen($cookieDomain))) {
continue;
}
}
foreach ($pathCookies as $cookiePath => $namedCookies) {
if ($cookiePath != substr($path, 0, strlen($cookiePath))) {
if (0 !== strpos($path, $cookiePath)) {
continue;
}
if (isset($namedCookies[$name])) {