Skip to content

Commit 9df35a9

Browse files
author
Hugo Hamon
committed
[Form] improve deprecation messages for the "empty_value" and "choice_list" options in the ChoiceType class.
1 parent 3d95d1c commit 9df35a9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Extension/Core/Type/ChoiceType.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,10 @@ public function configureOptions(OptionsResolver $resolver)
292292
return;
293293
};
294294

295-
$choiceListNormalizer = function (Options $options, $choiceList) use ($choiceListFactory) {
295+
$that = $this;
296+
$choiceListNormalizer = function (Options $options, $choiceList) use ($choiceListFactory, $that) {
296297
if ($choiceList) {
297-
@trigger_error('The "choice_list" option is deprecated since version 2.7 and will be removed in 3.0. Use "choice_loader" instead.', E_USER_DEPRECATED);
298+
@trigger_error(sprintf('The "choice_list" option of the "%s" form type (%s) is deprecated since version 2.7 and will be removed in 3.0. Use "choice_loader" instead.', $that->getName(), __CLASS__), E_USER_DEPRECATED);
298299

299300
if ($choiceList instanceof LegacyChoiceListInterface) {
300301
return new LegacyChoiceListAdapter($choiceList);
@@ -321,9 +322,9 @@ public function configureOptions(OptionsResolver $resolver)
321322
return $choiceListFactory->createListFromChoices($choices, $options['choice_value']);
322323
};
323324

324-
$placeholderNormalizer = function (Options $options, $placeholder) {
325+
$placeholderNormalizer = function (Options $options, $placeholder) use ($that) {
325326
if (!is_object($options['empty_value']) || !$options['empty_value'] instanceof \Exception) {
326-
@trigger_error('The form option "empty_value" is deprecated since version 2.6 and will be removed in 3.0. Use "placeholder" instead.', E_USER_DEPRECATED);
327+
@trigger_error(sprintf('The form option "empty_value" of the "%s" form type (%s) is deprecated since version 2.6 and will be removed in 3.0. Use "placeholder" instead.', $that->getName(), __CLASS__), E_USER_DEPRECATED);
327328

328329
$placeholder = $options['empty_value'];
329330
}

0 commit comments

Comments
 (0)