Skip to content

Commit

Permalink
Enable PHPStan Level 6 (#1194)
Browse files Browse the repository at this point in the history
* Update phpstan.neon

* Update YandexTest.php

* Update TomTomTest.php

* Update PickPointTest.php

* Update PickPoint.php

* Update PhotonTest.php

* Update PeliasTest.php

* Update OpenRouteServiceTest.php

* Update OpenCageTest.php

* Update OpenCage.php

* Update NominatimTest.php

* Update MaxMindBinaryTest.php

* Update MaxMindTest.php

* [WIP] Apply PHPStan fixes

* Apply PHPCSFixer fixes

* [WIP] Apply PHPStan fixes

* [WIP] Apply PHPStan fixes

* Revert "[WIP] Apply PHPStan fixes"

This reverts commit 734c5c52fbcba4bc12cbda07b58d902a79d47891.

* [WIP] Apply PHPStan fixes

* [WIP] Apply PHPStan fixes

* Update phpstan-baseline.neon
  • Loading branch information
jbelien authored Jul 31, 2023
1 parent 7394d83 commit e50a87b
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 26 deletions.
16 changes: 14 additions & 2 deletions GoogleMapsPlaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public function getName(): string

/**
* Build query for the find place API.
*
* @return array<string, mixed>
*/
private function buildFindPlaceQuery(GeocodeQuery $geocodeQuery): array
{
Expand Down Expand Up @@ -168,6 +170,8 @@ private function buildFindPlaceQuery(GeocodeQuery $geocodeQuery): array

/**
* Build query for the place search API.
*
* @return array<string, mixed>
*/
private function buildPlaceSearchQuery(GeocodeQuery $geocodeQuery): array
{
Expand Down Expand Up @@ -197,6 +201,8 @@ private function buildPlaceSearchQuery(GeocodeQuery $geocodeQuery): array

/**
* Build query for the nearby search api.
*
* @return array<string, mixed>
*/
private function buildNearbySearchQuery(ReverseQuery $reverseQuery): array
{
Expand Down Expand Up @@ -265,7 +271,10 @@ private function buildNearbySearchQuery(ReverseQuery $reverseQuery): array
}

/**
* @return array
* @param array<string, mixed> $request
* @param string[] $keys
*
* @return array<string, mixed>
*/
private function applyDataFromQuery(Query $query, array $request, array $keys)
{
Expand All @@ -280,6 +289,9 @@ private function applyDataFromQuery(Query $query, array $request, array $keys)
return $request;
}

/**
* @param array<string, mixed> $query
*/
private function fetchUrl(string $url, array $query): AddressCollection
{
$query['key'] = $this->apiKey;
Expand Down Expand Up @@ -414,7 +426,7 @@ private function validateResponse(string $url, $content): \stdClass
/**
* Parse coordinates and bounds.
*/
private function parseCoordinates(AddressBuilder $builder, \stdClass $result)
private function parseCoordinates(AddressBuilder $builder, \stdClass $result): void
{
$coordinates = $result->geometry->location;
$builder->setCoordinates($coordinates->lat, $coordinates->lng);
Expand Down
39 changes: 38 additions & 1 deletion Model/GooglePlace.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class GooglePlace extends Address
private $name;

/**
* @var array
* @var string[]
*/
private $type = [];

Expand Down Expand Up @@ -134,12 +134,17 @@ public function withName(string $name = null)
return $new;
}

/**
* @return string[]
*/
public function getType(): array
{
return $this->type;
}

/**
* @param string[] $type
*
* @return GooglePlace
*/
public function withType(array $type)
Expand Down Expand Up @@ -196,6 +201,9 @@ public function getIcon()
return $this->icon;
}

/**
* @return GooglePlace
*/
public function withIcon(string $icon = null)
{
$new = clone $this;
Expand All @@ -209,6 +217,9 @@ public function getPlusCode(): ?PlusCode
return $this->plusCode;
}

/**
* @return GooglePlace
*/
public function withPlusCode(PlusCode $plusCode = null)
{
$new = clone $this;
Expand All @@ -225,6 +236,11 @@ public function getPhotos()
return $this->photos;
}

/**
* @param Photo[]|null $photos
*
* @return GooglePlace
*/
public function withPhotos(array $photos = null)
{
$new = clone $this;
Expand All @@ -249,6 +265,9 @@ public function getPriceLevel()
return $this->priceLevel;
}

/**
* @return GooglePlace
*/
public function withPriceLevel(int $priceLevel = null)
{
$new = clone $this;
Expand All @@ -265,6 +284,9 @@ public function getRating()
return $this->rating;
}

/**
* @return GooglePlace
*/
public function withRating(float $rating = null)
{
$new = clone $this;
Expand All @@ -281,6 +303,9 @@ public function getFormattedPhoneNumber()
return $this->formattedPhoneNumber;
}

/**
* @return GooglePlace
*/
public function withFormattedPhoneNumber(string $phone)
{
$new = clone $this;
Expand All @@ -297,6 +322,9 @@ public function getInternationalPhoneNumber()
return $this->internationalPhoneNumber;
}

/**
* @return GooglePlace
*/
public function withInternationalPhoneNumber(string $phone)
{
$new = clone $this;
Expand All @@ -313,6 +341,9 @@ public function getWebsite()
return $this->website;
}

/**
* @return GooglePlace
*/
public function withWebsite(string $website)
{
$new = clone $this;
Expand All @@ -329,6 +360,9 @@ public function getOpeningHours()
return $this->openingHours;
}

/**
* @return GooglePlace
*/
public function withOpeningHours(OpeningHours $openingHours)
{
$new = clone $this;
Expand All @@ -342,6 +376,9 @@ public function isPermanentlyClosed(): bool
return $this->permanentlyClosed;
}

/**
* @return GooglePlace
*/
public function setPermanentlyClosed()
{
$new = clone $this;
Expand Down
10 changes: 5 additions & 5 deletions Model/OpeningHours.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OpeningHours
private $openNow;

/**
* @var array[]
* @var array{close: array{day: int, time: string}, open: array{day: int, time: string}}
*/
private $periods;

Expand All @@ -33,9 +33,9 @@ class OpeningHours
private $weekdayText;

/**
* @param bool|null $openNow
* @param array[] $periods
* @param string[] $weekdayText
* @param bool|null $openNow
* @param array{close: array{day: int, time: string}, open: array{day: int, time: string}} $periods
* @param string[] $weekdayText
*/
public function __construct($openNow, array $periods, array $weekdayText)
{
Expand All @@ -53,7 +53,7 @@ public function isOpenNow()
}

/**
* @return array[]
* @return array{close: array{day: int, time: string}, open: array{day: int, time: string}}
*/
public function getPeriods(): array
{
Expand Down
13 changes: 12 additions & 1 deletion Model/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ class Photo
private $width;

/**
* @var array
* @var string[]
*/
private $htmlAttributions = [];

/**
* @param string[] $htmlAttributions
*/
public function __construct(string $photoReference, int $height, int $width, array $htmlAttributions)
{
$this->photoReference = $photoReference;
Expand All @@ -60,11 +63,19 @@ public function getWidth(): int
return $this->width;
}

/**
* @return string[]
*/
public function getHtmlAttributions(): array
{
return $this->htmlAttributions;
}

/**
* @param \stdClass[] $photos
*
* @return self[]
*/
public static function getPhotosFromResult(array $photos): array
{
return array_map(function ($photo) {
Expand Down
Loading

0 comments on commit e50a87b

Please sign in to comment.