Skip to content

Commit 0f5f9c1

Browse files
committed
coding style
1 parent 575c10c commit 0f5f9c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+212
-251
lines changed

src/Application/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct(
7171
IPresenterFactory $presenterFactory,
7272
Router $router,
7373
Nette\Http\IRequest $httpRequest,
74-
Nette\Http\IResponse $httpResponse
74+
Nette\Http\IResponse $httpResponse,
7575
) {
7676
$this->httpRequest = $httpRequest;
7777
$this->httpResponse = $httpResponse;
@@ -128,7 +128,7 @@ public function createInitialRequest(): Request
128128
$params,
129129
$this->httpRequest->getPost(),
130130
$this->httpRequest->getFiles(),
131-
[Request::SECURED => $this->httpRequest->isSecured()]
131+
[Request::SECURED => $this->httpRequest->isSecured()],
132132
);
133133
}
134134

src/Application/LinkGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function withReferenceUrl(string $url): self
9898
return new self(
9999
$this->router,
100100
new UrlScript($url),
101-
$this->presenterFactory
101+
$this->presenterFactory,
102102
);
103103
}
104104
}

src/Application/MicroPresenter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class MicroPresenter implements Application\IPresenter
4040
public function __construct(
4141
Nette\DI\Container $context = null,
4242
Http\IRequest $httpRequest = null,
43-
Router $router = null
43+
Router $router = null,
4444
) {
4545
$this->context = $context;
4646
$this->httpRequest = $httpRequest;

src/Application/PresenterFactory.php

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

4343

src/Application/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function __construct(
6565
array $params = [],
6666
array $post = [],
6767
array $files = [],
68-
array $flags = []
68+
array $flags = [],
6969
) {
7070
$this->name = $name;
7171
$this->method = $method;

src/Application/Responses/FileResponse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(
3939
string $file,
4040
string $name = null,
4141
string $contentType = null,
42-
bool $forceDownload = true
42+
bool $forceDownload = true,
4343
) {
4444
if (!is_file($file) || !is_readable($file)) {
4545
throw new Nette\Application\BadRequestException("File '$file' doesn't exist or is not readable.");
@@ -89,7 +89,7 @@ public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $htt
8989
'Content-Disposition',
9090
($this->forceDownload ? 'attachment' : 'inline')
9191
. '; filename="' . $this->name . '"'
92-
. '; filename*=utf-8\'\'' . rawurlencode($this->name)
92+
. '; filename*=utf-8\'\'' . rawurlencode($this->name),
9393
);
9494

9595
$filesize = $length = filesize($this->file);
@@ -126,7 +126,7 @@ public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $htt
126126

127127
$httpResponse->setHeader('Content-Length', (string) $length);
128128
while (!feof($handle) && $length > 0) {
129-
echo $s = fread($handle, min(4000000, $length));
129+
echo $s = fread($handle, min(4_000_000, $length));
130130
$length -= strlen($s);
131131
}
132132
fclose($handle);

src/Application/UI/Component.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function createComponent(string $name): ?Nette\ComponentModel\ICompone
7777
{
7878
$res = parent::createComponent($name);
7979
if ($res && !$res instanceof SignalReceiver && !$res instanceof StatePersistent) {
80-
$type = get_class($res);
80+
$type = $res::class;
8181
trigger_error("It seems that component '$name' of type $type is not intended to be used in the Presenter.", E_USER_NOTICE);
8282
}
8383
return $res;
@@ -164,7 +164,7 @@ public function loadState(array $params): void
164164
$name,
165165
$this instanceof Presenter ? 'presenter ' . $this->getName() : "component '{$this->getUniqueId()}'",
166166
$meta['type'],
167-
is_object($params[$name]) ? get_class($params[$name]) : gettype($params[$name])
167+
is_object($params[$name]) ? get_class($params[$name]) : gettype($params[$name]),
168168
));
169169
}
170170
$this->$name = $params[$name];
@@ -324,7 +324,7 @@ public function redirectPermanent(string $destination, ...$args): void
324324
$presenter = $this->getPresenter();
325325
$presenter->redirectUrl(
326326
$presenter->createRequest($this, $destination, $args, 'redirect'),
327-
Nette\Http\IResponse::S301_MOVED_PERMANENTLY
327+
Nette\Http\IResponse::S301_MOVED_PERMANENTLY,
328328
);
329329
}
330330

