You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am configuring Symfony's immutable HttpClient in the constructor of a service. I have the spec set up to return a new instance of the client in the let() method, which works fine in spec that don't reconfigure the constructor.
However, if I attempt to reconfigure the constructor in an example then I get an error about the return type…
[err:TypeError("Double\HttpClientInterface\HttpClientInterface\P3::withOptions(): Return value must be of type Double\HttpClientInterface\HttpClientInterface\P3, Double\HttpClientInterface\P1 returned")] has been thrown.
… however, if I inject the resulting client into the example, even if it's not used, it works just fine…
// …publicfunctionit_should_provide_the_base_url_length(
HttpClientInterface$initialHttpClient,
// Keep this here, as without it the example fails with a return type error// @see https://github.com/phpspec/phpspec/issues/1448HttpClientInterface$httpClient,
): void {
$this->beConstructedWith('https://api.co', $initialHttpClient);
$this
->getBaseUrlLength()
->shouldReturn(14);
}
Is this a known limitation?
The text was updated successfully, but these errors were encountered:
Actually, I've just realised it doesn't matter whehter I update the constructor args in a example or not, it gives the same error. I this I may have been mislead by my assuption that the it_is_initializable() example would instantiate the object?!
So this example also gives the Return value must be of type Double\HttpClientInterface\P1, Double\HttpClientInterface\HttpClientInterface\P3 returned error as well…
Ah, OK. Thanks @ciaranmcnulty. Would yo like me to leave this open for review then? I'm working OK by storing the initial collaborator instances in properties and using them in the examples.
I am configuring Symfony's immutable
HttpClient
in the constructor of a service. I have the spec set up to return a new instance of the client in thelet()
method, which works fine in spec that don't reconfigure the constructor.However, if I attempt to reconfigure the constructor in an example then I get an error about the return type…
… results in …
… however, if I inject the resulting client into the example, even if it's not used, it works just fine…
Is this a known limitation?
The text was updated successfully, but these errors were encountered: