Skip to content

Commit 52ba64f

Browse files
committed
removed useless type juggling and checking
1 parent 0d95852 commit 52ba64f

File tree

7 files changed

+10
-15
lines changed

7 files changed

+10
-15
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
@@ -33,8 +33,8 @@ class RedirectResponse implements Nette\Application\IResponse
3333
*/
3434
public function __construct(string $url, int $code = Http\IResponse::S302_FOUND)
3535
{
36-
$this->url = (string) $url;
37-
$this->code = (int) $code;
36+
$this->url = $url;
37+
$this->code = $code;
3838
}
3939

4040

src/Application/UI/Component.php

Lines changed: 1 addition & 1 deletion
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);

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
@@ -372,7 +372,7 @@ public function getAction(bool $fullyQualified = FALSE): string
372372
*/
373373
public function changeAction(string $action): void
374374
{
375-
if (is_string($action) && Nette\Utils\Strings::match($action, '#^[a-zA-Z0-9][a-zA-Z0-9_\x7f-\xff]*\z#')) {
375+
if (Nette\Utils\Strings::match($action, '#^[a-zA-Z0-9][a-zA-Z0-9_\x7f-\xff]*\z#')) {
376376
$this->action = $action;
377377
$this->view = $action;
378378
} else {
@@ -396,7 +396,7 @@ public function getView(): string
396396
*/
397397
public function setView(string $view)
398398
{
399-
$this->view = (string) $view;
399+
$this->view = $view;
400400
return $this;
401401
}
402402

@@ -629,7 +629,7 @@ public function forward($destination, $args = []): void
629629
public function redirectUrl(string $url, int $code = NULL): void
630630
{
631631
if ($this->isAjax()) {
632-
$this->payload->redirect = (string) $url;
632+
$this->payload->redirect = $url;
633633
$this->sendPayload();
634634

635635
} elseif (!$code) {

0 commit comments

Comments
 (0)