Skip to content

Commit a178a35

Browse files
authored
Add PHP Coding Standards Fixer in CI (#1196)
* Update composer.json * Update .gitignore * Update php.yml * Apply PHPCSFixer fixes * Switch to php-cs-fixer/shim * Create .php-cs-fixer.dist.php
1 parent 4d6c79d commit a178a35

File tree

3 files changed

+27
-69
lines changed

3 files changed

+27
-69
lines changed

Mapbox.php

Lines changed: 25 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,99 +16,99 @@
1616
use Geocoder\Exception\InvalidArgument;
1717
use Geocoder\Exception\InvalidServerResponse;
1818
use Geocoder\Exception\UnsupportedOperation;
19-
use Geocoder\Model\AddressCollection;
20-
use Geocoder\Model\AddressBuilder;
21-
use Geocoder\Query\GeocodeQuery;
22-
use Geocoder\Query\ReverseQuery;
2319
use Geocoder\Http\Provider\AbstractHttpProvider;
20+
use Geocoder\Model\AddressBuilder;
21+
use Geocoder\Model\AddressCollection;
2422
use Geocoder\Provider\Mapbox\Model\MapboxAddress;
2523
use Geocoder\Provider\Provider;
24+
use Geocoder\Query\GeocodeQuery;
25+
use Geocoder\Query\ReverseQuery;
2626
use Psr\Http\Client\ClientInterface;
2727

2828
final class Mapbox extends AbstractHttpProvider implements Provider
2929
{
3030
/**
3131
* @var string
3232
*/
33-
const GEOCODE_ENDPOINT_URL_SSL = 'https://api.mapbox.com/geocoding/v5/%s/%s.json';
33+
public const GEOCODE_ENDPOINT_URL_SSL = 'https://api.mapbox.com/geocoding/v5/%s/%s.json';
3434

3535
/**
3636
* @var string
3737
*/
38-
const REVERSE_ENDPOINT_URL_SSL = 'https://api.mapbox.com/geocoding/v5/%s/%F,%F.json';
38+
public const REVERSE_ENDPOINT_URL_SSL = 'https://api.mapbox.com/geocoding/v5/%s/%F,%F.json';
3939

4040
/**
4141
* @var string
4242
*/
43-
const GEOCODING_MODE_PLACES = 'mapbox.places';
43+
public const GEOCODING_MODE_PLACES = 'mapbox.places';
4444

4545
/**
4646
* @var string
4747
*/
48-
const GEOCODING_MODE_PLACES_PERMANENT = 'mapbox.places-permanent';
48+
public const GEOCODING_MODE_PLACES_PERMANENT = 'mapbox.places-permanent';
4949

5050
/**
5151
* @var array
5252
*/
53-
const GEOCODING_MODES = [
53+
public const GEOCODING_MODES = [
5454
self::GEOCODING_MODE_PLACES,
5555
self::GEOCODING_MODE_PLACES_PERMANENT,
5656
];
5757

5858
/**
5959
* @var string
6060
*/
61-
const TYPE_COUNTRY = 'country';
61+
public const TYPE_COUNTRY = 'country';
6262

6363
/**
6464
* @var string
6565
*/
66-
const TYPE_REGION = 'region';
66+
public const TYPE_REGION = 'region';
6767

6868
/**
6969
* @var string
7070
*/
71-
const TYPE_POSTCODE = 'postcode';
71+
public const TYPE_POSTCODE = 'postcode';
7272

7373
/**
7474
* @var string
7575
*/
76-
const TYPE_DISTRICT = 'district';
76+
public const TYPE_DISTRICT = 'district';
7777

7878
/**
7979
* @var string
8080
*/
81-
const TYPE_PLACE = 'place';
81+
public const TYPE_PLACE = 'place';
8282

8383
/**
8484
* @var string
8585
*/
86-
const TYPE_LOCALITY = 'locality';
86+
public const TYPE_LOCALITY = 'locality';
8787

8888
/**
8989
* @var string
9090
*/
91-
const TYPE_NEIGHBORHOOD = 'neighborhood';
91+
public const TYPE_NEIGHBORHOOD = 'neighborhood';
9292

9393
/**
9494
* @var string
9595
*/
96-
const TYPE_ADDRESS = 'address';
96+
public const TYPE_ADDRESS = 'address';
9797

9898
/**
9999
* @var string
100100
*/
101-
const TYPE_POI = 'poi';
101+
public const TYPE_POI = 'poi';
102102

103103
/**
104104
* @var string
105105
*/
106-
const TYPE_POI_LANDMARK = 'poi.landmark';
106+
public const TYPE_POI_LANDMARK = 'poi.landmark';
107107

108108
/**
109109
* @var array
110110
*/
111-
const TYPES = [
111+
public const TYPES = [
112112
self::TYPE_COUNTRY,
113113
self::TYPE_REGION,
114114
self::TYPE_POSTCODE,
@@ -121,7 +121,7 @@ final class Mapbox extends AbstractHttpProvider implements Provider
121121
self::TYPE_POI_LANDMARK,
122122
];
123123

124-
const DEFAULT_TYPE = self::TYPE_ADDRESS;
124+
public const DEFAULT_TYPE = self::TYPE_ADDRESS;
125125

126126
/**
127127
* @var string
@@ -139,10 +139,8 @@ final class Mapbox extends AbstractHttpProvider implements Provider
139139
private $geocodingMode;
140140

141141
/**
142-
* @param ClientInterface $client An HTTP adapter
143-
* @param string $accessToken Your Mapbox access token
144-
* @param string|null $country
145-
* @param string $geocodingMode
142+
* @param ClientInterface $client An HTTP adapter
143+
* @param string $accessToken Your Mapbox access token
146144
*/
147145
public function __construct(
148146
ClientInterface $client,
@@ -223,20 +221,12 @@ public function reverseQuery(ReverseQuery $query): Collection
223221
return $this->fetchUrl($url, $query->getLimit(), $query->getLocale(), $query->getData('country', $this->country));
224222
}
225223

226-
/**
227-
* {@inheritdoc}
228-
*/
229224
public function getName(): string
230225
{
231226
return 'mapbox';
232227
}
233228

234229
/**
235-
* @param string $url
236-
* @param int $limit
237-
* @param string|null $locale
238-
* @param string|null $country
239-
*
240230
* @return string query with extra params
241231
*/
242232
private function buildQuery(string $url, int $limit, string $locale = null, string $country = null): string
@@ -253,14 +243,6 @@ private function buildQuery(string $url, int $limit, string $locale = null, stri
253243
return $url.$separator.http_build_query($parameters);
254244
}
255245

256-
/**
257-
* @param string $url
258-
* @param int $limit
259-
* @param string|null $locale
260-
* @param string|null $country
261-
*
262-
* @return AddressCollection
263-
*/
264246
private function fetchUrl(string $url, int $limit, string $locale = null, string $country = null): AddressCollection
265247
{
266248
$url = $this->buildQuery($url, $limit, $locale, $country);
@@ -323,9 +305,8 @@ private function fetchUrl(string $url, int $limit, string $locale = null, string
323305
/**
324306
* Update current resultSet with given key/value.
325307
*
326-
* @param AddressBuilder $builder
327-
* @param string $type Component type
328-
* @param array $value The component value
308+
* @param string $type Component type
309+
* @param array $value The component value
329310
*/
330311
private function updateAddressComponent(AddressBuilder $builder, string $type, array $value)
331312
{
@@ -378,10 +359,7 @@ private function updateAddressComponent(AddressBuilder $builder, string $type, a
378359
/**
379360
* Decode the response content and validate it to make sure it does not have any errors.
380361
*
381-
* @param string $url
382362
* @param string $content
383-
*
384-
* @return array
385363
*/
386364
private function validateResponse(string $url, $content): array
387365
{
@@ -397,9 +375,6 @@ private function validateResponse(string $url, $content): array
397375

398376
/**
399377
* Parse coordinats and bounds.
400-
*
401-
* @param AddressBuilder $builder
402-
* @param array $result
403378
*/
404379
private function parseCoordinates(AddressBuilder $builder, array $result)
405380
{

Model/MapboxAddress.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ final class MapboxAddress extends Address
4747
private $neighborhood;
4848

4949
/**
50-
* @param string|null $id
51-
*
5250
* @return MapboxAddress
5351
*/
5452
public function withId(string $id = null)
@@ -78,8 +76,6 @@ public function getStreetName()
7876
}
7977

8078
/**
81-
* @param string|null $streetName
82-
*
8379
* @return MapboxAddress
8480
*/
8581
public function withStreetName(string $streetName = null)
@@ -99,8 +95,6 @@ public function getStreetNumber()
9995
}
10096

10197
/**
102-
* @param string|null $streetNumber
103-
*
10498
* @return MapboxAddress
10599
*/
106100
public function withStreetNumber(string $streetNumber = null)
@@ -111,17 +105,12 @@ public function withStreetNumber(string $streetNumber = null)
111105
return $new;
112106
}
113107

114-
/**
115-
* @return array
116-
*/
117108
public function getResultType(): array
118109
{
119110
return $this->resultType;
120111
}
121112

122113
/**
123-
* @param array $resultType
124-
*
125114
* @return MapboxAddress
126115
*/
127116
public function withResultType(array $resultType)
@@ -141,8 +130,6 @@ public function getFormattedAddress()
141130
}
142131

143132
/**
144-
* @param string|null $formattedAddress
145-
*
146133
* @return MapboxAddress
147134
*/
148135
public function withFormattedAddress(string $formattedAddress = null)
@@ -162,8 +149,6 @@ public function getNeighborhood()
162149
}
163150

164151
/**
165-
* @param string|null $neighborhood
166-
*
167152
* @return MapboxAddress
168153
*/
169154
public function withNeighborhood(string $neighborhood = null)

Tests/MapboxTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
namespace Geocoder\Provider\Mapbox\Tests;
1414

1515
use Geocoder\IntegrationTest\BaseTestCase;
16-
use Geocoder\Location;
17-
use Geocoder\Model\Address;
1816
use Geocoder\Model\AddressCollection;
1917
use Geocoder\Model\Bounds;
20-
use Geocoder\Query\GeocodeQuery;
21-
use Geocoder\Query\ReverseQuery;
2218
use Geocoder\Provider\Mapbox\Mapbox;
2319
use Geocoder\Provider\Mapbox\Model\MapboxAddress;
20+
use Geocoder\Query\GeocodeQuery;
21+
use Geocoder\Query\ReverseQuery;
2422

2523
class MapboxTest extends BaseTestCase
2624
{

0 commit comments

Comments
 (0)