Skip to content

Commit 9012b17

Browse files
committed
added type hints (BC break)
1 parent 6512dd5 commit 9012b17

File tree

4 files changed

+11
-21
lines changed

4 files changed

+11
-21
lines changed

src/Application/UI/Component.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,9 @@ public function isLinkCurrent(?string $destination = null, $args = []): bool
336336
* Redirect to another presenter, action or signal.
337337
* @param string $destination in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"
338338
* @param array|mixed $args
339-
* @return never
340339
* @throws Nette\Application\AbortException
341340
*/
342-
public function redirect(string $destination, $args = []): void
341+
public function redirect(string $destination, $args = []): never
343342
{
344343
$args = func_num_args() < 3 && is_array($args)
345344
? $args
@@ -354,10 +353,9 @@ public function redirect(string $destination, $args = []): void
354353
* Permanently redirects to presenter, action or signal.
355354
* @param string $destination in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"
356355
* @param array|mixed $args
357-
* @return never
358356
* @throws Nette\Application\AbortException
359357
*/
360-
public function redirectPermanent(string $destination, $args = []): void
358+
public function redirectPermanent(string $destination, $args = []): never
361359
{
362360
$args = func_num_args() < 3 && is_array($args)
363361
? $args

src/Application/UI/Presenter.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,8 @@ public function setLayout(string|bool $layout): static
472472

473473
/**
474474
* @throws Nette\Application\AbortException
475-
* @return never
476475
*/
477-
public function sendTemplate(?Template $template = null): void
476+
public function sendTemplate(?Template $template = null): never
478477
{
479478
$template ??= $this->getTemplate();
480479
if (!$template->getFile()) {
@@ -646,9 +645,8 @@ public function isAjax(): bool
646645
/**
647646
* Sends AJAX payload to the output.
648647
* @throws Nette\Application\AbortException
649-
* @return never
650648
*/
651-
public function sendPayload(): void
649+
public function sendPayload(): never
652650
{
653651
$this->sendResponse(new Responses\JsonResponse($this->getPayload()));
654652
}
@@ -657,9 +655,8 @@ public function sendPayload(): void
657655
/**
658656
* Sends JSON data to the output.
659657
* @throws Nette\Application\AbortException
660-
* @return never
661658
*/
662-
public function sendJson(mixed $data): void
659+
public function sendJson(mixed $data): never
663660
{
664661
$this->sendResponse(new Responses\JsonResponse($data));
665662
}
@@ -671,9 +668,8 @@ public function sendJson(mixed $data): void
671668
/**
672669
* Sends response and terminates presenter.
673670
* @throws Nette\Application\AbortException
674-
* @return never
675671
*/
676-
public function sendResponse(Application\Response $response): void
672+
public function sendResponse(Application\Response $response): never
677673
{
678674
$this->response = $response;
679675
$this->terminate();
@@ -683,9 +679,8 @@ public function sendResponse(Application\Response $response): void
683679
/**
684680
* Correctly terminates presenter.
685681
* @throws Nette\Application\AbortException
686-
* @return never
687682
*/
688-
public function terminate(): void
683+
public function terminate(): never
689684
{
690685
throw new Application\AbortException;
691686
}
@@ -695,9 +690,8 @@ public function terminate(): void
695690
* Forward to another presenter or action.
696691
* @param array|mixed $args
697692
* @throws Nette\Application\AbortException
698-
* @return never
699693
*/
700-
public function forward(string|Nette\Application\Request $destination, $args = []): void
694+
public function forward(string|Nette\Application\Request $destination, $args = []): never
701695
{
702696
if ($destination instanceof Application\Request) {
703697
$this->sendResponse(new Responses\ForwardResponse($destination));
@@ -714,9 +708,8 @@ public function forward(string|Nette\Application\Request $destination, $args = [
714708
/**
715709
* Redirect to another URL and ends presenter execution.
716710
* @throws Nette\Application\AbortException
717-
* @return never
718711
*/
719-
public function redirectUrl(string $url, ?int $httpCode = null): void
712+
public function redirectUrl(string $url, ?int $httpCode = null): never
720713
{
721714
if ($this->isAjax()) {
722715
$this->getPayload()->redirect = $url;

src/Bridges/ApplicationLatte/TemplateFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public function __construct(
3838
}
3939

4040

41-
/** @return Template */
42-
public function createTemplate(?UI\Control $control = null, ?string $class = null): UI\Template
41+
public function createTemplate(?UI\Control $control = null, ?string $class = null): Template
4342
{
4443
$class ??= $this->templateClass;
4544
if (!is_a($class, Template::class, allow_string: true)) {

tests/UI/Component.redirect().phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class TestPresenter extends Application\UI\Presenter
2424
}
2525

2626

27-
public function sendResponse(Application\Response $response): void
27+
public function sendResponse(Application\Response $response): never
2828
{
2929
parent::sendResponse($this->response = $response);
3030
}

0 commit comments

Comments
 (0)