Skip to content

Commit 5d40430

Browse files
committed
cs whitespace
1 parent 05a22e5 commit 5d40430

32 files changed

+144
-5
lines changed

src/Application/Application.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function run(): void
102102
Arrays::invoke($this->onError, $this, $e);
103103
}
104104
}
105+
105106
Arrays::invoke($this->onShutdown, $this, $e);
106107
throw $e;
107108
}
@@ -157,6 +158,7 @@ public function processRequest(Request $request): void
157158
? $e
158159
: new BadRequestException($e->getMessage(), 0, $e);
159160
}
161+
160162
Arrays::invoke($this->onPresenter, $this, $this->presenter);
161163
$response = $this->presenter->run(clone $request);
162164

@@ -175,6 +177,7 @@ public function processException(\Throwable $e): void
175177
if (!$e instanceof BadRequestException && $this->httpResponse instanceof Nette\Http\Response) {
176178
$this->httpResponse->warnOnBuffer = false;
177179
}
180+
178181
if (!$this->httpResponse->isSent()) {
179182
$this->httpResponse->setCode($e instanceof BadRequestException ? ($e->getHttpCode() ?: 404) : 500);
180183
}

src/Application/ErrorPresenter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function run(Application\Request $request): Application\Response
4343
$this->logger->log($e, ILogger::EXCEPTION);
4444
}
4545
}
46+
4647
return new Application\Responses\CallbackResponse(function (Http\IRequest $httpRequest, Http\IResponse $httpResponse) use ($code): void {
4748
if (preg_match('#^text/html(?:;|$)#', (string) $httpResponse->getHeader('Content-Type'))) {
4849
require __DIR__ . '/templates/error.phtml';

src/Application/LinkGenerator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function link(string $dest, array $params = []): string
4949
if (!preg_match('~^([\w:]+):(\w*+)(#.*)?()$~D', $dest, $m)) {
5050
throw new UI\InvalidLinkException("Invalid link destination '$dest'.");
5151
}
52+
5253
[, $presenter, $action, $frag] = $m;
5354

5455
try {
@@ -63,6 +64,7 @@ public function link(string $dest, array $params = []): string
6364
if ($action === '') {
6465
$action = UI\Presenter::DEFAULT_ACTION;
6566
}
67+
6668
if (
6769
method_exists($class, $method = $class::formatActionMethod($action))
6870
|| method_exists($class, $method = $class::formatRenderMethod($action))
@@ -72,7 +74,6 @@ public function link(string $dest, array $params = []): string
7274
$rp = $missing[0];
7375
throw new UI\InvalidLinkException("Missing parameter \${$rp->getName()} required by {$rp->getDeclaringClass()->getName()}::{$rp->getDeclaringFunction()->getName()}()");
7476
}
75-
7677
} elseif (array_key_exists(0, $params)) {
7778
throw new UI\InvalidLinkException("Unable to pass parameters to action '$presenter:$action', missing corresponding method.");
7879
}
@@ -81,6 +82,7 @@ public function link(string $dest, array $params = []): string
8182
if ($action !== '') {
8283
$params[UI\Presenter::ACTION_KEY] = $action;
8384
}
85+
8486
$params[UI\Presenter::PRESENTER_KEY] = $presenter;
8587

8688
$url = $this->router->constructUrl($params, $this->refUrl);
@@ -89,6 +91,7 @@ public function link(string $dest, array $params = []): string
8991
$paramsDecoded = urldecode(http_build_query($params, '', ', '));
9092
throw new UI\InvalidLinkException("No route for $dest($paramsDecoded)");
9193
}
94+
9295
return $url . $frag;
9396
}
9497

src/Application/MicroPresenter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function run(Application\Request $request): Application\Response
7979
if (!is_object($callback) || !is_callable($callback)) {
8080
throw new Application\BadRequestException('Parameter callback is not a valid closure.');
8181
}
82+
8283
$reflection = Nette\Utils\Callback::toReflection($callback);
8384

8485
if ($this->context) {
@@ -88,6 +89,7 @@ public function run(Application\Request $request): Application\Response
8889
}
8990
}
9091
}
92+
9193
$params['presenter'] = $this;
9294
try {
9395
$params = Application\UI\ComponentReflection::combineArgs($reflection, $params);
@@ -100,14 +102,17 @@ public function run(Application\Request $request): Application\Response
100102
if (is_string($response)) {
101103
$response = [$response, []];
102104
}
105+
103106
if (is_array($response)) {
104107
[$templateSource, $templateParams] = $response;
105108
$response = $this->createTemplate()->setParameters($templateParams);
106109
if (!$templateSource instanceof \SplFileInfo) {
107110
$response->getLatte()->setLoader(new Latte\Loaders\StringLoader);
108111
}
112+
109113
$response->setFile((string) $templateSource);
110114
}
115+
111116
if ($response instanceof Application\UI\Template) {
112117
return new Responses\TextResponse($response);
113118
} else {
@@ -136,6 +141,7 @@ public function createTemplate(string $class = null, callable $latteFactory = nu
136141
$template->baseUrl = rtrim($url->getBaseUrl(), '/');
137142
$template->basePath = rtrim($url->getBasePath(), '/');
138143
}
144+
139145
return $template;
140146
}
141147

src/Application/PresenterFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,15 @@ public function setMapping(array $mapping)
9393
if (!preg_match('#^\\\\?([\w\\\\]*\\\\)?(\w*\*\w*?\\\\)?([\w\\\\]*\*\w*)$#D', $mask, $m)) {
9494
throw new Nette\InvalidStateException("Invalid mapping mask '$mask'.");
9595
}
96+
9697
$this->mapping[$module] = [$m[1], $m[2] ?: '*Module\\', $m[3]];
9798
} elseif (is_array($mask) && count($mask) === 3) {
9899
$this->mapping[$module] = [$mask[0] ? $mask[0] . '\\' : '', $mask[1] . '\\', $mask[2]];
99100
} else {
100101
throw new Nette\InvalidStateException("Invalid mapping mask for module $module.");
101102
}
102103
}
104+
103105
return $this;
104106
}
105107

