Skip to content

Use flex client wrapper for profiling if needed #209

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 4 commits into from
Nov 29, 2017

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Sep 6, 2017

fix #206

FYI @fbourigault

Copy link
Contributor

@fbourigault fbourigault left a comment

Choose a reason for hiding this comment

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

Thank you. I missed this in my last PluginClientFactory support PR.

@@ -47,23 +47,18 @@ class ProfileClient implements HttpClient, HttpAsyncClient
private $eventNames = [];

/**
* @param HttpClient|HttpAsyncClient $client The client to profile. Client must implement both HttpClient and
* HttpAsyncClient interfaces.
* @param HttpClient|HttpAsyncClient $client The client to profile. Client must implement both HttpClient or
Copy link
Contributor

Choose a reason for hiding this comment

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

implement HttpClient or HttpAsyncClient


class Issue206 extends WebTestCase
{
public function testCustomClientStillAvailable()
Copy link
Contributor

Choose a reason for hiding this comment

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

You should assert something in this test to avoid adding a risky test.

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

@@ -22,5 +22,8 @@ public function testCustomClientStillAvailable()
// Create a client
$myCustomClient = new HttpMethodsClient(HttpClientDiscovery::find(), MessageFactoryDiscovery::find());
$pluginClient = (new PluginClientFactory())->createClient($myCustomClient, []);

// If we get to this line, no exceptions has been thrown.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still relevant as we removed the throw statement from ProfileClient. Maybe you could use NSA to check that the $client inside $pluginClient is a FlexibleHttpClient.

@fbourigault
Copy link
Contributor

This one was left aside since ages :/ Could you rebase to check that build is still green? This is required for next release.

@fbourigault fbourigault added this to the 1.8.0 milestone Nov 27, 2017
@Nyholm
Copy link
Member Author

Nyholm commented Nov 28, 2017

Im done with this PR. We should use the flexClient.

This will fix #206.

@dbu dbu changed the title Adding failing tests for #206 Use flex client wrapper for profiling if needed Nov 29, 2017
Copy link
Collaborator

@dbu dbu left a comment

Choose a reason for hiding this comment

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

i updated the title and description as this is now the fix to the problem and not only a failing test.

thanks a lot, looks good to squash and merge to me.

@fbourigault fbourigault merged commit d12c15d into php-http:master Nov 29, 2017
@fbourigault
Copy link
Contributor

Thank you!

@Nyholm Nyholm deleted the issue206 branch November 29, 2017 08:37
* @param Collector $collector
* @param Formatter $formatter
* @param Stopwatch $stopwatch
*/
public function __construct($client, Collector $collector, Formatter $formatter, Stopwatch $stopwatch)
{
if (!($client instanceof HttpClient && $client instanceof HttpAsyncClient)) {
throw new \RuntimeException(sprintf(
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the exception still be thrown if neither of the interfaces is implemented? I know that the FlexibleHttpClient throws anyway, but I am not sure if relying on that behaviour would be a good idea and also could the stack trace be confusing for users.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, an exception are thrown, But yes. It could be a good idea to throw en exception here as well.

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.

ProfileClient overrides other feature clients
4 participants