src/Application/UI/ComponentReflection.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class ComponentReflection extends \ReflectionClass
3838
*/
3939
public function getPersistentParams(string $class = null): array
4040
{
41-
$class = $class ?? $this->getName();
41+
$class ??= $this->getName();
4242
$params = &self::$ppCache[$class];
4343
if ($params !== null) {
4444
return $params;
@@ -74,7 +74,7 @@ public function getPersistentParams(string $class = null): array
7474

7575
public function getPersistentComponents(string $class = null): array
7676
{
77-
$class = $class ?? $this->getName();
77+
$class ??= $this->getName();
7878
$components = &self::$pcCache[$class];
7979
if ($components !== null) {
8080
return $components;
@@ -98,7 +98,7 @@ public function getPersistentComponents(string $class = null): array
9898
*/
9999
public function saveState(Component $component, array &$params): void
100100
{
101-
$tree = self::getClassesAndTraits(get_class($component));
101+
$tree = self::getClassesAndTraits($component::class);
102102

103103
foreach ($this->getPersistentParams() as $name => $meta) {
104104
if (isset($params[$name])) {
@@ -121,7 +121,7 @@ public function saveState(Component $component, array &$params): void
121121
$name,
122122
$component instanceof Presenter ? 'presenter ' . $component->getName() : "component '{$component->getUniqueId()}'",
123123
$meta['type'],
124-
is_object($params[$name]) ? get_class($params[$name]) : gettype($params[$name])
124+
is_object($params[$name]) ? get_class($params[$name]) : gettype($params[$name]),
125125
));
126126
}
127127

@@ -166,7 +166,7 @@ public static function combineArgs(\ReflectionFunctionAbstract $method, array $a
166166
$name,
167167
($method instanceof \ReflectionMethod ? $method->getDeclaringClass()->getName() . '::' : '') . $method->getName(),
168168
$type,
169-
is_object($args[$name]) ? get_class($args[$name]) : gettype($args[$name])
169+
is_object($args[$name]) ? get_class($args[$name]) : gettype($args[$name]),
170170
));
171171
}
172172
} elseif ($param->isDefaultValueAvailable()) {
@@ -179,7 +179,7 @@ public static function combineArgs(\ReflectionFunctionAbstract $method, array $a
179179
throw new Nette\InvalidArgumentException(sprintf(
180180
'Missing parameter $%s required by %s()',
181181
$name,
182-
($method instanceof \ReflectionMethod ? $method->getDeclaringClass()->getName() . '::' : '') . $method->getName()
182+
($method instanceof \ReflectionMethod ? $method->getDeclaringClass()->getName() . '::' : '') . $method->getName(),
183183
));
184184
}
185185
}

src/Application/UI/Control.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected function checkTemplateClass(string $class): ?string
8282
'%s: class %s was found but does not implement the %s, so it will not be used for the template.',
8383
static::class,
8484
$class,
85-
Template::class
85+
Template::class,
8686
), E_USER_NOTICE);
8787
return null;
8888
} else {

src/Application/UI/Presenter.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ public function setLayout($layout)
450450
*/
451451
public function sendTemplate(Template $template = null): void
452452
{
453-
$template = $template ?? $this->getTemplate();
453+
$template ??= $this->getTemplate();
454454
if (!$template->getFile()) {
455455
$files = $this->formatTemplateFiles();
456456
foreach ($files as $file) {
@@ -722,7 +722,7 @@ public function canonicalize(string $destination = null, ...$args): void
722722
$this,
723723
$destination ?: $this->action,
724724
$args + $this->getGlobalState() + $request->getParameters(),
725-
'redirectX'
725+
'redirectX',
726726
);
727727
} catch (InvalidLinkException $e) {
728728
}
@@ -768,7 +768,7 @@ protected function createRequest(
768768
Component $component,
769769
string $destination,
770770
array $args,
771-
string $mode
771+
string $mode,
772772
): ?string {
773773
// note: createRequest supposes that saveState(), run() & tryCall() behaviour is final
774774

@@ -818,7 +818,7 @@ protected function createRequest(
818818

819819
// PROCESS SIGNAL ARGUMENTS
820820
if (isset($signal)) { // $component must be StatePersistent
821-
$reflection = new ComponentReflection(get_class($component));
821+
$reflection = new ComponentReflection($component::class);
822822
if ($signal === 'this') { // means "no signal"
823823
$signal = '';
824824
if (array_key_exists(0, $args)) {
@@ -835,10 +835,10 @@ protected function createRequest(
835835
$this->invalidLinkMode
836836
&& ComponentReflection::parseAnnotation(new \ReflectionMethod($component, $method), 'deprecated')
837837
) {
838-
trigger_error("Link to deprecated signal '$signal'" . ($component === $this ? '' : ' in ' . get_class($component)) . " from '{$this->getName()}:{$this->getAction()}'.", E_USER_DEPRECATED);
838+
trigger_error("Link to deprecated signal '$signal'" . ($component === $this ? '' : ' in ' . $component::class) . " from '{$this->getName()}:{$this->getAction()}'.", E_USER_DEPRECATED);
839839
}
840840
// convert indexed parameters to named
841-
static::argsToParams(get_class($component), $method, $args, [], $missing);
841+
static::argsToParams($component::class, $method, $args, [], $missing);
842842
}
843843

844844
// counterpart of StatePersistent
@@ -1010,7 +1010,7 @@ public static function argsToParams(
10101010
string $method,
10111011
array &$args,
10121012
array $supplemental = [],
1013-
array &$missing = null
1013+
array &$missing = null,
10141014
): void {
10151015
$i = 0;
10161016
$rm = new \ReflectionMethod($class, $method);
@@ -1050,7 +1050,7 @@ public static function argsToParams(
10501050
$name,
10511051
$rm->getDeclaringClass()->getName() . '::' . $rm->getName(),
10521052
$type,
1053-
is_object($args[$name]) ? get_class($args[$name]) : gettype($args[$name])
1053+
is_object($args[$name]) ? get_class($args[$name]) : gettype($args[$name]),
10541054
));
10551055
}
10561056

@@ -1357,7 +1357,7 @@ final public function injectPrimary(
13571357
Http\IResponse $httpResponse,
13581358
?Http\Session $session = null,
13591359
?Nette\Security\User $user = null,
1360-
?TemplateFactory $templateFactory = null
1360+
?TemplateFactory $templateFactory = null,
13611361
) {
13621362
if ($this->presenterFactory !== null) {
13631363
throw new Nette\InvalidStateException('Method ' . __METHOD__ . ' is intended for initialization and should not be called more than once.');

0 commit comments

Comments
 (0)