Skip to content

Commit 6eea5a9

Browse files
committed
strict type fixes
1 parent a989377 commit 6eea5a9

File tree

12 files changed

+18
-18
lines changed

12 files changed

+18
-18
lines changed

src/Application/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function processRequest(Request $request)
127127
$this->requests[] = $request;
128128
$this->onRequest($this, $request);
129129

130-
if (!$request->isMethod($request::FORWARD) && !strcasecmp($request->getPresenterName(), $this->errorPresenter)) {
130+
if (!$request->isMethod($request::FORWARD) && !strcasecmp($request->getPresenterName(), (string) $this->errorPresenter)) {
131131
throw new BadRequestException('Invalid request. Presenter is not achievable.');
132132
}
133133

src/Application/LinkGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function link($dest, array $params = [])
7979
$url = $this->router->constructUrl(new Request($presenter, NULL, $params), $this->refUrl);
8080
if ($url === NULL) {
8181
unset($params[UI\Presenter::ACTION_KEY]);
82-
$params = urldecode(http_build_query($params, NULL, ', '));
82+
$params = urldecode(http_build_query($params, '', ', '));
8383
throw new UI\InvalidLinkException("No route for $dest($params)");
8484
}
8585
return $url . $frag;

src/Application/MicroPresenter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function run(Application\Request $request)
9595
if (!$templateSource instanceof \SplFileInfo) {
9696
$response->getLatte()->setLoader(new Latte\Loaders\StringLoader);
9797
}
98-
$response->setFile($templateSource);
98+
$response->setFile((string) $templateSource);
9999
}
100100
if ($response instanceof Application\UI\ITemplate) {
101101
return new Responses\TextResponse($response);

src/Application/Responses/FileResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $htt
9898

9999
if ($this->resuming) {
100100
$httpResponse->setHeader('Accept-Ranges', 'bytes');
101-
if (preg_match('#^bytes=(\d*)-(\d*)\z#', $httpRequest->getHeader('Range'), $matches)) {
101+
if (preg_match('#^bytes=(\d*)-(\d*)\z#', (string) $httpRequest->getHeader('Range'), $matches)) {
102102
list(, $start, $end) = $matches;
103103
if ($start === '') {
104104
$start = max(0, $filesize - $end);
@@ -115,7 +115,7 @@ public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $htt
115115
$httpResponse->setCode(206);
116116
$httpResponse->setHeader('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $filesize);
117117
$length = $end - $start + 1;
118-
fseek($handle, $start);
118+
fseek($handle, (int) $start);
119119

120120
} else {
121121
$httpResponse->setHeader('Content-Range', 'bytes 0-' . ($filesize - 1) . '/' . $filesize);

src/Application/Routers/Route.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
288288

289289
if (isset($metadata[self::MODULE_KEY])) { // try split into module and [submodule:]presenter parts
290290
$module = $metadata[self::MODULE_KEY];
291-
if (isset($module['fixity']) && strncmp($presenter, $module[self::VALUE] . ':', strlen($module[self::VALUE]) + 1) === 0) {
291+
if (isset($module['fixity'], $module[self::VALUE]) && strncmp($presenter, $module[self::VALUE] . ':', strlen($module[self::VALUE]) + 1) === 0) {
292292
$a = strlen($module[self::VALUE]);
293293
} else {
294294
$a = strrpos($presenter, ':');
@@ -339,7 +339,7 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
339339
$params[$name] = $meta[self::FILTER_OUT]($params[$name]);
340340
}
341341

342-
if (isset($meta[self::PATTERN]) && !preg_match($meta[self::PATTERN], rawurldecode($params[$name]))) {
342+
if (isset($meta[self::PATTERN]) && !preg_match($meta[self::PATTERN], rawurldecode((string) $params[$name]))) {
343343
return NULL; // pattern not match
344344
}
345345
}
@@ -576,7 +576,7 @@ private function setMask($mask, array $metadata)
576576
}
577577

578578
$meta['filterTable2'] = empty($meta[self::FILTER_TABLE]) ? NULL : array_flip($meta[self::FILTER_TABLE]);
579-
if (array_key_exists(self::VALUE, $meta)) {
579+
if (isset($meta[self::VALUE])) {
580580
if (isset($meta['filterTable2'][$meta[self::VALUE]])) {
581581
$meta['defOut'] = $meta['filterTable2'][$meta[self::VALUE]];
582582

src/Application/UI/Component.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function validateParent(Nette\ComponentModel\IContainer $parent)
8585
protected function tryCall($method, array $params)
8686
{
8787
$rc = $this->getReflection();
88-
if ($rc->hasMethod($method)) {
88+
if ($rc->hasMethod((string) $method)) {
8989
$rm = $rc->getMethod($method);
9090
if ($rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic()) {
9191
$this->checkRequirements($rm);

src/Application/UI/ComponentReflection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public static function convertType(&$val, $type, $isClass = FALSE)
196196
*/
197197
public static function parseAnnotation(\Reflector $ref, $name)
198198
{
199-
if (!preg_match_all('#[\\s*]@' . preg_quote($name, '#') . '(?:\(\\s*([^)]*)\\s*\)|\\s|$)#', $ref->getDocComment(), $m)) {
199+
if (!preg_match_all('#[\\s*]@' . preg_quote($name, '#') . '(?:\(\\s*([^)]*)\\s*\)|\\s|$)#', (string) $ref->getDocComment(), $m)) {
200200
return FALSE;
201201
}
202202
static $tokens = ['true' => TRUE, 'false' => FALSE, 'null' => NULL];

src/Application/UI/Presenter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public function findLayoutTemplateFile()
498498
*/
499499
public function formatLayoutTemplateFiles()
500500
{
501-
if (preg_match('#/|\\\\#', $this->layout)) {
501+
if (preg_match('#/|\\\\#', (string) $this->layout)) {
502502
return [$this->layout];
503503
}
504504
list($module, $presenter) = Helpers::splitName($this->getName());
@@ -891,7 +891,7 @@ protected function createRequest($component, $destination, array $args, $mode)
891891
$action = self::DEFAULT_ACTION;
892892
}
893893

894-
$current = ($action === '*' || strcasecmp($action, $this->action) === 0) && $presenterClass === get_class($this);
894+
$current = ($action === '*' || strcasecmp($action, (string) $this->action) === 0) && $presenterClass === get_class($this);
895895

896896
$reflection = new ComponentReflection($presenterClass);
897897

@@ -979,7 +979,7 @@ protected function createRequest($component, $destination, array $args, $mode)
979979
$url = $this->router->constructUrl($this->lastCreatedRequest, $this->refUrlCache);
980980
if ($url === NULL) {
981981
unset($args[self::ACTION_KEY]);
982-
$params = urldecode(http_build_query($args, NULL, ', '));
982+
$params = urldecode(http_build_query($args, '', ', '));
983983
throw new InvalidLinkException("No route for $presenter:$action($params)");
984984
}
985985

@@ -1231,7 +1231,7 @@ private function initGlobalParameters()
12311231
}
12321232

12331233
foreach ($params as $key => $value) {
1234-
if (!preg_match('#^((?:[a-z0-9_]+-)*)((?!\d+\z)[a-z0-9_]+)\z#i', $key, $matches)) {
1234+
if (!preg_match('#^((?:[a-z0-9_]+-)*)((?!\d+\z)[a-z0-9_]+)\z#i', (string) $key, $matches)) {
12351235
continue;
12361236
} elseif (!$matches[1]) {
12371237
$selfParams[$key] = $value;

src/Bridges/ApplicationDI/ApplicationExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function beforeCompile()
104104
$counter = 0;
105105
foreach ($this->findPresenters() as $class) {
106106
if (empty($all[$class])) {
107-
$all[$class] = $builder->addDefinition($this->prefix(++$counter))->setClass($class);
107+
$all[$class] = $builder->addDefinition($this->prefix((string) ++$counter))->setClass($class);
108108
}
109109
}
110110

src/Bridges/ApplicationLatte/TemplateFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function createTemplate(UI\Control $control = NULL)
103103
$latte->addProvider('uiControl', $control);
104104
$latte->addProvider('uiPresenter', $presenter);
105105
$latte->addProvider('snippetBridge', new Nette\Bridges\ApplicationLatte\SnippetBridge($control));
106-
$nonce = preg_match('#\s\'nonce-([\w+/]+=*)\'#', $presenter->getHttpResponse()->getHeader('Content-Security-Policy'), $m) ? $m[1] : NULL;
106+
$nonce = preg_match('#\s\'nonce-([\w+/]+=*)\'#', (string) $presenter->getHttpResponse()->getHeader('Content-Security-Policy'), $m) ? $m[1] : NULL;
107107
$latte->addProvider('uiNonce', $nonce);
108108
}
109109
$latte->addProvider('cacheStorage', $this->cacheStorage);

0 commit comments

Comments
 (0)