Skip to content

Commit fee2ef5

Browse files
committed
[phpstan] Fixed issues reported by phpstan
1 parent 311772e commit fee2ef5

6 files changed

+850
-463
lines changed

phpstan-baseline.neon

+836-443
Large diffs are not rendered by default.

src/lib/Exception/NoValidLocationsException.php

+2-9
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,12 @@
1313

1414
class NoValidLocationsException extends Exception
1515
{
16-
/**
17-
* @var \Ibexa\Contracts\Core\Repository\Values\Content\Content|\Ibexa\Contracts\Core\Repository\Values\Content\Content[]
18-
*/
19-
private $content;
16+
private Content $content;
2017

21-
/**
22-
* NoValidLocationsException constructor.
23-
*
24-
* @param \Ibexa\Contracts\Core\Repository\Values\Content\Content $content
25-
*/
2618
public function __construct(Content $content)
2719
{
2820
parent::__construct("No valid location could be determined for content #{$content->id}");
21+
2922
$this->content = $content;
3023
}
3124

src/lib/InputMapper/SearchQueryMapper.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ function ($input) {
8989
if (isset($inputArray['sortBy'])) {
9090
$query->sortClauses = array_map(
9191
static function ($sortClauseClass) {
92-
/** @var Query\SortClause $lastSortClause */
93-
static $lastSortClause;
92+
/** @var Query\SortClause|null $lastSortClause */
93+
static $lastSortClause = null;
9494

9595
if ($sortClauseClass === Query::SORT_DESC) {
9696
if (!$lastSortClause instanceof Query\SortClause) {

src/lib/InputMapper/SearchQuerySortByMapper.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public function mapInputToSortClauses(array $sortInput)
2020
{
2121
$sortClauses = array_map(
2222
static function (string $sortClauseClass) {
23-
/** @var Query\SortClause $lastSortClause */
24-
static $lastSortClause;
23+
/** @var Query\SortClause|null $lastSortClause */
24+
static $lastSortClause = null;
2525

2626
if ($sortClauseClass === Query::SORT_DESC) {
2727
if (!$lastSortClause instanceof Query\SortClause) {

src/lib/Resolver/ImageAssetFieldResolver.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@
1515
*/
1616
class ImageAssetFieldResolver
1717
{
18-
/* @var array<\Ibexa\GraphQL\Mapper\ImageAssetMapperStrategyInterface> */
19-
private $strategies;
18+
/** @var array<\Ibexa\GraphQL\Mapper\ImageAssetMapperStrategyInterface> */
19+
private array $strategies;
2020

2121
/**
2222
* @param iterable<\Ibexa\GraphQL\Mapper\ImageAssetMapperStrategyInterface> $strategies
2323
*/
2424
public function __construct(iterable $strategies)
2525
{
26+
$this->strategies = [];
2627
foreach ($strategies as $strategy) {
27-
if ($strategy instanceof ImageAssetMapperStrategyInterface) {
28-
$this->strategies[] = $strategy;
29-
}
28+
$this->strategies[] = $strategy;
3029
}
3130
}
3231

src/lib/Resolver/ImageFieldResolver.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
namespace Ibexa\GraphQL\Resolver;
99

1010
use Ibexa\Contracts\Core\Repository\ContentService;
11+
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
12+
use Ibexa\Contracts\Core\Repository\Values\Content\Field;
1113
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
1214
use Ibexa\Contracts\Core\Variation\VariationHandler;
1315
use Ibexa\Core\FieldType;
@@ -80,7 +82,7 @@ public function resolveImageVariation(ImageFieldValue $fieldValue, $args)
8082
}
8183

8284
/**
83-
* @return [Content, Field]
85+
* @phpstan-return array{Content, Field}
8486
*
8587
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
8688
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
@@ -92,7 +94,7 @@ protected function getImageField(ImageFieldValue $fieldValue): array
9294
$content = $this->contentLoader->findSingle(new Criterion\ContentId($contentId));
9395

9496
$fieldFound = false;
95-
/** @var $field \Ibexa\Contracts\Core\Repository\Values\Content\Field */
97+
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Field $field */
9698
foreach ($content->getFields() as $field) {
9799
if ($field->id == $fieldId) {
98100
$fieldFound = true;

0 commit comments

Comments
 (0)