Skip to content

Commit d44fa0b

Browse files
committed
removed useless type juggling
1 parent bc9732c commit d44fa0b

8 files changed

Lines changed: 19 additions & 24 deletions

File tree

src/Http/FileUpload.php

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

118118

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
}
@@ -241,10 +240,10 @@ public function setCookie(string $name, string $value, $time, string $path = NUL
241240
$name,
242241
$value,
243242
$time ? (int) DateTime::from($time)->format('U') : 0,
244-
$path === NULL ? $this->cookiePath : (string) $path,
245-
$domain === NULL ? $this->cookieDomain : (string) $domain,
246-
$secure === NULL ? $this->cookieSecure : (bool) $secure,
247-
$httpOnly === NULL ? $this->cookieHttpOnly : (bool) $httpOnly
243+
$path === NULL ? $this->cookiePath : $path,
244+
$domain === NULL ? $this->cookieDomain : $domain,
245+
$secure === NULL ? $this->cookieSecure : $secure,
246+
$httpOnly === NULL ? $this->cookieHttpOnly : $httpOnly
248247
);
249248
Helpers::removeDuplicateCookies();
250249
return $this;

src/Http/Session.php

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

157157

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

240240
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

@@ -223,7 +223,7 @@ public function getPort(): ?int
223223
*/
224224
public function setPath(string $value)
225225
{
226-
$this->path = (string) $value;
226+
$this->path = $value;
227227
if ($this->host && substr($this->path, 0, 1) !== '/') {
228228
$this->path = '/' . $this->path;
229229
}
@@ -310,7 +310,7 @@ public function setQueryParameter(string $name, $value)
310310
*/
311311
public function setFragment(string $value)
312312
{
313-
$this->fragment = (string) $value;
313+
$this->fragment = $value;
314314
return $this;
315315
}
316316

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, string $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();
@@ -98,7 +98,7 @@ public function getIdentity(): ?Nette\Security\IIdentity
9898
public function setNamespace(string $namespace)
9999
{
100100
if ($this->namespace !== $namespace) {
101-
$this->namespace = (string) $namespace;
101+
$this->namespace = $namespace;
102102
$this->sessionSection = NULL;
103103
}
104104
return $this;

0 commit comments

Comments
 (0)