Skip to content

Commit 20ebbee

Browse files
committed
Fixed php warnings and ran linter
1 parent 7d241b9 commit 20ebbee

11 files changed

Lines changed: 27 additions & 33 deletions

File tree

composer.json

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "ready2order/user-agent-parser",
3-
43
"description": "UserAgent parsing done right http://useragent.mkf.solutions/",
54
"keywords": [
65
"UA",
@@ -9,13 +8,11 @@
98
"User agent",
109
"User agent parser",
1110
"User agent detection",
12-
"UserAgent",
11+
"UserAgent",
1312
"UserAgentParser",
14-
1513
"Sniffing",
16-
"Parser",
14+
"Parser",
1715
"Detection",
18-
1916
"Browser",
2017
"Engine",
2118
"Rendering engine",
@@ -26,8 +23,7 @@
2623
"mobile detection",
2724
"mobile detector",
2825
"mobile device detection",
29-
"bot detection",
30-
26+
"bot detection",
3127
"get_browser",
3228
"browscap",
3329
"donatj",
@@ -38,42 +34,36 @@
3834
"whichbrowser",
3935
"woothee",
4036
"wurfl",
41-
4237
"DeviceAtlas",
4338
"NeutrinoApiCom",
4439
"UdgerCom",
4540
"UserAgentApiCom",
4641
"UserAgentStringCom",
4742
"WhatIsMyBrowserCom"
4843
],
49-
5044
"license": "MIT",
5145
"authors": [
5246
{
5347
"name": "ThaDafinser",
5448
"email": "martin.keckeis1@gmail.com"
5549
}
5650
],
57-
5851
"autoload": {
5952
"psr-4": {
60-
"UserAgentParser\\": "src"
53+
"UserAgentParser\\": "src"
6154
}
6255
},
63-
6456
"autoload-dev": {
6557
"psr-4": {
66-
"UserAgentParserTest\\Unit\\": "tests/unit",
67-
"UserAgentParserTest\\Integration\\": "tests/integration"
58+
"UserAgentParserTest\\Unit\\": "tests/unit",
59+
"UserAgentParserTest\\Integration\\": "tests/integration"
6860
}
6961
},
70-
7162
"require": {
7263
"php": "^7.4|^8.0",
73-
"guzzlehttp/guzzle": "^6.1",
64+
"guzzlehttp/guzzle": "^7.9",
7465
"composer-runtime-api": "^2.0"
7566
},
76-
7767
"conflict": {
7868
"browscap/browscap-php": "^5.0",
7969
"donatj/phpuseragentparser": "<0.5,>=1",
@@ -87,7 +77,6 @@
8777
"mimmi20/wurfl": "<1.6.4,>=2",
8878
"zsxsoft/php-useragent": "<1.2,>=2"
8979
},
90-
9180
"suggest": {
9281
"browscap/browscap-php": "Needed to use Provider\\BrowscapPhp",
9382
"donatj/phpuseragentparser": "Needed to use Provider\\DonatjUAParser",
@@ -102,7 +91,6 @@
10291
"mimmi20/wurfl": "Needed to use Provider\\Wurfl",
10392
"zsxsoft/php-useragent": "Needed to use Provider\\Zsxsoft"
10493
},
105-
10694
"require-dev": {
10795
"phpunit/phpunit": "^9.5",
10896
"friendsofphp/php-cs-fixer": "^2.17.3",
@@ -119,5 +107,11 @@
119107
"woothee/woothee": "^1.2",
120108
"mimmi20/wurfl": "^1.7.1.1",
121109
"zsxsoft/php-useragent": ">=1.2,<1.4"
110+
},
111+
"config": {
112+
"preferred-install": "dist",
113+
"platform": {
114+
"php": "7.4.0"
115+
}
122116
}
123117
}

src/Model/Version.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function setComplete($complete)
140140
{
141141
// check if the version has only 0 -> so no real result
142142
// maybe move this out to the Providers itself?
143-
$left = preg_replace('/[0._]/', '', (string)$complete);
143+
$left = preg_replace('/[0._]/', '', (string) $complete);
144144
if ($left === '') {
145145
$complete = null;
146146
}
@@ -226,7 +226,7 @@ private function getCompleteParts($complete)
226226
];
227227

228228
// only digits
229-
preg_match('/\\d+(?:[._]*\\d*)*/', (string)$complete, $result);
229+
preg_match('/\\d+(?:[._]*\\d*)*/', (string) $complete, $result);
230230
if (\count($result) > 0) {
231231
$parts = preg_split('/[._]/', $result[0]);
232232

@@ -242,7 +242,7 @@ private function getCompleteParts($complete)
242242
}
243243

