Skip to content

[VarDumper][HttpKernel] Add context to all dumps #28395

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

Closed

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Sep 7, 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 -

Following some discussion in #28317, I think it would be nice if the default VarDumper handler would add where the dump calls comes from. This is the case when the DebugBundle is enabled on html dumps. The behavior I added is exactly the same.

I also added it for cli dumps, but for those one I think it's actually better to display the file path instead of just the class name as sometimes you have multiple classes with the same name. This is not a problem for html dumps since there is a title attribute on the span or on the link.

@fancyweb fancyweb force-pushed the feat-add-context-to-all-dumps branch from 2807858 to 2f49e78 Compare September 7, 2018 18:54
$name = $file;
}

$this->line = $this->style('meta', $name, $attr).' on line '.$this->style('meta', $line).':';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this scenario, we are 100% sure that the dumper is an instance of CliDumper so those methods are safe to use.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Sep 8, 2018

I'd prefer not doing this change personally: when debugging, it's already hard enough to figure out what's going on, I'd prefer not having to visually parse extra output...

@fancyweb
Copy link
Contributor Author

fancyweb commented Sep 8, 2018

Here is how it renders :
CLI
cli

HTML
html

@nicolas-grekas nicolas-grekas modified the milestones: 2.8, next Sep 8, 2018
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Sep 9, 2018

The location of the dump is already printed in the dump-server and when the toolbar is used, isn't it?
When debugging e.g. CLI apps, I often end up using dump() in loops. Personally, I'd prefer not having the file+line in the output, as it would mostly be noise to my eyes.
Note that when dd() is used, I'd welcome this change, because, by definition, this will be printed only once.

@fancyweb
Copy link
Contributor Author

fancyweb commented Sep 9, 2018

When you only use the VarDumper component, no location is printed at all. So it would be an improvement for everyone using this component without Symfony, which is currently my case (working on Drupal) ^^

When you use the DebugBundle, a new handler is registered, so this new code will never be used and indeed the location is displayed in the toolbar, in the profiler, in the dump itself (if you die), and in the dump server.

For the cli dumps, I can understand and agree with the loop example. However, currently, when you use the dump server, 7 lines and displayed before each dump. Example with a loop :

loop

@fabpot
Copy link
Member

fabpot commented Oct 10, 2018

@nicolas-grekas Any more inputs here?

@nicolas-grekas
Copy link
Member

Sure, I'm 👎

@fabpot
Copy link
Member

fabpot commented Oct 10, 2018

Let's close then.

@fabpot fabpot closed this Oct 10, 2018
@fancyweb fancyweb deleted the feat-add-context-to-all-dumps branch October 11, 2018 06:42
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 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.

4 participants