Skip to content

Commit 4b8a4bd

Browse files
committed
removed useless type juggling
1 parent 07414ed commit 4b8a4bd

File tree

8 files changed

+19
-24
lines changed

8 files changed

+19
-24
lines changed

src/Http/FileUpload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function getTemporaryFile(): string
113113
*/
114114
public function __toString(): string
115115
{
116-
return (string) $this->tmpName;
116+
return $this->tmpName;
117117
}
118118

119119

src/Http/RequestFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class RequestFactory
4141
*/
4242
public function setBinary(bool $binary = TRUE)
4343
{
44-
$this->binary = (bool) $binary;
44+
$this->binary = $binary;
4545
return $this;
4646
}
4747

src/Http/Response.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public function __construct()
6060
*/
6161
public function setCode(int $code, string $reason = NULL)
6262
{
63-
$code = (int) $code;
6463
if ($code < 100 || $code > 599) {
6564
throw new Nette\InvalidArgumentException("Bad HTTP response '$code'.");
6665
}
@@ -242,10 +241,10 @@ public function setCookie(string $name, string $value, $time, string $path = NUL
242241
$name,
243242
$value,
244243
$time ? (int) DateTime::from($time)->format('U') : 0,
245-
$path === NULL ? $this->cookiePath : (string) $path,
246-
$domain === NULL ? $this->cookieDomain : (string) $domain,
247-
$secure === NULL ? $this->cookieSecure : (bool) $secure,
248-
$httpOnly === NULL ? $this->cookieHttpOnly : (bool) $httpOnly
244+
$path === NULL ? $this->cookiePath : $path,
245+
$domain === NULL ? $this->cookieDomain : $domain,
246+
$secure === NULL ? $this->cookieSecure : $secure,
247+
$httpOnly === NULL ? $this->cookieHttpOnly : $httpOnly
249248
);
250249
Helpers::removeDuplicateCookies();
251250
return $this;

src/Http/Session.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function start()
152152
*/
153153
public function isStarted(): bool
154154
{
155-
return (bool) self::$started;
155+
return self::$started;
156156
}
157157

158158

@@ -237,8 +237,8 @@ public function getId(): string
237237
*/
238238
public function setName(string $name)
239239
{
240-
if (!is_string($name) || !preg_match('#[^0-9.][^.]*\z#A', $name)) {
241-
throw new Nette\InvalidArgumentException('Session name must be a string and cannot contain dot.');
240+
if (!preg_match('#[^0-9.][^.]*\z#A', $name)) {
241+
throw new Nette\InvalidArgumentException('Session name cannot contain dot.');
242242
}
243243

244244
session_name($name);

src/Http/SessionSection.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ class SessionSection implements \IteratorAggregate, \ArrayAccess
4040
*/
4141
public function __construct(Session $session, string $name)
4242
{
43-
if (!is_string($name)) {
44-
throw new Nette\InvalidArgumentException('Session namespace must be a string, ' . gettype($name) . ' given.');
45-
}
46-
4743
$this->session = $session;
4844
$this->name = $name;
4945
}

src/Http/Url.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function __construct($url = NULL)
120120
*/
121121
public function setScheme(string $value)
122122
{
123-
$this->scheme = (string) $value;
123+
$this->scheme = $value;
124124
return $this;
125125
}
126126

@@ -140,7 +140,7 @@ public function getScheme(): string
140140
*/
141141
public function setUser(string $value)
142142
{
143-
$this->user = (string) $value;
143+
$this->user = $value;
144144
return $this;
145145
}
146146

@@ -160,7 +160,7 @@ public function getUser(): string
160160
*/
161161
public function setPassword(string $value)
162162
{
163-
$this->password = (string) $value;
163+
$this->password = $value;
164164
return $this;
165165
}
166166

@@ -180,7 +180,7 @@ public function getPassword(): string
180180
*/
181181
public function setHost(string $value)
182182
{
183-
$this->host = (string) $value;
183+
$this->host = $value;
184184
$this->setPath($this->path);
185185
return $this;
186186
}
@@ -201,7 +201,7 @@ public function getHost(): string
201201
*/
202202
public function setPort(int $value)
203203
{
204-
$this->port = (int) $value;
204+
$this->port = $value;
205205
return $this;
206206
}
207207

@@ -224,7 +224,7 @@ public function getPort()
224224
*/
225225
public function setPath(string $value)
226226
{
227-
$this->path = (string) $value;
227+
$this->path = $value;
228228
if ($this->host && substr($this->path, 0, 1) !== '/') {
229229
$this->path = '/' . $this->path;
230230
}
@@ -311,7 +311,7 @@ public function setQueryParameter(string $name, $value)
311311
*/
312312
public function setFragment(string $value)
313313
{
314-
$this->fragment = (string) $value;
314+
$this->fragment = $value;
315315
return $this;
316316
}
317317

src/Http/UrlScript.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct($url = NULL, $scriptPath = '')
4545
*/
4646
public function setScriptPath(string $value)
4747
{
48-
$this->scriptPath = (string) $value;
48+
$this->scriptPath = $value;
4949
return $this;
5050
}
5151

src/Http/UserStorage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(Session $sessionHandler)
4343
public function setAuthenticated(bool $state)
4444
{
4545
$section = $this->getSessionSection(TRUE);
46-
$section->authenticated = (bool) $state;
46+
$section->authenticated = $state;
4747

4848
// Session Fixation defence
4949
$this->sessionHandler->regenerateId();
@@ -99,7 +99,7 @@ public function getIdentity()
9999
public function setNamespace(string $namespace)
100100
{
101101
if ($this->namespace !== $namespace) {
102-
$this->namespace = (string) $namespace;
102+
$this->namespace = $namespace;
103103
$this->sessionSection = NULL;
104104
}
105105
return $this;

0 commit comments

Comments
 (0)