Skip to content

Commit bca8e03

Browse files
committed
Fixed PHPStan issues.
Fixed a test. Updated dependencies.
1 parent 2b7b6ae commit bca8e03

8 files changed

Lines changed: 359 additions & 349 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"classmap": ["src/", "tests/"]
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "10.1.2",
23+
"phpunit/phpunit": "^12.5.8",
2424
"phpstan/phpstan": "^1.10"
2525
}
2626
}

composer.lock

Lines changed: 347 additions & 338 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/agentzero.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,13 @@ public static function parse(string $ua, array $hints = [], array $config = [])
248248
// get tokens
249249
} elseif (($tokens = self::getTokens(\trim($hinted, ' "\''), $config['single'], $config['ignore'])) !== false) {
250250

251+
// lowercase the tokens
252+
$tokenslower = [];
253+
foreach ($tokens AS $key => $item) {
254+
$tokenslower[$key] = $item;
255+
}
256+
251257
// extract UA info
252-
$tokenslower = \array_map('\\mb_strtolower', $tokens);
253258
foreach ($config['match'] AS $key => $item) {
254259
$item->match($browser, $key, $tokens, $tokenslower, $config);
255260
}

src/helpers/hints.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ public static function parse(string &$ua, array $hints) : \stdClass {
3535
'10.21H2'
3636
];
3737
$major = \intval($value);
38-
if (isset($map[$major])) {
39-
$value = $map[$major] ?? '11';
40-
}
38+
$value = $map[$major] ?? '11';
4139
}
4240
$obj->platformversion = $value ?: null;
4341
},

src/helpers/versions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static function get(string $browser, string $version, array $config) : ar
139139
$data['browserreleased'] = self::released($versions[$browser], $version);
140140

141141
// calculate status
142-
if (isset($data['browserreleased'], $data['browserlatest'])) {
142+
if ($data['browserreleased'] !== null) {
143143
$current = \explode('.', $data['browserlatest'])[0] === \explode('.', $version)[0];
144144
$released = new \DateTime($data['browserreleased']);
145145

src/mappings/apps.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,13 @@ public static function get() : array {
321321
'vendor' => devices::getVendor(\mb_substr($value, 5))
322322
]),
323323
'FBDV/' => new props('start', fn (string $value) : array => \array_merge(
324-
devices::getDevice(\mb_substr($value, 5))),
324+
devices::getDevice(\mb_substr($value, 5)),
325325
[
326326
'type' => 'human',
327327
'app' => 'Facebook',
328328
'appname' => 'Facebook'
329329
]
330-
),
330+
)),
331331
'FBMD/' => new props('start', fn (string $value) : array => [
332332
'type' => 'human',
333333
'app' => 'Facebook',

src/mappings/crawlers.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ public static function getApp(string $value, array $data = []) : array {
101101
'sbintuitionsbot' => 'ai',
102102
'sidetradebot' => 'ai',
103103
'thinkbot' => 'ai',
104-
'ai2bot' => 'ai',
105104
'timpibot' => 'ai',
106105
'wardbot' => 'monitor'
107106
];
@@ -388,7 +387,6 @@ public static function get() : array {
388387
'Site24x7' => new props('exact', $fn['monitor']),
389388
'StatusCake' => new props('exact', $fn['monitor']),
390389
'AWS Network Health' => new props('start', $fn['monitor']),
391-
'StatusCake' => new props('exact', $fn['monitor']),
392390
'adbeat.com' => new props('start', fn (string $value) : array => [
393391
'type' => 'robot',
394392
'category' => 'ads',

tests/browsersTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ public function testBrave() : void {
500500
'engineversion' => '601.1.46',
501501
'browser' => 'Brave',
502502
'browserversion' => '1.2.11',
503-
'browserreleased' => '2026-03-19'
503+
'browserreleased' => '2026-04-08'
504504
],
505505
'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_4_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Brave/115.0.0.0 Safari/605.1.15' => [
506506
'string' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_4_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Brave/115.0.0.0 Safari/605.1.15',

0 commit comments

Comments
 (0)