-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Form][OptionsResolver] Show deprecated options definition on debug:form command #27667
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
Conversation
b252112 to
e2e05f9
Compare
|
Will it be possible to use this command to find all form types that have a deprecated option, and see which of those options are deprecated per type? That would make fixing them a walk in the park! |
|
@iltar sure, I'll add an option Status: Needs Work |
69cf93f to
150c14d
Compare
|
Added
Status: Needs Review (Travis failures aren't related) |
a42dfa2 to
64f444b
Compare
|
Any update about this? @ogizanagi you're working on this command in the past, so will be great to have your opinion on this! thanks. :) |
ogizanagi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Thanks @yceruto for working on this!
| /** | ||
| * @return string|\Closure | ||
| * | ||
| * @throws NoConfigurationException on no configured normalizer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on no configured deprecation
| return $definition; | ||
| } | ||
|
|
||
| protected function filterTypesByDeprecated(array $types): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with current code, should this rather live in the command and pass deprecated types & options to the descriptor as $options, so the descriptors' responsibility sticks to handling output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but in that case should we to move collectOptions(), getParentOptionsResolver(), etc, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's okay as we aim to describe OptionResolver and ResolvedFormTypeInterface instances. What is a bit weird here to me is injecting the form registry as an option.
But no strong opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, done.
| for ($i = 0; $i < $count; ++$i) { | ||
| $cells = array(); | ||
| foreach (array_keys($headers) as $group) { | ||
| if (isset($options[$group][$i])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be simplified a bit I guess:
diff --git a/src/Symfony/Component/Form/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Form/Console/Descriptor/TextDescriptor.php
index 1e63aa0c68..3702d2f6b1 100644
--- a/src/Symfony/Component/Form/Console/Descriptor/TextDescriptor.php
+++ b/src/Symfony/Component/Form/Console/Descriptor/TextDescriptor.php
@@ -130,17 +130,12 @@ class TextDescriptor extends Descriptor
for ($i = 0; $i < $count; ++$i) {
$cells = array();
foreach (array_keys($headers) as $group) {
- if (isset($options[$group][$i])) {
- $option = $options[$group][$i];
-
- if (\is_string($option) && \in_array($option, $this->requiredOptions, true)) {
- $option .= ' <info>(required)</info>';
- }
-
- $cells[] = $option;
- } else {
- $cells[] = null;
+ $option = $options[$group][$i] ?? null;
+ if (\is_string($option) && \in_array($option, $this->requiredOptions, true)) {
+ $option .= ' <info>(required)</info>';
}
+
+ $cells[] = $option;
}
$tableRows[] = $cells;
}
src/Symfony/Component/Form/Tests/Fixtures/Descriptor/types_with_deprecated_options.json
Outdated
Show resolved
Hide resolved
64f444b to
f02ee12
Compare
|
Thanks for the review @ogizanagi! I've fixed most comments. (AppVeyor & Travis failures are unrelated) |
676e79d to
cde4c4b
Compare
b2cf002 to
856578c
Compare
|
Rebased and ready. |
fabpot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with minor comments
| ->setDefinition(array( | ||
| new InputArgument('class', InputArgument::OPTIONAL, 'The form type class'), | ||
| new InputArgument('option', InputArgument::OPTIONAL, 'The form type option'), | ||
| new InputOption('show-deprecated', null, InputOption::VALUE_NONE, 'Used to show deprecated options in form types'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Display deprecated options in form types
| <info>php %command.full_name% ChoiceType choice_value</info> | ||
| Use the <info>--show-deprecated</info> option to display form types with deprecated options or the deprecated options of the given form type: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be cut at around 80 chars
856578c to
87c209d
Compare
|
@fabpot comments addressed, thanks! (AppVeyor failure is unrelated) |
|
Thank you @yceruto. |
…tion on debug:form command (yceruto) This PR was merged into the 4.2-dev branch. Discussion ---------- [Form][OptionsResolver] Show deprecated options definition on debug:form command | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Next move after #27277. It will look like this: Use `--show-deprecated` option to show form types with deprecated options (example):  Use `--show-deprecated` option to show deprecated options of the given form type (example):  Deprecated option (example):   Commits ------- 87c209d Show deprecated options definition on debug:form command
Next move after #27277.
It will look like this:
Use

--show-deprecatedoption to show form types with deprecated options (example):Use

--show-deprecatedoption to show deprecated options of the given form type (example):Deprecated option (example):
