Skip to content

Commit 4165859

Browse files
committed
removed useless type juggling and checking
1 parent f3d72e0 commit 4165859

File tree

7 files changed

+11
-16
lines changed

7 files changed

+11
-16
lines changed

src/Application/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function run(): void
105105
public function createInitialRequest(): Request
106106
{
107107
$request = $this->router->match($this->httpRequest);
108-
if (!$request instanceof Request) {
108+
if (!$request) {
109109
throw new BadRequestException('No route for HTTP request.');
110110
}
111111
return $request;

src/Application/PresenterFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getPresenterClass(string &$name): string
6363
return $this->cache[$name];
6464
}
6565

66-
if (!is_string($name) || !Nette\Utils\Strings::match($name, '#^[a-zA-Z\x7f-\xff][a-zA-Z0-9\x7f-\xff:]*\z#')) {
66+
if (!Nette\Utils\Strings::match($name, '#^[a-zA-Z\x7f-\xff][a-zA-Z0-9\x7f-\xff:]*\z#')) {
6767
throw new InvalidPresenterException("Presenter name must be alphanumeric string, '$name' is invalid.");
6868
}
6969

src/Application/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public function isMethod(string $method): bool
199199
*/
200200
public function setFlag(string $flag, bool $value = TRUE)
201201
{
202-
$this->flags[$flag] = (bool) $value;
202+
$this->flags[$flag] = $value;
203203
return $this;
204204
}
205205

src/Application/Responses/RedirectResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class RedirectResponse implements Nette\Application\IResponse
2929

3030
public function __construct(string $url, int $httpCode = Http\IResponse::S302_FOUND)
3131
{
32-
$this->url = (string) $url;
33-
$this->httpCode = (int) $httpCode;
32+
$this->url = $url;
33+
$this->httpCode = $httpCode;
3434
}
3535

3636

src/Application/UI/Component.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function validateParent(Nette\ComponentModel\IContainer $parent): void
7878
protected function tryCall(string $method, array $params): bool
7979
{
8080
$rc = $this->getReflection();
81-
if ($rc->hasMethod((string) $method)) {
81+
if ($rc->hasMethod($method)) {
8282
$rm = $rc->getMethod($method);
8383
if ($rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic()) {
8484
$this->checkRequirements($rm);
@@ -254,7 +254,7 @@ public function signalReceived(string $signal): void
254254
*/
255255
public static function formatSignalMethod(string $signal): string
256256
{
257-
return $signal == NULL ? NULL : 'handle' . $signal; // intentionally ==
257+
return 'handle' . $signal;
258258
}
259259

260260

src/Application/UI/Control.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ public function setTemplateFactory(ITemplateFactory $templateFactory)
4444
public function getTemplate(): ITemplate
4545
{
4646
if ($this->template === NULL) {
47-
$value = $this->createTemplate();
48-
if (!$value instanceof ITemplate && $value !== NULL) {
49-
$class2 = get_class($value); $class = get_class($this);
50-
throw new Nette\UnexpectedValueException("Object returned by $class::createTemplate() must be instance of Nette\\Application\\UI\\ITemplate, '$class2' given.");
51-
}
52-
$this->template = $value;
47+
$this->template = $this->createTemplate();
5348
}
5449
return $this->template;
5550
}

src/Application/UI/Presenter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public function getAction(bool $fullyQualified = FALSE): string
371371
*/
372372
public function changeAction(string $action): void
373373
{
374-
$this->action = $this->view = (string) $action;
374+
$this->action = $this->view = $action;
375375
}
376376

377377

@@ -390,7 +390,7 @@ public function getView(): string
390390
*/
391391
public function setView(string $view)
392392
{
393-
$this->view = (string) $view;
393+
$this->view = $view;
394394
return $this;
395395
}
396396

@@ -623,7 +623,7 @@ public function forward($destination, $args = []): void
623623
public function redirectUrl(string $url, int $httpCode = NULL): void
624624
{
625625
if ($this->isAjax()) {
626-
$this->payload->redirect = (string) $url;
626+
$this->payload->redirect = $url;
627627
$this->sendPayload();
628628

629629
} elseif (!$httpCode) {

0 commit comments

Comments
 (0)