Skip to content

Added possibility for debug plugins #22

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 7 commits into from
Jul 5, 2016
Merged

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Jul 2, 2016

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets php-http/HttplugBundle#26
Documentation php-http/documentation#109
License MIT

What's in this PR?

This PR gives the possibility to add debug plugins. A debug plugin is executed between each normal plugin

Why?

With this PR we can show better diffs and how different plugins are changing the requests/responses.

Checklist

  • Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix
  • Documentation pull request created (if not simply a bugfix)

@sagikazarmark
Copy link
Member

This looks like an interesting idea to me.

/*
* Inject debug plugins between each plugin.
*/
$pluginListWithDegug = $this->options['debug_plugins'];
Copy link
Contributor

Choose a reason for hiding this comment

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

s/Degug/Debug/

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 dont know whats wrong with me. I've corrected this typo at least 10 times...

Thank you.

@dbu
Copy link
Contributor

dbu commented Jul 3, 2016

looks interesting! i think we should have a tiny bit of phpdoc in the constructor. it was not obvious to me from looking at it what this does.

@Nyholm
Copy link
Member Author

Nyholm commented Jul 3, 2016

Ping @joelwurtz. It this similar what you had in mind? php-http/HttplugBundle#26 (comment)

@@ -44,7 +44,8 @@
* @param Plugin[] $plugins
* @param array $options {
*
* @var int $max_restarts
* @var int $max_restarts
* @var Plugin[] $debug_plugins an array of plugins that are injected between all normal plugins
Copy link
Contributor

Choose a reason for hiding this comment

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

s/all normal plugins/each normal plugin/

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you.

@dbu
Copy link
Contributor

dbu commented Jul 4, 2016

looks good to me. lets wait for feedback from @joelwurtz ?

@Nyholm is this ready to merge from your point of view? aka does it work in the HttplugBundle ?

@Nyholm
Copy link
Member Author

Nyholm commented Jul 4, 2016

Yes it is ready for merge.

@@ -110,6 +111,7 @@ private function configure(array $options = [])
$resolver = new OptionsResolver();
$resolver->setDefaults([
'max_restarts' => 10,
'debug_plugins' => [],
Copy link
Member

@sagikazarmark sagikazarmark Jul 4, 2016

Choose a reason for hiding this comment

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

Can we add a type check for plugins somewhere? Does the OptionsResolver support "an array of type" check?

Copy link
Contributor

@dbu dbu Jul 4, 2016 via email

Choose a reason for hiding this comment

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

@joelwurtz
Copy link
Member

joelwurtz commented Jul 4, 2016

Not sure if this would be better in a DebugPluginClient which extends from PluginClient, i just don't like to mix "debug" properties in "real classes".

Also tests are missing :)

Otherwise 👍 for this

@Nyholm
Copy link
Member Author

Nyholm commented Jul 4, 2016

Thank you for the feedback. I've updated the PR.

@dbu
Copy link
Contributor

dbu commented Jul 5, 2016

looks good to me. for this scenario, i see no problem in having debug handled inside the plugin client. thinking from symfony, you will sometimes pass a debug plugin and sometimes not. extending the client would make this a lot more complicated.

@dbu
Copy link
Contributor

dbu commented Jul 5, 2016

squash and merge?

@sagikazarmark sagikazarmark merged commit a3c93b2 into php-http:master Jul 5, 2016
@Nyholm
Copy link
Member Author

Nyholm commented Jul 5, 2016

Thank you for merging.

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.

4 participants