Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 1 commit into from
Sep 4, 2018

Conversation

yceruto
Copy link
Member

@yceruto yceruto commented Jun 20, 2018

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):
debug_types_with_deprecated_options

Use --show-deprecated option to show deprecated options of the given form type (example):
debug_deprecated_options_from_type

Deprecated option (example):
debug_deprecated_option_text

debug_deprecated_option_json

@linaori
Copy link
Contributor

linaori commented Jun 21, 2018

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!

@nicolas-grekas nicolas-grekas added this to the next milestone Jun 21, 2018
@yceruto
Copy link
Member Author

yceruto commented Jun 21, 2018

@iltar sure, I'll add an option --show-deprecated to filter the result on debug:form and debug:form <type>.

Status: Needs Work

@yceruto yceruto force-pushed the debug_deprecated_options branch 2 times, most recently from 69cf93f to 150c14d Compare June 24, 2018 21:45
@yceruto
Copy link
Member Author

yceruto commented Jun 24, 2018

Added --show-deprecated option to the comand:

Use the --show-deprecated option to display form types with deprecated options or the deprecated options of the given form type:

php %command.full_name% --show-deprecated
php %command.full_name% ChoiceType --show-deprecated

Status: Needs Review

(Travis failures aren't related)

@yceruto yceruto force-pushed the debug_deprecated_options branch 2 times, most recently from a42dfa2 to 64f444b Compare July 3, 2018 11:06
@yceruto
Copy link
Member Author

yceruto commented Jul 7, 2018

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 ogizanagi self-requested a review July 7, 2018 16:36
Copy link
Contributor

@ogizanagi ogizanagi left a 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
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

@ogizanagi ogizanagi Jul 15, 2018

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.

Copy link
Member Author

@yceruto yceruto Jul 15, 2018

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])) {
Copy link
Contributor

@ogizanagi ogizanagi Jul 15, 2018

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;
         }

@yceruto yceruto force-pushed the debug_deprecated_options branch from 64f444b to f02ee12 Compare July 15, 2018 18:31
@yceruto
Copy link
Member Author

yceruto commented Jul 15, 2018

Thanks for the review @ogizanagi! I've fixed most comments. (AppVeyor & Travis failures are unrelated)

@yceruto yceruto force-pushed the debug_deprecated_options branch 4 times, most recently from 676e79d to cde4c4b Compare July 15, 2018 21:07
@yceruto yceruto force-pushed the debug_deprecated_options branch 2 times, most recently from b2cf002 to 856578c Compare July 30, 2018 19:49
@yceruto
Copy link
Member Author

yceruto commented Jul 30, 2018

Rebased and ready.

Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

with minor comments

@@ -58,6 +58,7 @@ protected function configure()
->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'),
Copy link
Member

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

@@ -75,6 +76,11 @@ protected function configure()

<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:
Copy link
Member

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

@yceruto yceruto force-pushed the debug_deprecated_options branch from 856578c to 87c209d Compare September 4, 2018 13:42
@yceruto
Copy link
Member Author

yceruto commented Sep 4, 2018

@fabpot comments addressed, thanks! (AppVeyor failure is unrelated)

@fabpot
Copy link
Member

fabpot commented Sep 4, 2018

Thank you @yceruto.

@fabpot fabpot merged commit 87c209d into symfony:master Sep 4, 2018
fabpot added a commit that referenced this pull request Sep 4, 2018
…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):
![debug_types_with_deprecated_options](https://user-images.githubusercontent.com/2028198/41823977-970c7c98-77d6-11e8-9e97-30dcedc316ac.png)

Use `--show-deprecated` option to show deprecated options of the given form type (example):
![debug_deprecated_options_from_type](https://user-images.githubusercontent.com/2028198/41823980-a4d6bd8e-77d6-11e8-95ed-39926ffd6235.png)

Deprecated option (example):
![debug_deprecated_option_text](https://user-images.githubusercontent.com/2028198/41689091-04e6b7dc-74bd-11e8-87d0-90729eac4bb3.png)

![debug_deprecated_option_json](https://user-images.githubusercontent.com/2028198/41689105-142b5c5c-74bd-11e8-9232-1f30237bcf69.png)

Commits
-------

87c209d Show deprecated options definition on debug:form command
@yceruto yceruto deleted the debug_deprecated_options branch September 4, 2018 15:29
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
This was referenced Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants