device-detector icon indicating copy to clipboard operation
device-detector copied to clipboard

Call parse() whenever it's required

Open renanbr opened this issue 5 years ago • 1 comments

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.

renanbr avatar Dec 06 '20 10:12 renanbr

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.

renanbr avatar Dec 06 '20 10:12 renanbr

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 avatar Feb 09 '23 20:02 renanbr

@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.

sgiehl avatar Feb 10 '23 14:02 sgiehl