Skip to content

Commit fabf371

Browse files
committed
PHP 7.4 compatibility fixes
1 parent 7d35d44 commit fabf371

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/Forms/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function validate(array $controls = null): void
170170
}
171171
foreach ($this->onValidate as $handler) {
172172
$params = Nette\Utils\Callback::toReflection($handler)->getParameters();
173-
$values = isset($params[1]) ? $this->getValues((string) $params[1]->getType()) : null;
173+
$values = isset($params[1]) ? $this->getValues($params[1]->getType() ? $params[1]->getType()->getName() : null) : null;
174174
$handler($this, $values);
175175
}
176176
}

src/Forms/Controls/UploadControl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ public function isOk(): bool
104104
public function addRule($validator, $errorMessage = null, $arg = null)
105105
{
106106
if ($validator === Forms\Form::IMAGE) {
107-
$this->control->accept = implode(FileUpload::IMAGE_MIME_TYPES, ', ');
107+
$this->control->accept = implode(', ', FileUpload::IMAGE_MIME_TYPES);
108108
} elseif ($validator === Forms\Form::MIME_TYPE) {
109-
$this->control->accept = implode((array) $arg, ', ');
109+
$this->control->accept = implode(', ', (array) $arg);
110110
}
111111
return parent::addRule($validator, $errorMessage, $arg);
112112
}

src/Forms/Form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function isMethod(string $method): bool
209209
public function addProtection(string $errorMessage = null): Controls\CsrfProtection
210210
{
211211
$control = new Controls\CsrfProtection($errorMessage);
212-
$this->addComponent($control, self::PROTECTOR_ID, key($this->getComponents()));
212+
$this->addComponent($control, self::PROTECTOR_ID, key((array) $this->getComponents()));
213213
return $control;
214214
}
215215

@@ -416,7 +416,7 @@ private function invokeHandlers(iterable $handlers, $button = null): void
416416
{
417417
foreach ($handlers as $handler) {
418418
$params = Nette\Utils\Callback::toReflection($handler)->getParameters();
419-
$values = isset($params[1]) ? $this->getValues((string) $params[1]->getType()) : null;
419+
$values = isset($params[1]) ? $this->getValues($params[1]->getType() ? $params[1]->getType()->getName() : null) : null;
420420
$handler($button ?: $this, $values);
421421
if (!$this->isValid()) {
422422
return;

0 commit comments

Comments
 (0)