Skip to content

Commit

Permalink
cs nullable typehints
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 12, 2021
1 parent 5d40430 commit dc3f912
Show file tree
Hide file tree
Showing 26 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/Application/ErrorPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class ErrorPresenter implements Application\IPresenter
private $logger;


public function __construct(ILogger $logger = null)
public function __construct(?ILogger $logger = null)
{
$this->logger = $logger;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Application/LinkGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class LinkGenerator
private $presenterFactory;


public function __construct(Router $router, UrlScript $refUrl, IPresenterFactory $presenterFactory = null)
public function __construct(Router $router, UrlScript $refUrl, ?IPresenterFactory $presenterFactory = null)
{
$this->router = $router;
$this->refUrl = $refUrl;
Expand Down
8 changes: 4 additions & 4 deletions src/Application/MicroPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ final class MicroPresenter implements Application\IPresenter


public function __construct(
Nette\DI\Container $context = null,
Http\IRequest $httpRequest = null,
Router $router = null
?Nette\DI\Container $context = null,
?Http\IRequest $httpRequest = null,
?Router $router = null
) {
$this->context = $context;
$this->httpRequest = $httpRequest;
Expand Down Expand Up @@ -124,7 +124,7 @@ public function run(Application\Request $request): Application\Response
/**
* Template factory.
*/
public function createTemplate(string $class = null, callable $latteFactory = null): Application\UI\Template
public function createTemplate(?string $class = null, ?callable $latteFactory = null): Application\UI\Template
{
$latte = $latteFactory
? $latteFactory()
Expand Down
2 changes: 1 addition & 1 deletion src/Application/PresenterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PresenterFactory implements IPresenterFactory
/**
* @param callable(string): IPresenter $factory
*/
public function __construct(callable $factory = null)
public function __construct(?callable $factory = null)
{
$this->factory = $factory ?: function (string $class): IPresenter { return new $class; };
}
Expand Down
4 changes: 2 additions & 2 deletions src/Application/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class Request
*/
public function __construct(
string $name,
string $method = null,
?string $method = null,
array $params = [],
array $post = [],
array $files = [],
Expand Down Expand Up @@ -142,7 +142,7 @@ public function setPost(array $params)
* If no key is passed, returns the entire array.
* @return mixed
*/
public function getPost(string $key = null)
public function getPost(?string $key = null)
{
return func_num_args() === 0
? $this->post
Expand Down
4 changes: 2 additions & 2 deletions src/Application/Responses/FileResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ final class FileResponse implements Nette\Application\Response

public function __construct(
string $file,
string $name = null,
string $contentType = null,
?string $name = null,
?string $contentType = null,
bool $forceDownload = true
) {
if (!is_file($file) || !is_readable($file)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Responses/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class JsonResponse implements Nette\Application\Response
private $contentType;


public function __construct($payload, string $contentType = null)
public function __construct($payload, ?string $contentType = null)
{
$this->payload = $payload;
$this->contentType = $contentType ?: 'application/json';
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Routers/RouteList.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RouteList extends Nette\Routing\RouteList implements Nette\Routing\Router,
private $module;


public function __construct(string $module = null)
public function __construct(?string $module = null)
{
parent::__construct();
$this->module = $module ? $module . ':' : null;
Expand Down
2 changes: 1 addition & 1 deletion src/Application/UI/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function lazyLink(string $destination, $args = []): Link
* @param array|mixed $args
* @throws InvalidLinkException
*/
public function isLinkCurrent(string $destination = null, $args = []): bool
public function isLinkCurrent(?string $destination = null, $args = []): bool
{
if ($destination !== null) {
$args = func_num_args() < 3 && is_array($args)
Expand Down
4 changes: 2 additions & 2 deletions src/Application/UI/ComponentReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class ComponentReflection extends \ReflectionClass
* Returns array of classes persistent parameters. They have public visibility,
* are non-static and have annotation @persistent.
*/
public function getPersistentParams(string $class = null): array
public function getPersistentParams(?string $class = null): array
{
$class = $class ?? $this->getName();
$params = &self::$ppCache[$class];
Expand Down Expand Up @@ -75,7 +75,7 @@ public function getPersistentParams(string $class = null): array
}


public function getPersistentComponents(string $class = null): array
public function getPersistentComponents(?string $class = null): array
{
$class = $class ?? $this->getName();
$components = &self::$pcCache[$class];
Expand Down
4 changes: 2 additions & 2 deletions src/Application/UI/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function flashMessage($message, string $type = 'info'): \stdClass
/**
* Forces control or its snippet to repaint.
*/
public function redrawControl(string $snippet = null, bool $redraw = true): void
public function redrawControl(?string $snippet = null, bool $redraw = true): void
{
if ($redraw) {
$this->invalidSnippets[$snippet ?? "\0"] = true;
Expand All @@ -140,7 +140,7 @@ public function redrawControl(string $snippet = null, bool $redraw = true): void
/**
* Is required to repaint the control or its snippet?
*/
public function isControlInvalid(string $snippet = null): bool
public function isControlInvalid(?string $snippet = null): bool
{
if ($snippet !== null) {
return $this->invalidSnippets[$snippet] ?? isset($this->invalidSnippets["\0"]);
Expand Down
2 changes: 1 addition & 1 deletion src/Application/UI/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Form extends Nette\Forms\Form implements SignalReceiver
/**
* Application form constructor.
*/
public function __construct(Nette\ComponentModel\IContainer $parent = null, string $name = null)
public function __construct(?Nette\ComponentModel\IContainer $parent = null, ?string $name = null)
{
parent::__construct();
if ($parent !== null) {
Expand Down
18 changes: 9 additions & 9 deletions src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public function setLayout($layout)
* @throws Nette\Application\AbortException
* @return never
*/
public function sendTemplate(Template $template = null): void
public function sendTemplate(?Template $template = null): void
{
$template = $template ?? $this->getTemplate();
if (!$template->getFile()) {
Expand Down Expand Up @@ -675,7 +675,7 @@ public function forward($destination, $args = []): void
* @throws Nette\Application\AbortException
* @return never
*/
public function redirectUrl(string $url, int $httpCode = null): void
public function redirectUrl(string $url, ?int $httpCode = null): void
{
if ($this->isAjax()) {
$this->payload->redirect = $url;
Expand Down Expand Up @@ -716,7 +716,7 @@ final public function getLastCreatedRequestFlag(string $flag): bool
* @param mixed ...$args
* @throws Nette\Application\AbortException
*/
public function canonicalize(string $destination = null, ...$args): void
public function canonicalize(?string $destination = null, ...$args): void
{
$request = $this->request;
if ($this->isAjax() || (!$request->isMethod('get') && !$request->isMethod('head'))) {
Expand Down Expand Up @@ -754,7 +754,7 @@ public function canonicalize(string $destination = null, ...$args): void
* @param string $expire like '20 minutes'
* @throws Nette\Application\AbortException
*/
public function lastModified($lastModified, string $etag = null, string $expire = null): void
public function lastModified($lastModified, ?string $etag = null, ?string $expire = null): void
{
if ($expire !== null) {
$this->httpResponse->setExpiration($expire);
Expand Down Expand Up @@ -992,7 +992,7 @@ public static function parseDestination(string $destination): array
* Converts Request to URL.
* @internal
*/
protected function requestToUrl(Application\Request $request, bool $relative = null): string
protected function requestToUrl(Application\Request $request, ?bool $relative = null): string
{
if ($this->refUrlCache === null) {
$url = $this->httpRequest->getUrl();
Expand Down Expand Up @@ -1033,7 +1033,7 @@ public static function argsToParams(
string $method,
array &$args,
array $supplemental = [],
array &$missing = null
?array &$missing = null
): void {
$i = 0;
$rm = new \ReflectionMethod($class, $method);
Expand Down Expand Up @@ -1176,7 +1176,7 @@ public static function getPersistentComponents(): array
/**
* Saves state information for all subcomponents to $this->globalState.
*/
protected function getGlobalState(string $forClass = null): array
protected function getGlobalState(?string $forClass = null): array
{
$sinces = &$this->globalStateSinces;

Expand Down Expand Up @@ -1251,7 +1251,7 @@ protected function getGlobalState(string $forClass = null): array
/**
* Saves state informations for next request.
*/
public function saveState(array &$params, ComponentReflection $reflection = null): void
public function saveState(array &$params, ?ComponentReflection $reflection = null): void
{
($reflection ?: static::getReflection())->saveState($this, $params);
}
Expand Down Expand Up @@ -1438,7 +1438,7 @@ final public function getHttpResponse(): Http\IResponse
/**
* @return Http\Session|Http\SessionSection
*/
final public function getSession(string $namespace = null)
final public function getSession(?string $namespace = null)
{
if (!$this->session) {
throw new Nette\InvalidStateException('Service Session has not been set.');
Expand Down
2 changes: 1 addition & 1 deletion src/Application/UI/TemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
interface TemplateFactory
{
function createTemplate(Control $control = null): Template;
function createTemplate(?Control $control = null): Template;
}


Expand Down
2 changes: 1 addition & 1 deletion src/Application/exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BadRequestException extends \Exception
protected $code = Http\IResponse::S404_NOT_FOUND;


public function __construct(string $message = '', int $httpCode = 0, \Throwable $previous = null)
public function __construct(string $message = '', int $httpCode = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $httpCode ?: $this->code, $previous);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Bridges/ApplicationDI/ApplicationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ final class ApplicationExtension extends Nette\DI\CompilerExtension

public function __construct(
bool $debugMode = false,
array $scanDirs = null,
string $tempDir = null,
Nette\Loaders\RobotLoader $robotLoader = null
?array $scanDirs = null,
?string $tempDir = null,
?Nette\Loaders\RobotLoader $robotLoader = null
) {
$this->debugMode = $debugMode;
$this->scanDirs = (array) $scanDirs;
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/ApplicationLatte/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final public function getLatte(): Latte\Engine
/**
* Renders template to output.
*/
public function render(string $file = null, array $params = []): void
public function render(?string $file = null, array $params = []): void
{
Nette\Utils\Arrays::toObject($params, $this);
$this->latte->render($file ?: $this->file, $this);
Expand All @@ -50,7 +50,7 @@ public function render(string $file = null, array $params = []): void
/**
* Renders template to output.
*/
public function renderToString(string $file = null, array $params = []): string
public function renderToString(?string $file = null, array $params = []): string
{
Nette\Utils\Arrays::toObject($params, $this);
return $this->latte->renderToString($file ?: $this->file, $this);
Expand Down
8 changes: 4 additions & 4 deletions src/Bridges/ApplicationLatte/TemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class TemplateFactory implements UI\TemplateFactory

public function __construct(
LatteFactory $latteFactory,
Nette\Http\IRequest $httpRequest = null,
Nette\Security\User $user = null,
Nette\Caching\Storage $cacheStorage = null,
?Nette\Http\IRequest $httpRequest = null,
?Nette\Security\User $user = null,
?Nette\Caching\Storage $cacheStorage = null,
$templateClass = null
) {
$this->latteFactory = $latteFactory;
Expand All @@ -60,7 +60,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): UI\Template
{
$class = $class ?? $this->templateClass;
if (!is_a($class, Template::class, true)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/ApplicationLatte/UIRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function initialize(Latte\Runtime\Template $template, &$parentName
}


public static function printClass(Latte\Runtime\Template $template, string $parent = null): void
public static function printClass(Latte\Runtime\Template $template, ?string $parent = null): void
{
$blueprint = new Latte\Runtime\Blueprint;
$name = 'Template';
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/ApplicationTracy/RoutingPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function analyse(
Routing\Router $router,
Nette\Http\IRequest $httpRequest,
string $module = '',
string $path = null,
?string $path = null,
bool $parentMatches = true,
int $level = -1,
int $flag = 0
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/Presenter.twoDomains.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require __DIR__ . '/../bootstrap.php';

class TestPresenter extends Application\UI\Presenter
{
protected function createTemplate(string $class = null): Application\UI\Template
protected function createTemplate(?string $class = null): Application\UI\Template
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Bridges.Latte/TemplateFactory.customTemplate.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TemplateMock extends Template
private $file = 'ko';


public function render(string $file = null, array $params = []): void
public function render(?string $file = null, array $params = []): void
{
echo strrev($this->file);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Routers/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Tester\Assert;


function testRouteIn(Nette\Routing\Router $route, string $url, array $expectedParams = null, string $expectedUrl = null): void
function testRouteIn(Nette\Routing\Router $route, string $url, ?array $expectedParams = null, ?string $expectedUrl = null): void
{
$urlBuilder = new Nette\Http\Url("http://example.com$url");
$urlBuilder->appendQuery([
Expand Down
12 changes: 6 additions & 6 deletions tests/UI/ComponentReflection.combineArgs.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class MyPresenter


public function hintsNulls(
int $int = null,
bool $bool = null,
string $str = null,
array $arr = null,
iterable $iter = null
?int $int = null,
?bool $bool = null,
?string $str = null,
?array $arr = null,
?iterable $iter = null
) {
}

Expand All @@ -54,7 +54,7 @@ class MyPresenter
}


public function objects(stdClass $req, ?stdClass $nullable, stdClass $opt = null)
public function objects(stdClass $req, ?stdClass $nullable, ?stdClass $opt = null)
{
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/UI/Presenter.link().php74.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class TestPresenter extends Application\UI\Presenter
}


public function actionHintsNulls(int $int = null, bool $bool = null, string $str = null, array $arr = null)
public function actionHintsNulls(?int $int = null, ?bool $bool = null, ?string $str = null, ?array $arr = null)
{
}

Expand All @@ -273,7 +273,7 @@ class TestPresenter extends Application\UI\Presenter
}


public function actionObjects(stdClass $req, ?stdClass $nullable, stdClass $opt = null)
public function actionObjects(stdClass $req, ?stdClass $nullable, ?stdClass $opt = null)
{
}

Expand Down
Loading

0 comments on commit dc3f912

Please sign in to comment.