Skip to content

Commit d272906

Browse files
committed
Remove unnecessary empty usages
1 parent 44357c7 commit d272906

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

Cookie.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ public function __construct(string $name, ?string $value = null, int|string|\Dat
101101
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name));
102102
}
103103

104-
if (empty($name)) {
104+
if (!$name) {
105105
throw new \InvalidArgumentException('The cookie name cannot be empty.');
106106
}
107107

108108
$this->name = $name;
109109
$this->value = $value;
110110
$this->domain = $domain;
111111
$this->expire = self::expiresTimestamp($expire);
112-
$this->path = empty($path) ? '/' : $path;
112+
$this->path = $path ?: '/';
113113
$this->secure = $secure;
114114
$this->httpOnly = $httpOnly;
115115
$this->raw = $raw;

Request.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ public function isSecure(): bool
10481048

10491049
$https = $this->server->get('HTTPS');
10501050

1051-
return !empty($https) && 'off' !== strtolower($https);
1051+
return $https && 'off' !== strtolower($https);
10521052
}
10531053

10541054
/**
@@ -1528,7 +1528,7 @@ public function getPreferredLanguage(?array $locales = null): ?string
15281528
{
15291529
$preferredLanguages = $this->getLanguages();
15301530

1531-
if (empty($locales)) {
1531+
if (!$locales) {
15321532
return $preferredLanguages[0] ?? null;
15331533
}
15341534

@@ -1759,7 +1759,7 @@ protected function prepareBaseUrl(): string
17591759
}
17601760

17611761
$basename = basename($baseUrl ?? '');
1762-
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) {
1762+
if (!$basename || !strpos(rawurldecode($truncatedRequestUri), $basename)) {
17631763
// no match whatsoever; set it blank
17641764
return '';
17651765
}
@@ -1780,7 +1780,7 @@ protected function prepareBaseUrl(): string
17801780
protected function prepareBasePath(): string
17811781
{
17821782
$baseUrl = $this->getBaseUrl();
1783-
if (empty($baseUrl)) {
1783+
if (!$baseUrl) {
17841784
return '';
17851785
}
17861786

ResponseHeaderBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function removeCookie(string $name, ?string $path = '/', ?string $domain
180180
}
181181
}
182182

183-
if (empty($this->cookies)) {
183+
if (!$this->cookies) {
184184
unset($this->headerNames['set-cookie']);
185185
}
186186
}

Session/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function isEmpty(): bool
134134
}
135135
}
136136
foreach ($this->data as &$data) {
137-
if (!empty($data)) {
137+
if ($data) {
138138
return false;
139139
}
140140
}

Session/Storage/MockArraySessionStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function start(): bool
5656
return true;
5757
}
5858

59-
if (empty($this->id)) {
59+
if (!$this->id) {
6060
$this->id = $this->generateId();
6161
}
6262

0 commit comments

Comments
 (0)