@@ -118,6 +120,7 @@ public function formatPresenterClass(string $presenter): string
118120
while ($part = array_shift($parts)) {
119121
$mapping[0] .= str_replace('*', $part, $mapping[$parts ? 1 : 2]);
120122
}
123+
121124
return $mapping[0];
122125
}
123126

@@ -136,6 +139,7 @@ public function unformatPresenterClass(string $class): ?string
136139
. preg_replace("#$mapping[1]#iA", '$1:', $matches[1]) . $matches[3];
137140
}
138141
}
142+
139143
return null;
140144
}
141145
}

src/Application/Responses/FileResponse.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $htt
109109
} elseif ($end === '' || $end > $filesize - 1) {
110110
$end = $filesize - 1;
111111
}
112+
112113
if ($end < $start) {
113114
$httpResponse->setCode(416); // requested range not satisfiable
114115
return;
@@ -129,6 +130,7 @@ public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $htt
129130
echo $s = fread($handle, min(4000000, $length));
130131
$length -= strlen($s);
131132
}
133+
132134
fclose($handle);
133135
}
134136
}

src/Application/Routers/CliRouter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function match(Nette\Http\IRequest $httpRequest): ?array
5454
} else {
5555
$params[] = $arg;
5656
}
57+
5758
$flag = null;
5859
continue;
5960
}
@@ -78,11 +79,13 @@ public function match(Nette\Http\IRequest $httpRequest): ?array
7879
if (!isset($params[self::PRESENTER_KEY])) {
7980
throw new Nette\InvalidStateException('Missing presenter & action in route definition.');
8081
}
82+
8183
[$module, $presenter] = Nette\Application\Helpers::splitName($params[self::PRESENTER_KEY]);
8284
if ($module !== '') {
8385
$params[self::PRESENTER_KEY] = $presenter;
8486
$presenter = $module;
8587
}
88+
8689
$params['presenter'] = $presenter;
8790

8891
return $params;

src/Application/Routers/Route.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function __construct(string $mask, $metadata = [], int $flags = 0)
5555
if (!$presenter) {
5656
throw new Nette\InvalidArgumentException("Second argument must be array or string in format Presenter:action, '$metadata' given.");
5757
}
58+
5859
$metadata = [self::PRESENTER_KEY => $presenter];
5960
if ($action !== '') {
6061
$metadata['action'] = $action;
@@ -95,6 +96,7 @@ public function match(Nette\Http\IRequest $httpRequest): ?array
9596
if (isset($this->getMetadata()[self::MODULE_KEY], $params[self::MODULE_KEY]) && is_string($presenter)) {
9697
$params[self::PRESENTER_KEY] = $params[self::MODULE_KEY] . ':' . $params[self::PRESENTER_KEY];
9798
}
99+
98100
unset($params[self::MODULE_KEY]);
99101

100102
return $params;
@@ -139,6 +141,7 @@ public function getConstantParameters(): array
139141
} elseif (isset($this->getMetadata()[self::MODULE_KEY])) {
140142
unset($res[self::PRESENTER_KEY]);
141143
}
144+
142145
unset($res[self::MODULE_KEY]);
143146
return $res;
144147
}

src/Application/Routers/RouteList.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function match(Nette\Http\IRequest $httpRequest): ?array
4141
if (is_string($presenter) && strncmp($presenter, 'Nette:', 6)) {
4242
$params[self::PRESENTER_KEY] = $this->module . $presenter;
4343
}
44+
4445
return $params;
4546
}
4647

@@ -126,6 +127,7 @@ public function offsetGet($index)
126127
if (!$this->offsetExists($index)) {
127128
throw new Nette\OutOfRangeException('Offset invalid or out of range');
128129
}
130+
129131
return $this->getRouters()[$index];
130132
}
131133

@@ -148,6 +150,7 @@ public function offsetUnset($index): void
148150
if (!$this->offsetExists($index)) {
149151
throw new Nette\OutOfRangeException('Offset invalid or out of range');
150152
}
153+
151154
$this->modify($index, null);
152155
}
153156

src/Application/Routers/SimpleRouter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function __construct($defaults = [], int $flags = 0)
3333
if (!$presenter) {
3434
throw new Nette\InvalidArgumentException("Argument must be array or string in format Presenter:action, '$defaults' given.");
3535
}
36+
3637
$defaults = [
3738
self::PRESENTER_KEY => $presenter,
3839
'action' => $action === '' ? Application\UI\Presenter::DEFAULT_ACTION : $action,
@@ -58,6 +59,7 @@ public function constructUrl(array $params, Nette\Http\UrlScript $refUrl): ?stri
5859
if ($this->flags & self::ONE_WAY) {
5960
return null;
6061
}
62+
6163
return parent::constructUrl($params, $refUrl);
6264
}
6365

0 commit comments

Comments
 (0)