Skip to content

Commit f9d870f

Browse files
committed
added type hints (BC break)
1 parent db371e3 commit f9d870f

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
@@ -335,10 +335,9 @@ public function isLinkCurrent(?string $destination = null, $args = []): bool
335335
* Redirect to another presenter, action or signal.
336336
* @param string $destination in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"
337337
* @param array|mixed $args
338-
* @return never
339338
* @throws Nette\Application\AbortException
340339
*/
341-
public function redirect(string $destination, $args = []): void
340+
public function redirect(string $destination, $args = []): never
342341
{
343342
$args = func_num_args() < 3 && is_array($args)
344343
? $args
@@ -353,10 +352,9 @@ public function redirect(string $destination, $args = []): void
353352
* Permanently redirects to presenter, action or signal.
354353
* @param string $destination in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"
355354
* @param array|mixed $args
356-
* @return never
357355
* @throws Nette\Application\AbortException
358356
*/
359-
public function redirectPermanent(string $destination, $args = []): void
357+
public function redirectPermanent(string $destination, $args = []): never
360358
{
361359
$args = func_num_args() < 3 && is_array($args)
362360
? $args

src/Application/UI/Presenter.php

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

471471
/**
472472
* @throws Nette\Application\AbortException
473-
* @return never
474473
*/
475-
public function sendTemplate(?Template $template = null): void
474+
public function sendTemplate(?Template $template = null): never
476475
{
477476
$template ??= $this->getTemplate();
478477
if (!$template->getFile()) {
@@ -644,9 +643,8 @@ public function isAjax(): bool
644643
/**
645644
* Sends AJAX payload to the output.
646645
* @throws Nette\Application\AbortException
647-
* @return never
648646
*/
649-
public function sendPayload(): void
647+
public function sendPayload(): never
650648
{
651649
$this->sendResponse(new Responses\JsonResponse($this->getPayload()));
652650
}
@@ -655,9 +653,8 @@ public function sendPayload(): void
655653
/**
656654
* Sends JSON data to the output.
657655
* @throws Nette\Application\AbortException
658-
* @return never
659656
*/
660-
public function sendJson(mixed $data): void
657+
public function sendJson(mixed $data): never
661658
{
662659
$this->sendResponse(new Responses\JsonResponse($data));
663660
}
@@ -669,9 +666,8 @@ public function sendJson(mixed $data): void
669666
/**
670667
* Sends response and terminates presenter.
671668
* @throws Nette\Application\AbortException
672-
* @return never
673669
*/
674-
public function sendResponse(Application\Response $response): void
670+
public function sendResponse(Application\Response $response): never
675671
{
676672
$this->response = $response;
677673
$this->terminate();
@@ -681,9 +677,8 @@ public function sendResponse(Application\Response $response): void
681677
/**
682678
* Correctly terminates presenter.
683679
* @throws Nette\Application\AbortException
684-
* @return never
685680
*/
686-
public function terminate(): void
681+
public function terminate(): never
687682
{
688683
throw new Application\AbortException;
689684
}
@@ -693,9 +688,8 @@ public function terminate(): void
693688
* Forward to another presenter or action.
694689
* @param array|mixed $args
695690
* @throws Nette\Application\AbortException
696-
* @return never
697691
*/
698-
public function forward(string|Nette\Application\Request $destination, $args = []): void
692+
public function forward(string|Nette\Application\Request $destination, $args = []): never
699693
{
700694
if ($destination instanceof Application\Request) {
701695
$this->sendResponse(new Responses\ForwardResponse($destination));
@@ -712,9 +706,8 @@ public function forward(string|Nette\Application\Request $destination, $args = [
712706
/**
713707
* Redirect to another URL and ends presenter execution.
714708
* @throws Nette\Application\AbortException
715-
* @return never
716709
*/
717-
public function redirectUrl(string $url, ?int $httpCode = null): void
710+
public function redirectUrl(string $url, ?int $httpCode = null): never
718711
{
719712
if ($this->isAjax()) {
720713
$this->getPayload()->redirect = $url;

src/Bridges/ApplicationLatte/TemplateFactory.php

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

3939

40-
/** @return Template */
41-
public function createTemplate(?UI\Control $control = null, ?string $class = null): UI\Template
40+
public function createTemplate(?UI\Control $control = null, ?string $class = null): Template
4241
{
4342
$class ??= $this->templateClass;
4443
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)