Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for properties in NEON statement syntax in section services - PART 3 #339

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added type hints (BC break)
dg committed Sep 10, 2024
commit e139babb33e50ec6e48577f558551fb2f66dc42a
6 changes: 2 additions & 4 deletions src/Application/UI/Component.php
Original file line number Diff line number Diff line change
@@ -335,10 +335,9 @@ public function isLinkCurrent(?string $destination = null, $args = []): bool
* Redirect to another presenter, action or signal.
* @param string $destination in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"
* @param array|mixed $args
* @return never
* @throws Nette\Application\AbortException
*/
public function redirect(string $destination, $args = []): void
public function redirect(string $destination, $args = []): never
{
$args = func_num_args() < 3 && is_array($args)
? $args
@@ -353,10 +352,9 @@ public function redirect(string $destination, $args = []): void
* Permanently redirects to presenter, action or signal.
* @param string $destination in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"
* @param array|mixed $args
* @return never
* @throws Nette\Application\AbortException
*/
public function redirectPermanent(string $destination, $args = []): void
public function redirectPermanent(string $destination, $args = []): never
{
$args = func_num_args() < 3 && is_array($args)
? $args
21 changes: 7 additions & 14 deletions src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
@@ -470,9 +470,8 @@ public function setLayout(string|bool $layout): static

/**
* @throws Nette\Application\AbortException
* @return never
*/
public function sendTemplate(?Template $template = null): void
public function sendTemplate(?Template $template = null): never
{
$template ??= $this->getTemplate();
if (!$template->getFile()) {
@@ -644,9 +643,8 @@ public function isAjax(): bool
/**
* Sends AJAX payload to the output.
* @throws Nette\Application\AbortException
* @return never
*/
public function sendPayload(): void
public function sendPayload(): never
{
$this->sendResponse(new Responses\JsonResponse($this->getPayload()));
}
@@ -655,9 +653,8 @@ public function sendPayload(): void
/**
* Sends JSON data to the output.
* @throws Nette\Application\AbortException
* @return never
*/
public function sendJson(mixed $data): void
public function sendJson(mixed $data): never
{
$this->sendResponse(new Responses\JsonResponse($data));
}
@@ -669,9 +666,8 @@ public function sendJson(mixed $data): void
/**
* Sends response and terminates presenter.
* @throws Nette\Application\AbortException
* @return never
*/
public function sendResponse(Application\Response $response): void
public function sendResponse(Application\Response $response): never
{
$this->response = $response;
$this->terminate();
@@ -681,9 +677,8 @@ public function sendResponse(Application\Response $response): void
/**
* Correctly terminates presenter.
* @throws Nette\Application\AbortException
* @return never
*/
public function terminate(): void
public function terminate(): never
{
throw new Application\AbortException;
}
@@ -693,9 +688,8 @@ public function terminate(): void
* Forward to another presenter or action.
* @param array|mixed $args
* @throws Nette\Application\AbortException
* @return never
*/
public function forward(string|Nette\Application\Request $destination, $args = []): void
public function forward(string|Nette\Application\Request $destination, $args = []): never
{
if ($destination instanceof Application\Request) {
$this->sendResponse(new Responses\ForwardResponse($destination));
@@ -712,9 +706,8 @@ public function forward(string|Nette\Application\Request $destination, $args = [
/**
* Redirect to another URL and ends presenter execution.
* @throws Nette\Application\AbortException
* @return never
*/
public function redirectUrl(string $url, ?int $httpCode = null): void
public function redirectUrl(string $url, ?int $httpCode = null): never
{
if ($this->isAjax()) {
$this->getPayload()->redirect = $url;
3 changes: 1 addition & 2 deletions src/Bridges/ApplicationLatte/TemplateFactory.php
Original file line number Diff line number Diff line change
@@ -37,8 +37,7 @@ public function __construct(
}


/** @return Template */
public function createTemplate(?UI\Control $control = null, ?string $class = null): UI\Template
public function createTemplate(?UI\Control $control = null, ?string $class = null): Template
{
$class ??= $this->templateClass;
if (!is_a($class, Template::class, allow_string: true)) {
2 changes: 1 addition & 1 deletion tests/UI/Component.redirect().phpt
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ class TestPresenter extends Application\UI\Presenter
}


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