From 1e9cd621eae3b0d76851fe37cc7bad7d5a6f8a2d Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Wed, 18 Nov 2026 00:21:27 +0100 Subject: [PATCH 1/8] Use strict in_array --- DeviceDetector.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DeviceDetector.php b/DeviceDetector.php index c13aaae02d..8ffc1c460c 100644 --- a/DeviceDetector.php +++ b/DeviceDetector.php @@ -936,7 +936,7 @@ protected function parseDevice(): void /** * if it's fake UA then it's best not to identify it as Apple running Android OS or GNU/Linux */ - if ('Apple' === $this->brand && !\in_array($osName, $appleOsNames)) { + if ('Apple' === $this->brand && !\in_array($osName, $appleOsNames, true)) { $this->device = null; $this->brand = ''; $this->model = ''; @@ -945,7 +945,7 @@ protected function parseDevice(): void /** * Assume all devices running iOS / Mac OS are from Apple */ - if ('' === $this->brand && \in_array($osName, $appleOsNames)) { + if ('' === $this->brand && \in_array($osName, $appleOsNames, true)) { $this->brand = 'Apple'; } @@ -1137,7 +1137,7 @@ protected function parseDevice(): void 'Kylo', 'Espial TV Browser', 'LUJO TV Browser', 'LogicUI TV Browser', 'Open TV Browser', 'Seraphic Sraf', 'Opera Devices', 'Crow Browser', 'Vewd Browser', 'TiviMate', 'Quick Search TV', 'QJY TV Browser', 'TV Bro', 'Redline', 'Odin', - ]) + ], true) ) { $this->device = AbstractDeviceParser::DEVICE_TYPE_TV; } From ebc2641f9b42f47f856962d2baed4ef72a69eda8 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Wed, 18 Nov 2026 00:28:26 +0100 Subject: [PATCH 2/8] Simplify return --- Tests/DeviceDetectorTest.php | 4 +--- Tests/Parser/Client/BrowserTest.php | 4 +--- Tests/Parser/Client/FeedReaderTest.php | 4 +--- Tests/Parser/Client/LibraryTest.php | 4 +--- Tests/Parser/Client/MediaPlayerTest.php | 4 +--- Tests/Parser/Client/MobileAppTest.php | 4 +--- Tests/Parser/Client/PIMTest.php | 4 +--- Tests/Parser/Device/CameraTest.php | 4 +--- Tests/Parser/Device/CarBrowserTest.php | 4 +--- Tests/Parser/Device/ConsoleTest.php | 4 +--- Tests/Parser/Device/NotebookTest.php | 4 +--- Tests/Parser/OperatingSystemTest.php | 4 +--- 12 files changed, 12 insertions(+), 36 deletions(-) diff --git a/Tests/DeviceDetectorTest.php b/Tests/DeviceDetectorTest.php index 4179aa260c..208a27af53 100644 --- a/Tests/DeviceDetectorTest.php +++ b/Tests/DeviceDetectorTest.php @@ -708,11 +708,9 @@ public static function getTypeMethodFixtures(): array { $fixtureData = \Spyc::YAMLLoad(\realpath(__DIR__ . '/Parser/fixtures/type-methods.yml')); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['ua' => $item['user_agent'], 'checkTypes' => $item['check']]; }, $fixtureData); - - return $fixtureData; } /** diff --git a/Tests/Parser/Client/BrowserTest.php b/Tests/Parser/Client/BrowserTest.php index 98d6fab08a..6bb1092421 100644 --- a/Tests/Parser/Client/BrowserTest.php +++ b/Tests/Parser/Client/BrowserTest.php @@ -55,11 +55,9 @@ public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/browser.yml'); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['useragent' => $item['user_agent'], 'client' => $item['client'], 'headers' => $item['headers'] ?? null]; }, $fixtureData); - - return $fixtureData; } public function testGetAvailableBrowserFamilies(): void diff --git a/Tests/Parser/Client/FeedReaderTest.php b/Tests/Parser/Client/FeedReaderTest.php index 07382f5191..c61fe8562a 100644 --- a/Tests/Parser/Client/FeedReaderTest.php +++ b/Tests/Parser/Client/FeedReaderTest.php @@ -35,11 +35,9 @@ public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/feed_reader.yml'); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['useragent' => $item['user_agent'], 'client' => $item['client']]; }, $fixtureData); - - return $fixtureData; } public function testStructureFeedReaderYml(): void diff --git a/Tests/Parser/Client/LibraryTest.php b/Tests/Parser/Client/LibraryTest.php index 9becb9e8c6..83dd953174 100644 --- a/Tests/Parser/Client/LibraryTest.php +++ b/Tests/Parser/Client/LibraryTest.php @@ -35,11 +35,9 @@ public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/library.yml'); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['useragent' => $item['user_agent'], 'client' => $item['client']]; }, $fixtureData); - - return $fixtureData; } public function testStructureLibraryYml(): void diff --git a/Tests/Parser/Client/MediaPlayerTest.php b/Tests/Parser/Client/MediaPlayerTest.php index 6b1c1254ac..d6233e43c5 100644 --- a/Tests/Parser/Client/MediaPlayerTest.php +++ b/Tests/Parser/Client/MediaPlayerTest.php @@ -35,11 +35,9 @@ public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/mediaplayer.yml'); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['useragent' => $item['user_agent'], 'client' => $item['client']]; }, $fixtureData); - - return $fixtureData; } public function testStructureMediaPlayerYml(): void diff --git a/Tests/Parser/Client/MobileAppTest.php b/Tests/Parser/Client/MobileAppTest.php index 7d748fb5a0..c35b6da036 100644 --- a/Tests/Parser/Client/MobileAppTest.php +++ b/Tests/Parser/Client/MobileAppTest.php @@ -35,11 +35,9 @@ public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/mobile_app.yml'); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['useragent' => $item['user_agent'], 'client' => $item['client']]; }, $fixtureData); - - return $fixtureData; } public function testStructureMobileAppYml(): void diff --git a/Tests/Parser/Client/PIMTest.php b/Tests/Parser/Client/PIMTest.php index ccf573da22..141c392029 100644 --- a/Tests/Parser/Client/PIMTest.php +++ b/Tests/Parser/Client/PIMTest.php @@ -35,11 +35,9 @@ public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/pim.yml'); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['useragent' => $item['user_agent'], 'client' => $item['client']]; }, $fixtureData); - - return $fixtureData; } public function testStructurePimYml(): void diff --git a/Tests/Parser/Device/CameraTest.php b/Tests/Parser/Device/CameraTest.php index 2ed16334f4..cf08484dd3 100644 --- a/Tests/Parser/Device/CameraTest.php +++ b/Tests/Parser/Device/CameraTest.php @@ -37,10 +37,8 @@ public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/camera.yml'); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['useragent' => $item['user_agent'], 'device' => $item['device']]; }, $fixtureData); - - return $fixtureData; } } diff --git a/Tests/Parser/Device/CarBrowserTest.php b/Tests/Parser/Device/CarBrowserTest.php index 6ba84987d9..0732c268fb 100644 --- a/Tests/Parser/Device/CarBrowserTest.php +++ b/Tests/Parser/Device/CarBrowserTest.php @@ -37,10 +37,8 @@ public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/car_browser.yml'); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['useragent' => $item['user_agent'], 'device' => $item['device']]; }, $fixtureData); - - return $fixtureData; } } diff --git a/Tests/Parser/Device/ConsoleTest.php b/Tests/Parser/Device/ConsoleTest.php index 925e850a11..c9beaf1a13 100644 --- a/Tests/Parser/Device/ConsoleTest.php +++ b/Tests/Parser/Device/ConsoleTest.php @@ -37,10 +37,8 @@ public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/console.yml'); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['useragent' => $item['user_agent'], 'device' => $item['device']]; }, $fixtureData); - - return $fixtureData; } } diff --git a/Tests/Parser/Device/NotebookTest.php b/Tests/Parser/Device/NotebookTest.php index 196566256e..2d851e29c1 100644 --- a/Tests/Parser/Device/NotebookTest.php +++ b/Tests/Parser/Device/NotebookTest.php @@ -37,10 +37,8 @@ public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/notebook.yml'); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['useragent' => $item['user_agent'], 'device' => $item['device']]; }, $fixtureData); - - return $fixtureData; } } diff --git a/Tests/Parser/OperatingSystemTest.php b/Tests/Parser/OperatingSystemTest.php index e3f768e2a1..944b1218e9 100644 --- a/Tests/Parser/OperatingSystemTest.php +++ b/Tests/Parser/OperatingSystemTest.php @@ -44,11 +44,9 @@ public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/oss.yml'); - $fixtureData = \array_map(static function (array $item): array { + return \array_map(static function (array $item): array { return ['useragent' => $item['user_agent'], 'os' => $item['os'], 'headers' => $item['headers'] ?? null]; }, $fixtureData); - - return $fixtureData; } /** From 90346a17743d64b0c59029fa1b39a13472b2b142 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Wed, 18 Nov 2026 00:32:53 +0100 Subject: [PATCH 3/8] Remove sprintf - replaces a single value --- misc/statistics.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/statistics.php b/misc/statistics.php index 94441398c8..8f0eaa7e3d 100644 --- a/misc/statistics.php +++ b/misc/statistics.php @@ -100,7 +100,7 @@ function format($str, $length): string foreach ($deviceTypes as $deviceTypeId => $deviceCount) { $reportStat[] = sprintf( $mask, - sprintf('%s', mb_convert_case($deviceAvailableDeviceTypes[$deviceTypeId], MB_CASE_TITLE)), + mb_convert_case($deviceAvailableDeviceTypes[$deviceTypeId], MB_CASE_TITLE), format($deviceCount, $parsedUAs), sprintf('(%s%%)', trim(getPercentage($deviceCount, $parsedUAs))) ); From c9907c0f519814c9ff8b7b2d5a85068999299259 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Wed, 18 Nov 2026 00:37:45 +0100 Subject: [PATCH 4/8] Remove compact and use explicit array --- Parser/OperatingSystem.php | 2 +- Tests/Parser/Client/BrowserTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Parser/OperatingSystem.php b/Parser/OperatingSystem.php index 5cb9f2739c..439da9c493 100644 --- a/Parser/OperatingSystem.php +++ b/Parser/OperatingSystem.php @@ -429,7 +429,7 @@ public static function getShortOsData(string $name): array break; } - return \compact('short', 'name'); + return ['short' => $short, 'name' => $name]; } /** diff --git a/Tests/Parser/Client/BrowserTest.php b/Tests/Parser/Client/BrowserTest.php index 6bb1092421..0ecdc62545 100644 --- a/Tests/Parser/Client/BrowserTest.php +++ b/Tests/Parser/Client/BrowserTest.php @@ -154,7 +154,7 @@ public static function getFixturesBrowserHints(): array $fixtures = []; foreach ($hints as $name) { - $fixtures[] = \compact('name'); + $fixtures[] = ['name' => $name]; } return $fixtures; From 661c5dff5c01b93e2c273937a89520e7296b82a6 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Wed, 18 Nov 2026 00:42:34 +0100 Subject: [PATCH 5/8] Add return type --- Tests/DeviceDetectorTest.php | 2 +- Tests/Parser/OperatingSystemTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/DeviceDetectorTest.php b/Tests/DeviceDetectorTest.php index 208a27af53..5c2439002b 100644 --- a/Tests/DeviceDetectorTest.php +++ b/Tests/DeviceDetectorTest.php @@ -609,7 +609,7 @@ public static function getBotFixtures(): array $fixturesPath = \realpath(__DIR__ . '/fixtures/bots.yml'); $fixtures = \Spyc::YAMLLoad($fixturesPath); - return \array_map(static function ($elem) { + return \array_map(static function ($elem): array { return [$elem]; }, $fixtures); } diff --git a/Tests/Parser/OperatingSystemTest.php b/Tests/Parser/OperatingSystemTest.php index 944b1218e9..765cae30a0 100644 --- a/Tests/Parser/OperatingSystemTest.php +++ b/Tests/Parser/OperatingSystemTest.php @@ -63,7 +63,7 @@ public static function getAllOs(): array { $allOs = \array_keys(OperatingSystem::getAvailableOperatingSystems()); - return \array_map(static function ($os) { + return \array_map(static function ($os): array { return [$os]; }, $allOs); } @@ -82,7 +82,7 @@ public static function getAllFamilyOs(): array { $allFamilyOs = \call_user_func_array('array_merge', \array_values(OperatingSystem::getAvailableOperatingSystemFamilies())); - return \array_map(static function ($os) { + return \array_map(static function ($os): array { return [$os]; }, $allFamilyOs); } From b2a63f70ffb3dbc502ba461c097a0846aba2191c Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Wed, 18 Nov 2026 00:46:17 +0100 Subject: [PATCH 6/8] Simplify check --- ClientHints.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ClientHints.php b/ClientHints.php index 61e6391d81..e7926642ce 100644 --- a/ClientHints.php +++ b/ClientHints.php @@ -325,7 +325,7 @@ public static function factory(array $headers): ClientHints break; case 'brands': - if (!empty($fullVersionList)) { + if ([] !== $fullVersionList) { break; } @@ -336,7 +336,7 @@ public static function factory(array $headers): ClientHints break; case 'http-sec-ch-ua': case 'sec-ch-ua': - if (!empty($fullVersionList)) { + if ([] !== $fullVersionList) { break; } From 3ef8c466fac1d7f550e42966f5810b05415d993e Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Wed, 18 Nov 2026 00:58:55 +0100 Subject: [PATCH 7/8] Add newline before new assignment --- DeviceDetector.php | 1 + Tests/DeviceDetectorTest.php | 1 + 2 files changed, 2 insertions(+) diff --git a/DeviceDetector.php b/DeviceDetector.php index 8ffc1c460c..1d6b638b33 100644 --- a/DeviceDetector.php +++ b/DeviceDetector.php @@ -1177,6 +1177,7 @@ protected function parseOs(): void $osParser->setClientHints($this->getClientHints()); $osParser->setYamlParser($this->getYamlParser()); $osParser->setCache($this->getCache()); + $this->os = $osParser->parse(); } diff --git a/Tests/DeviceDetectorTest.php b/Tests/DeviceDetectorTest.php index 5c2439002b..0bb674d7b4 100644 --- a/Tests/DeviceDetectorTest.php +++ b/Tests/DeviceDetectorTest.php @@ -187,6 +187,7 @@ public function testCacheSetAndGet(): void $memcached = new \Memcached(); $doctrineCache = new MemcachedCache(); $doctrineCache->setMemcached($memcached); + $dd->setCache(new DoctrineBridge($doctrineCache)); $this->assertInstanceOf(DoctrineBridge::class, $dd->getCache()); } From ece5d7cc7bfef5d712ddd4566a13f83e22234bb5 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Wed, 18 Nov 2026 01:25:28 +0100 Subject: [PATCH 8/8] Improve code - now are also sorted --- misc/generateBrandIdFree.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/misc/generateBrandIdFree.php b/misc/generateBrandIdFree.php index 61421f5fb5..307acc2589 100644 --- a/misc/generateBrandIdFree.php +++ b/misc/generateBrandIdFree.php @@ -12,17 +12,17 @@ exit(0); } -$mapIds = []; // create map (max 1296) -$c = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +$chars = array_merge( + range('0', '9'), + range('A', 'Z') +); -for ($n = 65; $n < 123; $n++) { - $n < 91 || $n > 96 and $c[] = chr($n); -} +$mapIds = []; -for ($y = 0; $y < 36; $y++) { - for ($x = 0; $x < 36; $x++) { - $mapIds[] = sprintf('%s%s', $c[$x], $c[$y]); +foreach ($chars as $first) { + foreach ($chars as $second) { + $mapIds[] = $first . $second; } }