Skip to content

Commit

Permalink
refactor call_user_func
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Apr 28, 2021
1 parent 8ad898b commit 68bc26e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Form/Control/Multiline.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ protected function getComponentDefinition(Field $field): array
}

$definition = array_map(function ($value) use ($field) {
return is_array($value) && is_callable($value) ? call_user_func($value, $field) : $value;
return is_array($value) && is_callable($value) ? $value($field) : $value;
}, $component);

return $definition;
Expand Down Expand Up @@ -629,7 +629,7 @@ protected function valuePropsBinding(string $values)
foreach ($fieldValues as $rows) {
foreach ($rows as $fieldName => $value) {
if (array_key_exists($fieldName, $this->valuePropsBinding)) {
call_user_func($this->valuePropsBinding[$fieldName], $this->getModel()->getField($fieldName), $value);
($this->valuePropsBinding[$fieldName])($this->getModel()->getField($fieldName), $value);
}
}
}
Expand Down Expand Up @@ -690,7 +690,7 @@ private function outputJson(): void

break;
case 'on-change':
$response = call_user_func($this->onChangeFunction, $this->getApp()->decodeJson($_POST['rows']), $this->form);
$response = ($this->onChangeFunction)($this->getApp()->decodeJson($_POST['rows']), $this->form);
$this->renderCallback->terminateAjax($this->renderCallback->getAjaxec($response));

break;
Expand Down
4 changes: 2 additions & 2 deletions src/Form/Control/ScopeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,12 @@ protected function getRule($type, array $defaults = [], Field $field = null): ar

// when $rule is callable
if (is_callable($rule)) {
$rule = call_user_func($rule, $field, $options);
$rule = $rule($field, $options);
}

// map all values for callables and merge with defaults
return array_merge(array_map(function ($value) use ($field, $options) {
return is_array($value) && is_callable($value) ? call_user_func($value, $field, $options) : $value;
return is_array($value) && is_callable($value) ? $value($field, $options) : $value;
}, $rule), $defaults);
}

Expand Down
4 changes: 2 additions & 2 deletions src/UserAction/ExecutorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ protected function createActionTrigger(UserAction $action, string $type = null):
$seed = $viewType['default'];
}

$seed = is_array($seed) && is_callable($seed) ? call_user_func($seed, $action, $type) : $seed;
$seed = is_array($seed) && is_callable($seed) ? $seed($action, $type) : $seed;

return Factory::factory($seed);
}
Expand Down Expand Up @@ -249,7 +249,7 @@ protected function getActionCaption(UserAction $action, string $type = null): st
$caption = $action->getCaption();
}

return is_array($caption) && is_callable($caption) ? call_user_func($caption, $action) : $caption;
return is_array($caption) && is_callable($caption) ? $caption($action) : $caption;
}

/**
Expand Down

0 comments on commit 68bc26e

Please sign in to comment.