Skip to content

Commit d0e5cd3

Browse files
authored
Fixed some code smell (#709)
* Fixed type issues * Fixed code smell
1 parent 87b7849 commit d0e5cd3

File tree

10 files changed

+13
-17
lines changed

10 files changed

+13
-17
lines changed

src/Common/Model/Address.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,7 @@ public static function createFromArray(array $data)
244244
continue;
245245
}
246246

247-
$adminLevels[] = new AdminLevel(
248-
$adminLevel['level'],
249-
$name,
250-
$adminLevel['code'] ?? null
251-
);
247+
$adminLevels[] = new AdminLevel($adminLevel['level'], $name, $adminLevel['code'] ?? null);
252248
}
253249

254250
return new static(

src/Common/Provider/AbstractProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
namespace Geocoder\Provider;
1414

15-
use Geocoder\Geocoder;
1615
use Geocoder\Location;
1716
use Geocoder\Model\Address;
1817

src/Common/StatefulGeocoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function geocodeQuery(GeocodeQuery $query): Collection
103103
$query = $query->withBounds($this->bounds);
104104
}
105105

106-
$this->provider->geocodeQuery($query);
106+
return $this->provider->geocodeQuery($query);
107107
}
108108

109109
/**
@@ -116,7 +116,7 @@ public function reverseQuery(ReverseQuery $query): Collection
116116
$query->withLocale($this->locale);
117117
}
118118

119-
$this->provider->reverseQuery($query);
119+
return $this->provider->reverseQuery($query);
120120
}
121121

122122
/**

src/Common/Tests/TimedGeocoderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TimedGeocoderTest extends TestCase
2626
private $stopwatch;
2727

2828
/**
29-
* @var Provider
29+
* @var Provider|\PHPUnit_Framework_MockObject_MockObject
3030
*/
3131
private $delegate;
3232

src/Provider/FreeGeoIp/FreeGeoIp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public function geocodeQuery(GeocodeQuery $query): Collection
5050
$data = json_decode($content, true);
5151
$builder = new AddressBuilder($this->getName());
5252

53-
if (!empty($data['region_name']) || !empty($data['region_code'])) {
54-
$builder->addAdminLevel(1, $data['region_name'] ?? null, $data['region_code'] ?? null);
53+
if (!empty($data['region_name'])) {
54+
$builder->addAdminLevel(1, $data['region_name'], $data['region_code'] ?? null);
5555
}
5656

5757
if ($data['latitude'] !== 0 || $data['longitude'] !== 0) {

src/Provider/GeoIP2/Tests/GeoIP2AdapterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414

1515
use Geocoder\Provider\GeoIP2\GeoIP2Adapter;
1616
use RuntimeException;
17+
use PHPUnit\Framework\TestCase;
1718

1819
/**
1920
* @author Jens Wiese <[email protected]>
2021
*/
21-
class GeoIP2AdapterTest extends \PHPUnit\Framework\TestCase
22+
class GeoIP2AdapterTest extends TestCase
2223
{
2324
/**
2425
* @var GeoIP2Adapter

src/Provider/Geonames/Geonames.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ private function executeQuery(string $url, string $locale = null): AddressCollec
139139
for ($level = 1; $level <= AdminLevelCollection::MAX_LEVEL_DEPTH; ++$level) {
140140
$adminNameProp = 'adminName'.$level;
141141
$adminCodeProp = 'adminCode'.$level;
142-
if (!empty($item->$adminNameProp) || !empty($item->$adminCodeProp)) {
143-
$builder->addAdminLevel($level, $item->$adminNameProp ?? null, $item->$adminCodeProp ?? null);
142+
if (!empty($item->$adminNameProp)) {
143+
$builder->addAdminLevel($level, $item->$adminNameProp, $item->$adminCodeProp ?? null);
144144
}
145145
}
146146

src/Provider/GoogleMaps/Tests/GoogleMapsTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Geocoder\Exception\InvalidServerResponse;
1616
use Geocoder\IntegrationTest\BaseTestCase;
1717
use Geocoder\Location;
18+
use Geocoder\Provider\GoogleMaps\Model\GoogleAddress;
1819
use Geocoder\Query\GeocodeQuery;
1920
use Geocoder\Query\ReverseQuery;
2021
use Geocoder\Provider\GoogleMaps\GoogleMaps;
@@ -304,7 +305,7 @@ public function testGeocodeWithSupremise()
304305
$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
305306
$this->assertCount(1, $results);
306307

307-
/** @var Location $result */
308+
/** @var GoogleAddress $result */
308309
$result = $results->first();
309310
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
310311
$this->assertEquals('61', $result->getSubpremise());

src/Provider/Nominatim/Nominatim.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ public function reverseQuery(ReverseQuery $query): Collection
127127
private function xmlResultToArray(\DOMElement $resultNode, \DOMElement $addressNode): Location
128128
{
129129
$builder = new AddressBuilder($this->getName());
130-
$adminLevels = [];
131130

132131
foreach (['state', 'county'] as $i => $tagName) {
133132
if (null !== ($adminLevel = $this->getNodeValue($addressNode->getElementsByTagName($tagName)))) {

src/Provider/TomTom/Tests/TomTomTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function testGeocodeWithIPv6()
124124
*/
125125
public function testWithoutApiKey()
126126
{
127-
$provider = new TomTom($this->getMockedHttpClient(), '');
127+
new TomTom($this->getMockedHttpClient(), '');
128128
}
129129

130130
/**

0 commit comments

Comments
 (0)