8000 [Form] improve deprecation message for "empty_value" and "choice_list" options. by hhamon · Pull Request #17119 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] improve deprecation message for "empty_value" and "choice_list" options. #17119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Form] improve deprecation messages for the "empty_value" and "choice…
…_list" options in the ChoiceType class.
  • Loading branch information
Hugo Hamon committed Dec 29, 2015
commit 787853673bc12d0d147c0968ebc5a633880514bf
9 changes: 5 additions & 4 deletions src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,10 @@ public function configureOptions(OptionsResolver $resolver)
return;
};

$choiceListNormalizer = function (Options $options, $choiceList) use ($choiceListFactory) {
$that = $this;
$choiceListNormalizer = function (Options $options, $choiceList) use ($choiceListFactory, $that) {
if ($choiceList) {
@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);
@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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we know that getName is deprecated in 2.8, shouldn't we only tell about __CLASS__? At least that's what should be done in 2.8, isn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolas-grekas this PR targets Symfony 2.7. In 2.8, we should indeed change it to use the class name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it's merged, I will open the other PR against the 2.8 branch.


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

$placeholderNormalizer = function (Options $options, $placeholder) {
$placeholderNormalizer = function (Options $options, $placeholder) use ($that) {
if (!is_object($options['empty_value']) || !$options['empty_value'] instanceof \Exception) {
@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);
@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);

$placeholder = $options['empty_value'];
}
Expand Down
0