Skip to content

Commit 1e9662b

Browse files
authored
Added PHP7 type hints (#639)
* Added return type hints * Added changelog
1 parent 0fc5b2f commit 1e9662b

15 files changed

+45
-44
lines changed

Collection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ interface Collection extends \IteratorAggregate, \Countable
2525
*
2626
* @throws CollectionIsEmpty
2727
*/
28-
public function first();
28+
public function first(): Location;
2929

3030
/**
3131
* @return bool
3232
*/
33-
public function isEmpty();
33+
public function isEmpty(): bool;
3434

3535
/**
3636
* @return Location[]
@@ -40,14 +40,14 @@ public function slice($offset, $length = null);
4040
/**
4141
* @return bool
4242
*/
43-
public function has($index);
43+
public function has($index): bool;
4444

4545
/**
4646
* @return Location
4747
*
4848
* @throws \OutOfBoundsException
4949
*/
50-
public function get($index);
50+
public function get($index): Location;
5151

5252
/**
5353
* @return Location[]

Geocoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ interface Geocoder extends Provider
3737
*
3838
* @throws \Geocoder\Exception\Exception
3939
*/
40-
public function geocode($value);
40+
public function geocode($value): Collection;
4141

4242
/**
4343
* Reverses geocode given latitude and longitude values.
@@ -49,5 +49,5 @@ public function geocode($value);
4949
*
5050
* @throws \Geocoder\Exception\Exception
5151
*/
52-
public function reverse($latitude, $longitude);
52+
public function reverse($latitude, $longitude): Collection;
5353
}

GeocoderTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ abstract public function reverseQuery(ReverseQuery $query);
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
public function geocode($value)
30+
public function geocode($value): Collection
3131
{
3232
return $this->geocodeQuery(GeocodeQuery::create($value));
3333
}
3434

3535
/**
3636
* {@inheritdoc}
3737
*/
38-
public function reverse($latitude, $longitude)
38+
public function reverse($latitude, $longitude): Collection
3939
{
4040
return $this->reverseQuery(ReverseQuery::fromCoordinates($latitude, $longitude));
4141
}

Location.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function getSubLocality();
8080
*
8181
* @return AdminLevelCollection
8282
*/
83-
public function getAdminLevels();
83+
public function getAdminLevels(): AdminLevelCollection;
8484

8585
/**
8686
* Returns the country value object.
@@ -103,5 +103,5 @@ public function getTimezone();
103103
*
104104
* @return array
105105
*/
106-
public function toArray();
106+
public function toArray(): array;
107107
}

Model/Address.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ class Address implements Location
8282
public function __construct(
8383
Coordinates $coordinates = null,
8484
Bounds $bounds = null,
85-
$streetNumber = null,
86-
$streetName = null,
87-
$postalCode = null,
88-
$locality = null,
89-
$subLocality = null,
85+
string $streetNumber = null,
86+
string $streetName = null,
87+
string $postalCode = null,
88+
string $locality = null,
89+
string $subLocality = null,
9090
AdminLevelCollection $adminLevels = null,
9191
Country $country = null,
92-
$timezone = null
92+
string $timezone = null
9393
) {
9494
$this->coordinates = $coordinates;
9595
$this->bounds = $bounds;
@@ -162,7 +162,7 @@ public function getSubLocality()
162162
/**
163163
* {@inheritdoc}
164164
*/
165-
public function getAdminLevels()
165+
public function getAdminLevels(): AdminLevelCollection
166166
{
167167
return $this->adminLevels;
168168
}
@@ -282,7 +282,7 @@ private static function createBounds($south, $west, $north, $east)
282282
/**
283283
* {@inheritdoc}
284284
*/
285-
public function toArray()
285+
public function toArray(): array
286286
{
287287
$adminLevels = [];
288288
foreach ($this->adminLevels as $adminLevel) {

Model/AddressCollection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function count()
4848
/**
4949
* {@inheritdoc}
5050
*/
51-
public function first()
51+
public function first(): Location
5252
{
5353
if (empty($this->locations)) {
5454
throw new CollectionIsEmpty();
@@ -60,7 +60,7 @@ public function first()
6060
/**
6161
* {@inheritdoc}
6262
*/
63-
public function isEmpty()
63+
public function isEmpty(): bool
6464
{
6565
return empty($this->locations);
6666
}
@@ -76,15 +76,15 @@ public function slice($offset, $length = null)
7676
/**
7777
* @return bool
7878
*/
79-
public function has($index)
79+
public function has($index): bool
8080
{
8181
return isset($this->locations[$index]);
8282
}
8383

8484
/**
8585
* {@inheritdoc}
8686
*/
87-
public function get($index)
87+
public function get($index): Location
8888
{
8989
if (!isset($this->locations[$index])) {
9090
throw new \OutOfBoundsException(sprintf('The index "%s" does not exist in this collection.', $index));

Model/AdminLevel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ final class AdminLevel
2626
private $name;
2727

2828
/**
29-
* @var string
29+
* @var string|null
3030
*/
3131
private $code;
3232

3333
/**
34-
* @param int $level
35-
* @param string $name
36-
* @param string $code
34+
* @param int $level
35+
* @param string $name
36+
* @param string|null $code
3737
*/
3838
public function __construct($level, $name, $code)
3939
{

Model/AdminLevelCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function slice($offset, $length = null)
8585
/**
8686
* @return bool
8787
*/
88-
public function has($level)
88+
public function has($level): bool
8989
{
9090
return isset($this->adminLevels[$level]);
9191
}
@@ -96,7 +96,7 @@ public function has($level)
9696
* @throws \OutOfBoundsException
9797
* @throws InvalidArgument
9898
*/
99-
public function get($level)
99+
public function get($level): AdminLevel
100100
{
101101
$this->checkLevel($level);
102102

Model/Bounds.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __construct($south, $west, $north, $east)
6666
*
6767
* @return float
6868
*/
69-
public function getSouth()
69+
public function getSouth(): float
7070
{
7171
return $this->south;
7272
}
@@ -76,7 +76,7 @@ public function getSouth()
7676
*
7777
* @return float
7878
*/
79-
public function getWest()
79+
public function getWest(): float
8080
{
8181
return $this->west;
8282
}
@@ -86,7 +86,7 @@ public function getWest()
8686
*
8787
* @return float
8888
*/
89-
public function getNorth()
89+
public function getNorth(): float
9090
{
9191
return $this->north;
9292
}
@@ -96,7 +96,7 @@ public function getNorth()
9696
*
9797
* @return float
9898
*/
99-
public function getEast()
99+
public function getEast(): float
100100
{
101101
return $this->east;
102102
}
@@ -106,7 +106,7 @@ public function getEast()
106106
*
107107
* @return array
108108
*/
109-
public function toArray()
109+
public function toArray(): array
110110
{
111111
return [
112112
'south' => $this->getSouth(),

Model/Coordinates.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct($latitude, $longitude)
4848
*
4949
* @return float
5050
*/
51-
public function getLatitude()
51+
public function getLatitude(): float
5252
{
5353
return $this->latitude;
5454
}
@@ -58,7 +58,7 @@ public function getLatitude()
5858
*
5959
* @return float
6060
*/
61-
public function getLongitude()
61+
public function getLongitude(): float
6262
{
6363
return $this->longitude;
6464
}

0 commit comments

Comments
 (0)