Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed version truncation so one client doesn't affect the others (mat…
…omo-org#6075) When `ParserAbstract::$maxMinorParts` is changed by any Client Parser, it is propagated to all Client Parsers. This happens because static properties defined ONLY in the parent class shares a common value with the child class. To set version truncation specifically for a custom ClientParser, we need to redefine `ParserAbstract::$maxMinorParts` in the child class and use late static binding to access the property. Example: ``` <?php use DeviceDetector\Parser\Client\ClientParserAbstract; class MyAppParser extends ClientParserAbstract{ protected static $maxMinorParts = self::VERSION_TRUNCATION_PATCH; protected $fixtureFile = 'my_app.yml'; protected $parserName = 'myapp'; protected function getRegexesDirectory(){ return __DIR__; } } ```` More on late static binding in PHP: https://www.php.net/manual/en/language.oop5.late-static-bindings.php Co-authored-by: Emmanuel Ogbodo <[email protected]> Co-authored-by: Stefan Giehl <[email protected]>
- Loading branch information