Skip to content

Commit a137fdc

Browse files
committed
Improving phpstan
1 parent 30e5d12 commit a137fdc

13 files changed

Lines changed: 90 additions & 24 deletions

src/Client.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,17 @@ public function search(
6868
]
6969
);
7070

71+
/** @var array<string, mixed> $result */
7172
$result = json_decode($response->getBody()->getContents(), true);
7273

7374
if (! isset($result['data']['defaultDatasetId'])) {
7475
throw new ApiException('Invalid API response: missing dataset ID');
7576
}
7677

77-
return $this->fetchDataset($result['data']['defaultDatasetId']);
78+
/** @var string $datasetId */
79+
$datasetId = $result['data']['defaultDatasetId'];
80+
81+
return $this->fetchDataset($datasetId);
7882
} catch (GuzzleException $e) {
7983
$this->handleGuzzleException($e);
8084
}
@@ -89,10 +93,11 @@ private function fetchDataset(string $datasetId): array
8993
{
9094
try {
9195
$response = $this->http->get("/datasets/{$datasetId}/items");
96+
/** @var array<int, array<string, mixed>> $items */
9297
$items = json_decode($response->getBody()->getContents(), true);
9398

9499
return array_map(
95-
static fn (array $item) => Supplier::fromArray($item),
100+
static fn (array $item): Supplier => Supplier::fromArray($item),
96101
$items
97102
);
98103
} catch (GuzzleException $e) {

src/DTO/Address.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public function __construct(
1818
public ?float $longitude,
1919
) {}
2020

21+
/**
22+
* @param array<string, mixed> $data
23+
*/
2124
public static function fromArray(array $data): self
2225
{
2326
return new self(

src/DTO/Brand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public function __construct(
1010
public string $name,
1111
) {}
1212

13+
/**
14+
* @param array<string, mixed> $data
15+
*/
1316
public static function fromArray(array $data): self
1417
{
1518
return new self(

src/DTO/Certification.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public function __construct(
2121
public bool $isActive,
2222
) {}
2323

24+
/**
25+
* @param array<string, mixed> $data
26+
*/
2427
public static function fromArray(array $data): self
2528
{
2629
return new self(

src/DTO/CertificationTotal.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ public function __construct(
1111
public int $count,
1212
) {}
1313

14+
/**
15+
* @param array<string, mixed> $data
16+
*/
1417
public static function fromArray(array $data): self
1518
{
1619
return new self(

src/DTO/Heading.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public function __construct(
1414
public ?string $url,
1515
) {}
1616

17+
/**
18+
* @param array<string, mixed> $data
19+
*/
1720
public static function fromArray(array $data): self
1821
{
1922
return new self(

src/DTO/NewsArticle.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public function __construct(
1515
public ?string $type,
1616
) {}
1717

18+
/**
19+
* @param array<string, mixed> $data
20+
*/
1821
public static function fromArray(array $data): self
1922
{
2023
return new self(

src/DTO/Person.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ public function __construct(
1111
public ?string $title,
1212
) {}
1313

14+
/**
15+
* @param array<string, mixed> $data
16+
*/
1417
public static function fromArray(array $data): self
1518
{
1619
return new self(

src/DTO/Product.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public function __construct(
1212
public ?string $imageUrl,
1313
) {}
1414

15+
/**
16+
* @param array<string, mixed> $data
17+
*/
1518
public static function fromArray(array $data): self
1619
{
1720
return new self(

src/DTO/SocialLink.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ public function __construct(
1111
public string $url,
1212
) {}
1313

14+
/**
15+
* @param array<string, mixed> $data
16+
*/
1417
public static function fromArray(array $data): self
1518
{
1619
return new self(

0 commit comments

Comments
 (0)