Skip to content

Commit 6b4760b

Browse files
authored
IBX-9727: Add missing type hints to search contracts (#565)
* Added missing type hints to \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Value\MapLocationValue * Added missing type hints to \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Field\FieldAggregationTrait * Added missing type hints to search contracts (automatic) * Added generics to aggregation framework contracts * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\AbstractImageRangeCriterion * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\AbstractImageCompositeCriterion * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Location\Depth * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Location\IsMainLocation * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Location\Priority * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Ancestor * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentId * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeGroupId * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeId * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeIdentifier * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\DateMetadata * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Field * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\FullText * Removed unsupported \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\FullText::{$analyzers, $wildcards} properties * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LanguageCode * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LocationId * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LocationRemoteId * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalOperator * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\MapLocationDistance * Removed unsupported Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\MapLocationDistance::$boost property * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ObjectStateId * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ObjectStateIdentifier * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ParentLocationId * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\RemoteId * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\SectionId * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\SectionIdentifier * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Subtree * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserEmail * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserId * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserLogin * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserMetadata * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Visibility * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause\Target\CustomFieldTarget * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause\Target\FieldTarget * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause\Target\MapLocationTarget * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause\Target\RandomTarget * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause\Field * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause\MapLocationDistance * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit * Added missing type hints to Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult * [PHPStan] Regenerated baseline * [Tests] Updated unit tests * Applied code review suggestions
1 parent 13b64dc commit 6b4760b

File tree

95 files changed

+555
-740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+555
-740
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 228 deletions
Large diffs are not rendered by default.

src/contracts/Repository/Values/Content/Query/Aggregation/AbstractRangeAggregation.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,31 @@
1010

1111
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation;
1212

13+
/**
14+
* @phpstan-template TValue
15+
*/
1316
abstract class AbstractRangeAggregation implements Aggregation
1417
{
1518
/**
1619
* The name of the aggregation.
17-
*
18-
* @var string
1920
*/
20-
protected $name;
21+
protected string $name;
2122

22-
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range[] */
23-
protected $ranges;
23+
/** @phpstan-var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range<covariant TValue>[] */
24+
protected array $ranges;
2425

26+
/**
27+
* @phpstan-param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range<covariant TValue>[] $ranges
28+
*/
2529
public function __construct(string $name, array $ranges = [])
2630
{
2731
$this->name = $name;
2832
$this->ranges = $ranges;
2933
}
3034

35+
/**
36+
* @phpstan-return \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range<covariant TValue>[]
37+
*/
3138
public function getRanges(): array
3239
{
3340
return $this->ranges;

src/contracts/Repository/Values/Content/Query/Aggregation/AbstractStatsAggregation.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ abstract class AbstractStatsAggregation implements Aggregation
1414
{
1515
/**
1616
* The name of the aggregation.
17-
*
18-
* @var string
1917
*/
20-
protected $name;
18+
protected string $name;
2119

2220
public function __construct(string $name)
2321
{

src/contracts/Repository/Values/Content/Query/Aggregation/AbstractTermAggregation.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,23 @@
1212

1313
abstract class AbstractTermAggregation implements Aggregation
1414
{
15-
public const DEFAULT_LIMIT = 10;
16-
public const DEFAULT_MIN_COUNT = 1;
15+
public const int DEFAULT_LIMIT = 10;
16+
public const int DEFAULT_MIN_COUNT = 1;
1717

1818
/**
1919
* The name of the aggregation.
20-
*
21-
* @var string
2220
*/
23-
protected $name;
21+
protected string $name;
2422

2523
/**
2624
* Number of facets (terms) returned.
27-
*
28-
* @var int
2925
*/
30-
protected $limit = self::DEFAULT_LIMIT;
26+
protected int $limit = self::DEFAULT_LIMIT;
3127

3228
/**
3329
* Specifies the minimum count. Only facet groups with more or equal results are returned.
34-
*
35-
* @var int
3630
*/
37-
protected $minCount = self::DEFAULT_MIN_COUNT;
31+
protected int $minCount = self::DEFAULT_MIN_COUNT;
3832

3933
public function __construct(string $name)
4034
{

src/contracts/Repository/Values/Content/Query/Aggregation/DateMetadataRangeAggregation.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@
1111
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Ranges\RangesGeneratorInterface;
1212
use Traversable;
1313

14+
/**
15+
* @phpstan-extends \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation<\DateTimeInterface>
16+
*/
1417
final class DateMetadataRangeAggregation extends AbstractRangeAggregation
1518
{
16-
public const MODIFIED = 'modified';
17-
public const CREATED = 'created';
18-
public const PUBLISHED = 'published';
19+
public const string MODIFIED = 'modified';
20+
public const string CREATED = 'created';
21+
public const string PUBLISHED = 'published';
1922

20-
/** @var string */
21-
private $type;
23+
private string $type;
2224

25+
/**
26+
* @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range<covariant \DateTimeInterface>[] $ranges
27+
*/
2328
public function __construct(string $name, string $type, array $ranges = [])
2429
{
2530
parent::__construct($name, $ranges);
@@ -31,6 +36,9 @@ public function getType(): string
3136
return $this->type;
3237
}
3338

39+
/**
40+
* @phpstan-param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Ranges\RangesGeneratorInterface<covariant \DateTimeInterface> $generator
41+
*/
3442
public static function fromGenerator(
3543
string $name,
3644
string $type,

src/contracts/Repository/Values/Content/Query/Aggregation/Field/AbstractFieldRangeAggregation.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@
1111
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation;
1212
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\FieldAggregation;
1313

14+
/**
15+
* @phpstan-template TValue
16+
*
17+
* @phpstan-extends \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation<TValue>
18+
*/
1419
abstract class AbstractFieldRangeAggregation extends AbstractRangeAggregation implements FieldAggregation
1520
{
1621
use FieldAggregationTrait;
1722

23+
/**
24+
* @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range<TValue>[] $ranges
25+
*/
1826
public function __construct(
1927
string $name,
2028
string $contentTypeIdentifier,

src/contracts/Repository/Values/Content/Query/Aggregation/Field/CountryTermAggregation.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010

1111
final class CountryTermAggregation extends AbstractFieldTermAggregation
1212
{
13-
public const TYPE_NAME = 1;
14-
public const TYPE_IDC = 2;
15-
public const TYPE_ALPHA_2 = 4;
16-
public const TYPE_ALPHA_3 = 8;
13+
public const int TYPE_NAME = 1;
14+
public const int TYPE_IDC = 2;
15+
public const int TYPE_ALPHA_2 = 4;
16+
public const int TYPE_ALPHA_3 = 8;
1717

18-
/** @var int */
19-
private $type;
18+
private int $type;
2019

2120
public function __construct(
2221
string $name,

src/contracts/Repository/Values/Content/Query/Aggregation/Field/DateRangeAggregation.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@
1111
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Ranges\RangesGeneratorInterface;
1212
use Traversable;
1313

14+
/**
15+
* @phpstan-extends \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Field\AbstractFieldRangeAggregation<\DateTimeInterface>
16+
*/
1417
final class DateRangeAggregation extends AbstractFieldRangeAggregation
1518
{
19+
/**
20+
* @phpstan-param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Ranges\RangesGeneratorInterface<\DateTimeInterface> $generator
21+
*/
1622
public static function fromGenerator(
1723
string $name,
1824
string $contentTypeIdentifier,

src/contracts/Repository/Values/Content/Query/Aggregation/Field/DateTimeRangeAggregation.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@
1111
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Ranges\RangesGeneratorInterface;
1212
use Traversable;
1313

14+
/**
15+
* @phpstan-extends \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Field\AbstractFieldRangeAggregation<\DateTimeInterface>
16+
*/
1417
final class DateTimeRangeAggregation extends AbstractFieldRangeAggregation
1518
{
19+
/**
20+
* @phpstan-param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Ranges\RangesGeneratorInterface<\DateTimeInterface> $generator
21+
*/
1622
public static function fromGenerator(
1723
string $name,
1824
string $contentTypeIdentifier,

src/contracts/Repository/Values/Content/Query/Aggregation/Field/FieldAggregationTrait.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010

1111
trait FieldAggregationTrait
1212
{
13-
/** @var string */
14-
public $contentTypeIdentifier;
13+
public string $contentTypeIdentifier;
1514

16-
/** @var string */
17-
public $fieldDefinitionIdentifier;
15+
public string $fieldDefinitionIdentifier;
1816

1917
public function getContentTypeIdentifier(): string
2018
{

0 commit comments

Comments
 (0)