Skip to content

[Form] Display option definition from a given form type #24208

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 2 commits into from
Oct 9, 2017

Conversation

yceruto
Copy link
Member

@yceruto yceruto commented Sep 14, 2017

Q A
Branch? 3.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes (deps=high failure expected)
Fixed tickets -
License MIT
Doc PR -

debug-form-option

Show friendly message if typo:
debug-form-not-found

complement of #24185

@yceruto
Copy link
Member Author

yceruto commented Sep 14, 2017

I've used CliDumper to dump some values but the output is not colored (see Normalizer value) @nicolas-grekas am I probably missing something?

@nicolas-grekas
Copy link
Member

Color is auto-enabled only when writing to a color-enabled output stream. You can force it, but then it's your responsibility to do it appropriately, see eg
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/VarDumper/Dumper/CliDumper.php#L85

@yceruto yceruto force-pushed the debug_form_option branch 3 times, most recently from 0a45775 to b71aed9 Compare September 14, 2017 20:24
@yceruto
Copy link
Member Author

yceruto commented Sep 14, 2017

@nicolas-grekas perfect thanks! color enabled.

protected function describeOption(OptionsResolver $optionsResolver, array $options = array())
{
$this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR);
$this->dumper->setColors(true);
Copy link
Member

Choose a reason for hiding this comment

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

s/true/$this->output->isDecorated()/

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Sep 14, 2017
@yceruto yceruto force-pushed the debug_form_option branch 7 times, most recently from 67cddf1 to 751de48 Compare September 14, 2017 22:44
@ogizanagi
Copy link
Contributor

Is dumping a closure like the normalizer ones really useful? At least perhaps registering a dedicated caster to only keep file and line no?

@ogizanagi ogizanagi self-requested a review September 15, 2017 16:32
@yceruto
Copy link
Member Author

yceruto commented Sep 15, 2017

Status: Needs Work

@yceruto yceruto force-pushed the debug_form_option branch 2 times, most recently from 3c548a7 to e9d49c2 Compare September 15, 2017 17:59
@yceruto
Copy link
Member Author

yceruto commented Sep 15, 2017

Unrelated to this command argument but I added type alternatives if typo on debug:form <type>:
type-alternatives

@yceruto yceruto force-pushed the debug_form_option branch 3 times, most recently from 9e90c8a to 20e9af2 Compare September 15, 2017 22:37
@ogizanagi
Copy link
Contributor

@nicolas-grekas: Regarding #24208 (comment), does this look okay to you? Thank you.

@ogizanagi
Copy link
Contributor

I'm going to merge this (unless there is any objection) before feature freeze, so the whole debug:form feature is complete for 3.4.
Anyway, I'll create a PR to add tests and give more visibility to the introduced OptionResolverIntrospector hidden in this PR. We still have 2 months to tweak this if desired.

@fabpot
Copy link
Member

fabpot commented Sep 29, 2017

I'd prefer to finish everything properly instead of rushing out anything. That would not make sense. We can still merge things next week if needed. there is no hard date.

@ogizanagi
Copy link
Contributor

Alright :)

@yceruto yceruto force-pushed the debug_form_option branch from c4e6958 to 4c07a0e Compare October 3, 2017 10:32
@yceruto
Copy link
Member Author

yceruto commented Oct 3, 2017

Just rebasing & resolving conflicts :)

@ogizanagi ogizanagi force-pushed the debug_form_option branch 2 times, most recently from ed0986e to 7b44ca0 Compare October 3, 2017 13:36
@fabpot
Copy link
Member

fabpot commented Oct 9, 2017

Thank you @yceruto.

@fabpot fabpot merged commit d6d187d into symfony:3.4 Oct 9, 2017
fabpot added a commit that referenced this pull request Oct 9, 2017
…e (yceruto, ogizanagi)

This PR was merged into the 3.4 branch.

Discussion
----------

[Form] Display option definition from a given form type

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes (deps=high failure expected)
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

![debug-form-option](https://user-images.githubusercontent.com/2028198/30569305-12a30738-9ca8-11e7-98b7-6eaf78d3d5a7.png)

Show friendly message if typo:
![debug-form-not-found](https://user-images.githubusercontent.com/2028198/30450999-83d58b56-9960-11e7-8705-b60ba33baf48.png)

complement of #24185

Commits
-------

d6d187d Add & use OptionResolverIntrospector
8bbb5e7 Add debug:form type option
@yceruto yceruto deleted the debug_form_option branch October 9, 2017 11:16
This was referenced Oct 18, 2017
@ro0NL ro0NL mentioned this pull request Oct 17, 2018
fabpot added a commit that referenced this pull request Mar 24, 2019
This PR was squashed before being merged into the 4.3-dev branch (closes #28898).

Discussion
----------

[Console] Add dumper

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#10502

This PR adds a new `Dumper` helper in the Console component. As there are 2 types of dumps

- debug purpose (e.g. `dd()`, `dump()`)
- output purpose (see #24208, #27684)

For the latter we cannot use the global system (debug) dumper, i.e. `VarDumper::dump()`, we need something tied to the current output and dependency free. Here it is:

```php
$io = new SymfonyStyle($input, $output);
$dumper = new Dumper($io);

$io->writeln($dumper([-0.5, 0, 1]));
$io->writeln($dumper(new \stdClass()));
$io->writeln($dumper(123));
$io->writeln($dumper('foo'));
$io->writeln($dumper(null));
$io->writeln($dumper(true));
```

With VarDumper comonent:

![image](https://user-images.githubusercontent.com/1047696/47069483-4cc26f80-d1ef-11e8-902e-2f9b0f040f25.png)

Without:

![image](https://user-images.githubusercontent.com/1047696/47069517-6663b700-d1ef-11e8-9328-ae1db0b83d7e.png)

> #27684 (comment) var-dumper is not a mandatory dep of fwb, can we do without?

Now we can  :)

Commits
-------

fc7465c [Console] Add dumper
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Jul 20, 2023
This PR was submitted for the 6.4 branch but it was squashed and merged into the 5.4 branch instead.

Discussion
----------

add `OptionsResolverIntrospector`usage doc

<!--

If your pull request fixes a BUG, use the oldest maintained branch that contains
the bug (see https://symfony.com/releases for the list of maintained branches).

If your pull request documents a NEW FEATURE, use the same Symfony branch where
the feature was introduced (and `6.x` for features of unreleased versions).

-->

Original commit : symfony/symfony@d6d187d
Orignal PR : symfony/symfony#24208

Commits
-------

887f6f5 add `OptionsResolverIntrospector`usage doc
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.

7 participants