244244
// grab alias
245-
$result = preg_split('/\\d+(?:[._]*\\d*)*/', (string)$complete);
245+
$result = preg_split('/\\d+(?:[._]*\\d*)*/', (string) $complete);
246246
foreach ($result as $row) {
247247
$row = trim($row);
248248

src/Provider/Http/AbstractHttpProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function getResponse(RequestInterface $request)
4646
// @var $response \GuzzleHttp\Psr7\Response
4747
$response = $this->getClient()->send($request);
4848
} catch (GuzzleHttpException $ex) {
49-
throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '"', null, $ex);
49+
throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '"', 0, $ex);
5050
}
5151

5252
if ($response->getStatusCode() !== 200) {

src/Provider/Http/DeviceAtlasCom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected function getResult($userAgent, array $headers)
122122
$prevEx = $ex->getPrevious();
123123

124124
if ($prevEx->hasResponse() === true && $prevEx->getResponse()->getStatusCode() === 403) {
125-
throw new Exception\InvalidCredentialsException('Your API key "' . $this->apiKey . '" is not valid for ' . $this->getName(), null, $ex);
125+
throw new Exception\InvalidCredentialsException('Your API key "' . $this->apiKey . '" is not valid for ' . $this->getName(), 0, $ex);
126126
}
127127

128128
throw $ex;

src/Provider/Http/FiftyOneDegreesCom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected function getResult($userAgent, array $headers)
141141
$prevEx = $ex->getPrevious();
142142

143143
if ($prevEx->hasResponse() === true && $prevEx->getResponse()->getStatusCode() === 403) {
144-
throw new Exception\InvalidCredentialsException('Your API key "' . $this->apiKey . '" is not valid for ' . $this->getName(), null, $ex);
144+
throw new Exception\InvalidCredentialsException('Your API key "' . $this->apiKey . '" is not valid for ' . $this->getName(), 0, $ex);
145145
}
146146

147147
throw $ex;

src/Provider/Http/NeutrinoApiCom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ protected function getResult($userAgent, array $headers)
168168
$prevEx = $ex->getPrevious();
169169

170170
if ($prevEx->hasResponse() === true && $prevEx->getResponse()->getStatusCode() === 403) {
171-
throw new Exception\InvalidCredentialsException('Your API userId "' . $this->apiUserId . '" and key "' . $this->apiKey . '" is not valid for ' . $this->getName(), null, $ex);
171+
throw new Exception\InvalidCredentialsException('Your API userId "' . $this->apiUserId . '" and key "' . $this->apiKey . '" is not valid for ' . $this->getName(), 0, $ex);
172172
}
173173

174174
throw $ex;

src/Provider/Http/UdgerCom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function getResult($userAgent, array $headers)
127127
'uastrig' => $userAgent,
128128
];
129129

130-
$body = http_build_query($params, null, '&');
130+
$body = http_build_query($params, '', '&');
131131

132132
$request = new Request('POST', self::$uri, [
133133
'Content-Type' => 'application/x-www-form-urlencoded',

src/Provider/Http/UserAgentApiCom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected function getResult($userAgent, array $headers)
136136

137137
// Error
138138
if (isset($content->error->code) && $content->error->code == 'key_invalid') {
139-
throw new Exception\InvalidCredentialsException('Your API key "' . $this->apiKey . '" is not valid for ' . $this->getName(), null, $ex);
139+
throw new Exception\InvalidCredentialsException('Your API key "' . $this->apiKey . '" is not valid for ' . $this->getName(), 0, $ex);
140140
}
141141

142142
if (isset($content->error->code) && $content->error->code == 'useragent_invalid') {

tests/integration/Provider/Http/AbstractHttpProviderTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ protected function getClient()
4242
'timeout' => 5,
4343

4444
'curl' => [
45-
CURLOPT_SSL_VERIFYHOST => false,
46-
CURLOPT_SSL_VERIFYPEER => false,
45+
\CURLOPT_SSL_VERIFYHOST => false,
46+
\CURLOPT_SSL_VERIFYPEER => false,
4747
],
4848
]);
4949
}

tests/integration/Provider/JenssegersAgentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testRealResultBot()
7676
],
7777
'bot' => [
7878
'isBot' => true,
79-
'name' => 'Google',
79+
'name' => 'Googlebot',
8080
'type' => null,
8181
],
8282
], $result->toArray());

0 commit comments

Comments
 (0)