Skip to content
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

Make PrettyPageHandler more easily extendable #517

Merged
merged 2 commits into from
Aug 3, 2017

Conversation

juliangut
Copy link
Contributor

Extending from PrettyPageHandler is a real pain: almost everything is private (nor everything should be protected neither) and most of the actual work is done in "handle" method so if I want to extend the class I've to completely copy/and/rewrite the whole method, even for the simplest of the modifications, with the problems this carries with future modifications of the original. This violates the O in SOLID

My use case: I need to filter certain frames out of the stack, and the corresponding exception code as well. To accomplish this I've just extracted "frames" and "code" collection into protected methods that can be overridden in children

Copy link
Collaborator

@denis-sokolov denis-sokolov left a comment

Choose a reason for hiding this comment

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

This is a good PR, thank you!

I support adding more ability to extend, as long as it is explicitly designed for. Your identified functions getFrames and getCode are good places to extend Whoops.

Could you make their names and descriptions a bit more explicit? Instead of getCode could you make it getExceptionCode, instead of getFrames - getExceptionFrames. In their descriptions in the doc comment, describe “Get the code of the exception that is currently being handled”.

My point being if we are adding new functions that 3rd-party developers can use to extend, let’s make sure the functions are very explicitly documented. :-)

Overall, thanks for the PR!

@@ -666,7 +691,7 @@ public function blacklist($superGlobalName, $key) {
* @param $superGlobalName string the name of the superglobal array, e.g. '_GET'
* @return array $values without sensitive data
*/
private function masked(array $superGlobal, $superGlobalName) {
private function getMasked(array $superGlobal, $superGlobalName) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this rename bundled with this commit? Note that the method is still private. Did you mean to make it protected as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I toyed with the idea of making it protected but I think this is the kind of method that really is meant to be private

$extraTables = array_map(function ($table) use ($inspector) {
return $table instanceof \Closure ? $table($inspector) : $table;
}, $this->getDataTables());
$extraTables = array_map(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I tend to avoid reformatting in the same commit as meaningful changes, as to keep the diffs more meaningful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I tend to reformat right when I see this kind of things

@juliangut
Copy link
Contributor Author

I'll update this evening for sure

@juliangut
Copy link
Contributor Author

Cleaner PR!

@denis-sokolov denis-sokolov merged commit ffbbd2c into filp:master Aug 3, 2017
@denis-sokolov
Copy link
Collaborator

Thank you for your contribution!

@juliangut
Copy link
Contributor Author

Quick question: next release has a planed date?

@denis-sokolov
Copy link
Collaborator

2.1.10 released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants