Skip to content

Commit f9c2e91

Browse files
committed
Fix deprecation, warning, and notice messages
1 parent 100c458 commit f9c2e91

5 files changed

Lines changed: 33 additions & 14 deletions

File tree

src/Details.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@ class Details
3232
public $abuse;
3333
public $domains;
3434
public $bogon;
35+
public $is_anycast;
36+
public $is_mobile;
37+
public $is_anonymous;
38+
public $is_satellite;
39+
public $is_hosting;
40+
public $name;
41+
public $allocated;
42+
public $registry;
43+
public $domain;
44+
public $num_ips;
45+
public $type;
46+
public $prefixes;
47+
public $prefixes6;
48+
public $peers;
49+
public $upstreams;
50+
public $downstreams;
3551
public $all;
3652

3753
public function __construct($raw_details)

src/DetailsCore.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class DetailsCore
1616
public $is_mobile;
1717
public $is_satellite;
1818
public $bogon;
19+
public $hostname;
20+
public $mobile;
21+
public $anonymous;
1922
public $all;
2023

2124
public function __construct($raw_details)

src/IPinfo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function getBatchDetails(
181181

182182
public function formatDetailsObject($details = [])
183183
{
184-
$country = $details['country'] ?? null;
184+
$country = $details['country'] ?? '';
185185
$details['country_name'] = $this->countries[$country] ?? null;
186186
$details['is_eu'] = in_array($country, $this->eu_countries);
187187
$details['country_flag'] = $this->countries_flags[$country] ?? null;
@@ -330,7 +330,7 @@ public function getMapUrl($ips)
330330
}
331331

332332
$res = json_decode($response->getBody(), true);
333-
return $res['reportUrl'];
333+
return $res['reportUrl'] ?? null;
334334
}
335335

336336
/**

src/IPinfoLite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function getDetails($ip_address = null)
105105

106106
public function formatDetailsObject($details = [])
107107
{
108-
$country_code = $details["country_code"] ?? null;
108+
$country_code = $details["country_code"] ?? '';
109109
$details["country_name"] = $details["country"] ?? null;
110110
$details["is_eu"] = in_array($country_code, $this->eu_countries);
111111
$details["country_flag"] =

tests/IPinfoTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public function testIPv6NotationsCaching()
367367
// Replace the real Guzzle client with our mock
368368
$reflectionClass = new \ReflectionClass($h);
369369
$reflectionProperty = $reflectionClass->getProperty('http_client');
370-
$reflectionProperty->setAccessible(true);
370+
371371
$reflectionProperty->setValue($h, $mock_guzzle);
372372

373373
// Different notations of the same IPv6 address
@@ -415,26 +415,26 @@ public function testResproxy()
415415
$h = new IPinfo("test_token");
416416
$ip = "175.107.211.204";
417417

418-
// Create a mock stream for the response body
419-
$mockStream = $this->createMock(\Psr\Http\Message\StreamInterface::class);
418+
// Create a stub stream for the response body
419+
$mockStream = $this->createStub(\Psr\Http\Message\StreamInterface::class);
420420
$mockStream->method("__toString")->willReturn(json_encode([
421421
"ip" => "175.107.211.204",
422422
"last_seen" => "2025-01-20",
423423
"percent_days_seen" => 0.85,
424424
"service" => "example_service"
425425
]));
426426

427-
$mockResponse = $this->createMock(\GuzzleHttp\Psr7\Response::class);
427+
$mockResponse = $this->createStub(\GuzzleHttp\Psr7\Response::class);
428428
$mockResponse->method("getStatusCode")->willReturn(200);
429429
$mockResponse->method("getBody")->willReturn($mockStream);
430430

431-
$mockClient = $this->createMock(\GuzzleHttp\Client::class);
431+
$mockClient = $this->createStub(\GuzzleHttp\Client::class);
432432
$mockClient->method("request")->willReturn($mockResponse);
433433

434434
// Use reflection to replace the http_client
435435
$reflectionClass = new \ReflectionClass($h);
436436
$reflectionProperty = $reflectionClass->getProperty("http_client");
437-
$reflectionProperty->setAccessible(true);
437+
438438
$reflectionProperty->setValue($h, $mockClient);
439439

440440
$res = $h->getResproxy($ip);
@@ -448,21 +448,21 @@ public function testResproxyEmpty()
448448
{
449449
$h = new IPinfo("test_token");
450450

451-
// Create a mock stream for the response body
452-
$mockStream = $this->createMock(\Psr\Http\Message\StreamInterface::class);
451+
// Create a stub stream for the response body
452+
$mockStream = $this->createStub(\Psr\Http\Message\StreamInterface::class);
453453
$mockStream->method("__toString")->willReturn("{}");
454454

455-
$mockResponse = $this->createMock(\GuzzleHttp\Psr7\Response::class);
455+
$mockResponse = $this->createStub(\GuzzleHttp\Psr7\Response::class);
456456
$mockResponse->method("getStatusCode")->willReturn(200);
457457
$mockResponse->method("getBody")->willReturn($mockStream);
458458

459-
$mockClient = $this->createMock(\GuzzleHttp\Client::class);
459+
$mockClient = $this->createStub(\GuzzleHttp\Client::class);
460460
$mockClient->method("request")->willReturn($mockResponse);
461461

462462
// Use reflection to replace the http_client
463463
$reflectionClass = new \ReflectionClass($h);
464464
$reflectionProperty = $reflectionClass->getProperty("http_client");
465-
$reflectionProperty->setAccessible(true);
465+
466466
$reflectionProperty->setValue($h, $mockClient);
467467

468468
$res = $h->getResproxy("8.8.8.8");

0 commit comments

Comments
 (0)