Call parse() whenever it's required
The intention is to avoid missing the parser() call.
I didn't found if this subject was already discussed in this project.
I'm aware that this may be a BC break for some, as an alternative solution, we could throw an exception (still a potential BC break), or trigger an error (less intrusive) if the user-agent was not yet parsed when calling these functions.
These two tests fail because they test exactly the opposite of the intention of this PR:
- DeviceDetector\Tests\DeviceDetectorTest::testGetOs
- DeviceDetector\Tests\DeviceDetectorTest::testGetClient
I can adapt it if the idea of the PR gets accepted.
Hello, just giving you an update on this.
We solved the issue on our side by proxying DeviceDetector
Implementation details: https://github.com/acsiomatic/device-detector-bundle/pull/18
@renanbr thanks for the update. That sounds like a better solution. Even though some users might expect an automatic parse if methods that require a parse are called, but there might also be cases where that should not happen. Especially when you let your own classes inherit from DeviceDetector in order to replace some parts. Not doing the parse makes it more flexible. I'll close this PR then.