Skip to content

Commit fb6f392

Browse files
committed
Fix GeoipProvider and MaxMindBinaryProvider
Bad return in getGeocodedData()
1 parent 5d4db0d commit fb6f392

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/Geocoder/Provider/GeoipProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public function getGeocodedData($address)
5656
}
5757

5858
$timezone = @geoip_time_zone_by_country_and_region($results['country_code'], $results['region']) ?: null;
59-
$region = @geoip_region_name_by_code($results['country_code'], $results['region']) ?: $results['region'];
59+
$region = @geoip_region_name_by_code($results['country_code'], $results['region']) ?: $results['region'];
6060

61-
return $this->fixEncoding(array_merge($this->getDefaults(), array(
61+
return array($this->fixEncoding(array_merge($this->getDefaults(), array(
6262
'latitude' => $results['latitude'],
6363
'longitude' => $results['longitude'],
6464
'city' => $results['city'],
@@ -68,7 +68,7 @@ public function getGeocodedData($address)
6868
'country' => $results['country_name'],
6969
'countryCode' => $results['country_code'],
7070
'timezone' => $timezone,
71-
)));
71+
))));
7272
}
7373

7474
/**

src/Geocoder/Provider/MaxMindBinaryProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ public function getGeocodedData($address)
7575
throw new NoResultException(sprintf('No results found for IP address %s', $address));
7676
}
7777

78-
return $this->fixEncoding(array_merge($this->getDefaults(), array(
78+
return array($this->fixEncoding(array_merge($this->getDefaults(), array(
7979
'countryCode' => $geoIpRecord->country_code,
8080
'country' => $geoIpRecord->country_name,
8181
'region' => $geoIpRecord->region,
8282
'city' => $geoIpRecord->city,
8383
'latitude' => $geoIpRecord->latitude,
8484
'longitude' => $geoIpRecord->longitude,
85-
)));
85+
))));
8686
}
8787

8888
/**

tests/Geocoder/Tests/Provider/GeoipProviderTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public function testGetGeocodedDataWithAddress()
5555
public function testGetGeocodedDataWithLocalhostIPv4()
5656
{
5757
$provider = new GeoipProvider();
58-
$result = $provider->getGeocodedData('127.0.0.1');
58+
$results = $provider->getGeocodedData('127.0.0.1');
5959

60-
$this->assertInternalType('array', $result);
61-
$this->assertCount(1, $result);
60+
$this->assertInternalType('array', $results);
61+
$this->assertCount(1, $results);
6262

63-
$result = $result[0];
63+
$result = $results[0];
6464
$this->assertInternalType('array', $result);
6565
$this->assertArrayNotHasKey('latitude', $result);
6666
$this->assertArrayNotHasKey('longitude', $result);
@@ -86,12 +86,12 @@ public function testGetGeocodedDataWithLocalhostIPv6()
8686
public function testGetGeocodedDataWithRealIPv4()
8787
{
8888
$provider = new GeoipProvider();
89-
$result = $provider->getGeocodedData('74.200.247.59');
89+
$results = $provider->getGeocodedData('74.200.247.59');
9090

91-
$this->assertInternalType('array', $result);
92-
$this->assertCount(1, $result);
91+
$this->assertInternalType('array', $results);
92+
$this->assertCount(1, $results);
9393

94-
$result = $result[0];
94+
$result = $results[0];
9595
$this->assertInternalType('array', $result);
9696
$this->assertNotNull($result['latitude']);
9797
$this->assertNotNull($result['longitude']);

tests/Geocoder/Tests/Provider/MaxMindBinaryProviderTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public function testThrowIfNotExistBinaryFileGiven()
4747
public function testLocationResultContainsExpectedFields($ip)
4848
{
4949
$provider = new MaxMindBinaryProvider($this->binaryFile);
50-
$result = $provider->getGeocodedData($ip);
50+
$results = $provider->getGeocodedData($ip);
5151

52-
$this->assertInternalType('array', $result);
53-
$this->assertCount(1, $result);
52+
$this->assertInternalType('array', $results);
53+
$this->assertCount(1, $results);
5454

55-
$result = $result[0];
55+
$result = $results[0];
5656
$this->assertInternalType('array', $result);
5757

5858
$this->assertArrayHasKey('country', $result);
@@ -95,9 +95,9 @@ public function testFindLocationByIp($ip, $expectedCity, $expectedCountry)
9595
public function testShouldReturnResultsAsUtf8Encoded()
9696
{
9797
$provider = new MaxMindBinaryProvider($this->binaryFile);
98-
$result = $provider->getGeocodedData('212.51.181.237');
98+
$results = $provider->getGeocodedData('212.51.181.237');
9999

100-
$this->assertSame('Châlette-sur-loing', $result['city']);
100+
$this->assertSame('Châlette-sur-loing', $results[0]['city']);
101101
}
102102

103103
public function testGetName()

0 commit comments

Comments
 (0)