Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[BrowserKit] Fixed BC-break introduced by rename of Client to Browser#31040
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedApr 9, 2019
class_alias() doesn't work really well for deprecation layers because the notice is thrown depending on the loading order. Deprecating the service in favor of test.browser might be better? |
Devristo commentedApr 9, 2019
It is true that <?phpdeclare(strict_types=1);namespaceFriendsOfBehat\SymfonyExtension\Driver;useBehat\Mink\Driver\BrowserKitDriver;useSymfony\Component\BrowserKit\Client;useSymfony\Component\HttpKernel\KernelInterface;finalclass SymfonyDriverextends BrowserKitDriver{publicfunction__construct(KernelInterface$kernel,string$baseUrl) {if (!$kernel->getContainer()->has('test.client')) {thrownew \RuntimeException(sprintf('Kernel "%s" used by Behat with "%s" environment and debug %s does not have "test.client" service.' ."\n" .'Please make sure the kernel is using "test" environment or have "framework.test" configuration option enabled.',get_class($kernel),$kernel->getEnvironment(),$kernel->isDebug() ?'enabled' :'disabled' )); }$testClient =$kernel->getContainer()->get('test.client');if (!$testClientinstanceof Client) {thrownew \RuntimeException(sprintf('Service "test.client" should be an instance of "%s", "%s" given.', Client::class,get_class($testClient) )); }parent::__construct($testClient,$baseUrl); }} The service Or do you mean that inaddition to the |
nicolas-grekas commentedApr 9, 2019
I was hopping that creating a new service would be enough but it wouldn't allow passing legacy type hints. |
Devristo commentedApr 9, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
If I am not mistaken, the Client should also have the same public interface as AbstractBrowser then. I'm not sure if that's worth it? Wouldn't it be against the intent of the original PR? It is possible though, rename AbstractBrowser back to Client. Create a new empty AbstractBrowser extending from Client. Then upon removal of Client drop AbstractBrowser and rename Client to AbstractBrowser. Bit cumbersome, but perhaps the safest way. |
nicolas-grekas commentedApr 9, 2019
It does have the same public interface, see its implementation, unless I missed something? |
Devristo commentedApr 10, 2019
I meant that all methods from AbstractBrowser have to be moved to Client if Client is the top of the hierarchy. Anyway, I am willing to do this. However I am not sure how deprecation will work. We cannot trigger an error in Client then as AbstractBrowser will depend on it? |
nicolas-grekas commentedApr 10, 2019
We will have to remove the deprecation notice and keep the annotation. DebugClassLoader will still warn ppl that extend Client directly. |
Devristo commentedApr 10, 2019
Sounds good. I think I have one last question concerning the deprecation messages. Currently the tests expect them on AbstractBrowser methods. If I alter the class hierarchy I can do three things:
I don't know how you guys usually solve this. I don't see evidence of variant 2 or 3 in the code base so far. Solution 1 is the way to go? Thanks for bearing with me and my questions 👍 |
nicolas-grekas commentedApr 10, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Option 1. makes the most sense to me: all existing code uses |
Devristo commentedApr 10, 2019
You are right :). I have pushed a separate commit with the changes we discussed. |
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedApr 15, 2019
Thank you@Devristo. |
… to Browser (Devristo)This PR was squashed before being merged into the 4.3-dev branch (closes#31040).Discussion----------[BrowserKit] Fixed BC-break introduced by rename of Client to Browser| Q | A| ------------- | ---| Branch? | master| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#31039| License | MIT| Doc PR |Since#30541 the inheritance hierarchy of `\Symfony\Component\BrowserKit\Client` has changed. Notably the test.client no longer is an instance of `\Symfony\Component\BrowserKit\Client`.This PR uses `class_alias` to fix the class hierarchy similarly as has been done in Twig. In this case I copied the approach of `Twig_TokenParser_AutoEscape` and `\Twig\TokenParser\AutoEscapeTokenParser`Commits-------6a94dea [BrowserKit] Fixed BC-break introduced by rename of Client to Browser
Uh oh!
There was an error while loading.Please reload this page.
Since#30541 the inheritance hierarchy of
\Symfony\Component\BrowserKit\Clienthas changed. Notably the test.client no longer is an instance of\Symfony\Component\BrowserKit\Client.This PR uses
class_aliasto fix the class hierarchy similarly as has been done in Twig. In this case I copied the approach ofTwig_TokenParser_AutoEscapeand\Twig\TokenParser\AutoEscapeTokenParser