Skip to content

Commit 9902659

Browse files
committed
minor #47370 Remove usage of empty function when possible (alamirault)
This PR was squashed before being merged into the 6.2 branch. Discussion ---------- Remove usage of empty function when possible | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> In recent code reviews we suggest to use `!$var` instead of `empty($var)` In order to keep same code style in codebase, I replaced usages of empty when it is possible and typehinted Commits ------- 026edbe601 Remove usage of empty function when possible
2 parents 5e6b221 + 9b6ff05 commit 9902659

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

EventListener/AbstractSessionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function onKernelResponse(ResponseEvent $event)
151151
$request = $event->getRequest();
152152
$requestSessionCookieId = $request->cookies->get($sessionName);
153153

154-
$isSessionEmpty = ($session instanceof Session ? $session->isEmpty() : empty($session->all())) && empty($_SESSION); // checking $_SESSION to keep compatibility with native sessions
154+
$isSessionEmpty = ($session instanceof Session ? $session->isEmpty() : !$session->all()) && empty($_SESSION); // checking $_SESSION to keep compatibility with native sessions
155155
if ($requestSessionCookieId && $isSessionEmpty) {
156156
// PHP internally sets the session cookie value to "deleted" when setcookie() is called with empty string $value argument
157157
// which happens in \Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler::destroy

0 commit comments

Comments
 (0)