Skip to content

Commit fb2378c

Browse files
Merge branch '4.1' into 4.2
* 4.1: Fix typos in doc blocks [Debug] ignore underscore vs backslash namespaces in DebugClassLoader [TwigBridge][Form] Prevent multiple rendering of form collection prototypes [FrameworkBundle] fix describing routes with no controllers [DI] move RegisterServiceSubscribersPass before DecoratorServicePass Update ValidationListener.php [Yaml] ensures that the mb_internal_encoding is reset to its initial value [WebLink] Fixed documentation link [Security] getTargetPath of TargetPathTrait must return string or null [Hackday][Serializer] Deserialization ignores argument type hint from phpdoc for array in constructor argument Optimize perf by replacing call_user_func with dynamic vars [Routing] fix dumping same-path routes with placeholders [Security] defer log message in guard authenticator [Validator] Added IBAN format for Vatican City State merge conflicts filter out invalid Intl values filter out invalid language values [Validator] Fixed grouped composite constraints [Form] Filter arrays out of scalar form types Fix HeaderBag::get phpdoc
2 parents 51f8c39 + cffdd99 commit fb2378c

25 files changed

+87
-54
lines changed

CallbackTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(callable $transform, callable $reverseTransform)
4141
*/
4242
public function transform($data)
4343
{
44-
return \call_user_func($this->transform, $data);
44+
return ($this->transform)($data);
4545
}
4646

4747
/**
@@ -57,6 +57,6 @@ public function transform($data)
5757
*/
5858
public function reverseTransform($data)
5959
{
60-
return \call_user_func($this->reverseTransform, $data);
60+
return ($this->reverseTransform)($data);
6161
}
6262
}

ChoiceList/ArrayChoiceList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function getValuesForChoices(array $choices)
155155
$givenValues = array();
156156

157157
foreach ($choices as $i => $givenChoice) {
158-
$givenValues[$i] = (string) \call_user_func($this->valueCallback, $givenChoice);
158+
$givenValues[$i] = (string) ($this->valueCallback)($givenChoice);
159159
}
160160

161161
return array_intersect($givenValues, array_keys($this->choices));
@@ -202,7 +202,7 @@ protected function flatten(array $choices, $value, &$choicesByValues, &$keysByVa
202202
continue;
203203
}
204204

205-
$choiceValue = (string) \call_user_func($value, $choice);
205+
$choiceValue = (string) $value($choice);
206206
$choicesByValues[$choiceValue] = $choice;
207207
$keysByValues[$choiceValue] = $key;
208208
$structuredValues[$key] = $choiceValue;

ChoiceList/Factory/DefaultChoiceListFactory.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $
118118
// $value may be an integer or a string, since it's stored in the array
119119
// keys. We want to guarantee it's a string though.
120120
$key = $keys[$value];
121-
$nextIndex = \is_int($index) ? $index++ : \call_user_func($index, $choice, $key, $value);
121+
$nextIndex = \is_int($index) ? $index++ : $index($choice, $key, $value);
122122

123123
// BC normalize label to accept a false value
124124
if (null === $label) {
@@ -127,7 +127,7 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $
127127
} elseif (false !== $label) {
128128
// If "choice_label" is set to false and "expanded" is true, the value false
129129
// should be passed on to the "label" option of the checkboxes/radio buttons
130-
$dynamicLabel = \call_user_func($label, $choice, $key, $value);
130+
$dynamicLabel = $label($choice, $key, $value);
131131
$label = false === $dynamicLabel ? false : (string) $dynamicLabel;
132132
}
133133

@@ -137,11 +137,11 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $
137137
$label,
138138
// The attributes may be a callable or a mapping from choice indices
139139
// to nested arrays
140-
\is_callable($attr) ? \call_user_func($attr, $choice, $key, $value) : (isset($attr[$key]) ? $attr[$key] : array())
140+
\is_callable($attr) ? $attr($choice, $key, $value) : (isset($attr[$key]) ? $attr[$key] : array())
141141
);
142142

143143
// $isPreferred may be null if no choices are preferred
144-
if ($isPreferred && \call_user_func($isPreferred, $choice, $key, $value)) {
144+
if ($isPreferred && $isPreferred($choice, $key, $value)) {
145145
$preferredViews[$nextIndex] = $view;
146146
} else {
147147
$otherViews[$nextIndex] = $view;
@@ -200,7 +200,7 @@ private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $key
200200

201201
private static function addChoiceViewGroupedBy($groupBy, $choice, $value, $label, $keys, &$index, $attr, $isPreferred, &$preferredViews, &$otherViews)
202202
{
203-
$groupLabel = \call_user_func($groupBy, $choice, $keys[$value], $value);
203+
$groupLabel = $groupBy($choice, $keys[$value], $value);
204204

205205
if (null === $groupLabel) {
206206
// If the callable returns null, don't group the choice

ChoiceList/Loader/CallbackChoiceLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function loadChoiceList($value = null)
4646
return $this->choiceList;
4747
}
4848

49-
return $this->choiceList = new ArrayChoiceList(\call_user_func($this->callback), $value);
49+
return $this->choiceList = new ArrayChoiceList(($this->callback)(), $value);
5050
}
5151

5252
/**

ChoiceList/Loader/IntlCallbackChoiceLoader.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ public function loadChoicesForValues(array $values, $value = null)
3030
return array();
3131
}
3232

33-
// If no callable is set, values are the same as choices
34-
if (null === $value) {
35-
return $values;
36-
}
37-
3833
return $this->loadChoiceList($value)->getChoicesForValues($values);
3934
}
4035

Extension/Core/EventListener/ResizeFormListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function onSubmit(FormEvent $event)
135135
/** @var FormInterface $child */
136136
foreach ($form as $name => $child) {
137137
$isNew = !isset($previousData[$name]);
138-
$isEmpty = \is_callable($this->deleteEmpty) ? \call_user_func($this->deleteEmpty, $child->getData()) : $child->isEmpty();
138+
$isEmpty = \is_callable($this->deleteEmpty) ? ($this->deleteEmpty)($child->getData()) : $child->isEmpty();
139139

140140
// $isNew can only be true if allowAdd is true, so we don't
141141
// need to check allowAdd again

Extension/Core/Type/CountryType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ public function loadChoicesForValues(array $values, $value = null)
106106
return array();
107107
}
108108

109-
// If no callable is set, values are the same as choices
110-
if (null === $value) {
111-
return $values;
112-
}
113-
114109
return $this->loadChoiceList($value)->getChoicesForValues($values);
115110
}
116111

Extension/Core/Type/CurrencyType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ public function loadChoicesForValues(array $values, $value = null)
106106
return array();
107107
}
108108

109-
// If no callable is set, values are the same as choices
110-
if (null === $value) {
111-
return $values;
112-
}
113-
114109
return $this->loadChoiceList($value)->getChoicesForValues($values);
115110
}
116111

Extension/Core/Type/LanguageType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ public function loadChoicesForValues(array $values, $value = null)
106106
return array();
107107
}
108108

109-
// If no callable is set, values are the same as choices
110-
if (null === $value) {
111-
return $values;
112-
}
113-
114109
return $this->loadChoiceList($value)->getChoicesForValues($values);
115110
}
116111

Extension/Core/Type/LocaleType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ public function loadChoicesForValues(array $values, $value = null)
106106
return array();
107107
}
108108

109-
// If no callable is set, values are the same as choices
110-
if (null === $value) {
111-
return $values;
112-
}
113-
114109
return $this->loadChoiceList($value)->getChoicesForValues($values);
115110
}
116111

0 commit comments

Comments
 (0)