Skip to content

Commit 1918565

Browse files
committed
strict type fixes
1 parent 54887ce commit 1918565

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/Bridges/FormsLatte/Runtime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function renderFormEnd(Form $form, $withTags = TRUE)
4949
{
5050
$s = '';
5151
if ($form->isMethod('get')) {
52-
foreach (preg_split('#[;&]#', parse_url($form->getElementPrototype()->action, PHP_URL_QUERY), NULL, PREG_SPLIT_NO_EMPTY) as $param) {
52+
foreach (preg_split('#[;&]#', (string) parse_url($form->getElementPrototype()->action, PHP_URL_QUERY), -1, PREG_SPLIT_NO_EMPTY) as $param) {
5353
$parts = explode('=', $param, 2);
5454
$name = urldecode($parts[0]);
5555
if (!isset($form[$name])) {

src/Forms/Controls/CsrfProtection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function getControl()
105105
*/
106106
public static function validateCsrf(CsrfProtection $control)
107107
{
108-
$value = $control->getValue();
108+
$value = (string) $control->getValue();
109109
return $control->generateToken(substr($value, 0, 10)) === $value;
110110
}
111111

src/Forms/Helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private static function sanitize($type, $value)
6565
return is_scalar($value) ? Strings::normalizeNewLines($value) : NULL;
6666

6767
} elseif ($type === Form::DATA_LINE) {
68-
return is_scalar($value) ? Strings::trim(strtr($value, "\r\n", ' ')) : NULL;
68+
return is_scalar($value) ? Strings::trim(strtr((string) $value, "\r\n", ' ')) : NULL;
6969

7070
} elseif ($type === Form::DATA_FILE) {
7171
return $value instanceof Nette\Http\FileUpload ? $value : NULL;
@@ -198,7 +198,7 @@ public static function createSelectBox(array $items, array $optionAttrs = NULL,
198198
$res .= $caption->setName('option')->addAttributes($option->attrs);
199199
} else {
200200
$res .= $optionTag . $option->attributes() . '>'
201-
. htmlspecialchars($caption, ENT_NOQUOTES, 'UTF-8')
201+
. htmlspecialchars((string) $caption, ENT_NOQUOTES, 'UTF-8')
202202
. '</option>';
203203
}
204204
}

src/Forms/Rendering/DefaultFormRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function renderBegin()
171171
$query = parse_url($el->action, PHP_URL_QUERY);
172172
$el->action = str_replace("?$query", '', $el->action);
173173
$s = '';
174-
foreach (preg_split('#[;&]#', $query, NULL, PREG_SPLIT_NO_EMPTY) as $param) {
174+
foreach (preg_split('#[;&]#', $query, -1, PREG_SPLIT_NO_EMPTY) as $param) {
175175
$parts = explode('=', $param, 2);
176176
$name = urldecode($parts[0]);
177177
if (!isset($this->form[$name])) {

src/Forms/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public static function validateLength(IControl $control, $range)
181181
$range = [$range, $range];
182182
}
183183
$value = $control->getValue();
184-
return Validators::isInRange(is_array($value) ? count($value) : Strings::length($value), $range);
184+
return Validators::isInRange(is_array($value) ? count($value) : Strings::length((string) $value), $range);
185185
}
186186

187187

0 commit comments

Comments
 (0)