-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Add dumper #28898
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
[Console] Add dumper #28898
Conversation
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.
(a test case would be nice)
for tests i like to embed/wait for #28931, so the fallback would be tested using |
This PR was squashed before being merged into the 4.3-dev branch (closes #28931). Discussion ---------- [PhpUnitBridge] Added ClassExistsMock | 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#10528 I've thought about this before, and bumped into it again when trying to test #28898 This PR allows to mock `class|interface|trait_exists` to enable specific code path testing Commits ------- 62caec1 [PhpUnitBridge] Added ClassExistsMock
I already thought about something like that. IMHO the issue is somewhere else. This PR solves this this issue only in CLI, and only in the main entry point (the Command class). So here we go: Many other framework / language have a |
BTW, for now you can aleady achieve this with |
@lyrixx understood
Also there might be e.g. "debug-commands" with lots of code / output control. My main goal here was to obtain the dump value so i can put it in a console table, and have DX friendly output (#24208, #27684)
Im not sure using the logger is possible in my case, im looking mostly for So maybe get rid of |
True, if we get rid of In that case putting it in VarDumper might be a better place 🤔 edit: no, if we move it to vardumper we dont need fallback support :D the whole idea was to NOT require var-dumper, but use it if available. |
Cool :) tend to keep Unless we prefer |
I think I prefer composition, so |
i dont understand the failures yet, running a single test works as expected ( In this case var_dump(
class_exists::class,
class_exists(CliDumper::class),
\Symfony\Component\Console\Helper\class_exists(CliDumper::class),
class_exists(CliDumper::class)
);
// Symfony\Component\Console\Helper\class_exists"
// bool(true) <-- unexpected
// bool(false)
// bool(false) edit: i've split the tests for now into 2 individual suites, this seems to overcome the state issue. |
Green&ready 👍 status: needs review |
Thank you @ro0NL. |
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:  Without:  > #27684 (comment) var-dumper is not a mandatory dep of fwb, can we do without? Now we can :) Commits ------- fc7465c [Console] Add dumper
This PR was merged into the 4.3-dev branch. Discussion ---------- [Form][Console] Use 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#... <!-- required for new features --> Continuation of #28898 for `debug:form` Commits ------- a94228e [Form][Console] Use dumper
This PR adds a new
Dumper
helper in the Console component. As there are 2 types of dumpsdd()
,dump()
)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:With VarDumper comonent:
Without:
Now we can :)