Skip to content

Commit aa6d8e8

Browse files
committed
stricter null checking
1 parent aafcc5f commit aa6d8e8

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

src/Application/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function createErrorRequest(\Throwable $e): ?Request
170170
return null;
171171
}
172172

173-
$args = ['exception' => $e, 'previousPresenter' => $this->presenter, 'request' => Arrays::last($this->requests) ?: null];
173+
$args = ['exception' => $e, 'previousPresenter' => $this->presenter, 'request' => Arrays::last($this->requests) ?? null];
174174
if ($this->presenter instanceof UI\Presenter) {
175175
try {
176176
$this->presenter->forward(":$errorPresenter:", $args);

src/Application/PresenterFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PresenterFactory implements IPresenterFactory
3636
*/
3737
public function __construct(?callable $factory = null)
3838
{
39-
$this->factory = $factory ?: fn(string $class): IPresenter => new $class;
39+
$this->factory = $factory ?? fn(string $class): IPresenter => new $class;
4040
}
4141

4242

src/Application/Responses/FileResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(
3737

3838
$this->file = $file;
3939
$this->name = $name ?? basename($file);
40-
$this->contentType = $contentType ?: 'application/octet-stream';
40+
$this->contentType = $contentType ?? 'application/octet-stream';
4141
$this->forceDownload = $forceDownload;
4242
}
4343

src/Application/Responses/JsonResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class JsonResponse implements Nette\Application\Response
2424
public function __construct(mixed $payload, ?string $contentType = null)
2525
{
2626
$this->payload = $payload;
27-
$this->contentType = $contentType ?: 'application/json';
27+
$this->contentType = $contentType ?? 'application/json';
2828
}
2929

3030

src/Application/UI/Presenter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ public function sendTemplate(?Template $template = null): void
480480
foreach ($this->getReflection()->getTemplateVariables($this) as $name) {
481481
$template->$name ??= $this->$name;
482482
}
483-
if (!$template->getFile()) {
483+
if ($template->getFile() === null) {
484484
$template->setFile($this->findTemplateFile());
485485
}
486486
$this->sendResponse(new Responses\TextResponse($template));

src/Bridges/ApplicationLatte/Template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final public function getLatte(): Latte\Engine
4040
public function render(?string $file = null, array $params = []): void
4141
{
4242
Nette\Utils\Arrays::toObject($params, $this);
43-
$this->latte->render($file ?: $this->file, $this);
43+
$this->latte->render($file ?? $this->file, $this);
4444
}
4545

4646

@@ -50,7 +50,7 @@ public function render(?string $file = null, array $params = []): void
5050
public function renderToString(?string $file = null, array $params = []): string
5151
{
5252
Nette\Utils\Arrays::toObject($params, $this);
53-
return $this->latte->renderToString($file ?: $this->file, $this);
53+
return $this->latte->renderToString($file ?? $this->file, $this);
5454
}
5555

5656

src/Bridges/ApplicationLatte/TemplateFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(
3636
throw new Nette\InvalidArgumentException("Class $templateClass does not implement " . Template::class . ' or it does not exist.');
3737
}
3838

39-
$this->templateClass = $templateClass ?: DefaultTemplate::class;
39+
$this->templateClass = $templateClass ?? DefaultTemplate::class;
4040
}
4141

4242

0 commit comments

Comments
 (0)