Skip to content

Commit 5b5729d

Browse files
committed
CS + PHPStan fixes
1 parent 24f1087 commit 5b5729d

78 files changed

Lines changed: 370 additions & 330 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.idea/
2+
vendor/
23
composer.lock

phpstan.neon

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ parameters:
44

55
ignoreErrors:
66
-
7-
identifier: missingType.iterableValue
7+
message: "#^Unreachable statement \\- code above always terminates\\.$#"
8+
count: 1
9+
path: src/Factory/EntityFactory.php
10+
811
-
9-
identifier: missingType.generics
12+
message: "#^Variable \\$propertyValue might not be defined\\.$#"
13+
count: 1
14+
path: src/Factory/EntityFactory.php
1015

1116
bootstrapFiles:
1217
- %rootDir%/../../../phpstanConstants.php

src/DI/SpameriElasticSearchExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public function loadConfiguration(): void
4545
}
4646

4747

48+
/**
49+
* @param array<mixed> $services
50+
* @param array<mixed> $config
51+
* @return array<mixed>
52+
*/
4853
public function setConfigOptions(
4954
array $services,
5055
array $config,

src/Entity/AbstractValueCollection.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace Spameri\Elastic\Entity;
44

5+
/**
6+
* @template-covariant T of \Spameri\Elastic\Entity\ValueInterface
7+
* @template-implements \Spameri\Elastic\Entity\ValueCollectionInterface<T>
8+
*/
59
abstract class AbstractValueCollection implements ValueCollectionInterface
610
{
711

@@ -47,7 +51,7 @@ public function get(mixed $key): \Spameri\Elastic\Entity\ValueInterface|null
4751

4852

4953
/**
50-
* @return \ArrayIterator<\Spameri\Elastic\Entity\ValueInterface>
54+
* @return \ArrayIterator<int|string, \Spameri\Elastic\Entity\ValueInterface>
5155
*/
5256
public function getIterator(): \ArrayIterator
5357
{

src/Entity/Collection/AbstractCachedEntityCollection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace Spameri\Elastic\Entity\Collection;
44

5+
/**
6+
* @template-covariant T of \Spameri\Elastic\Entity\EntityInterface
7+
* @template-extends \Spameri\Elastic\Entity\Collection\AbstractEntityCollection<T>
8+
*/
59
abstract class AbstractCachedEntityCollection extends AbstractEntityCollection
610
{
711

src/Entity/Collection/AbstractElasticEntityCollection.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Spameri\Elastic\Entity\Collection;
44

55
/**
6-
* @template-covariant T
7-
* @template-extends \Spameri\Elastic\Entity\ElasticEntityCollectionInterface<T>
6+
* @template-covariant T of \Spameri\Elastic\Entity\AbstractElasticEntity
7+
* @template-implements \Spameri\Elastic\Entity\ElasticEntityCollectionInterface<T>
88
*/
99
abstract class AbstractElasticEntityCollection implements \Spameri\Elastic\Entity\ElasticEntityCollectionInterface
1010
{
@@ -53,9 +53,6 @@ public function __construct(
5353
}
5454

5555

56-
/**
57-
* @param T $elasticEntity
58-
*/
5956
public function add(
6057
\Spameri\Elastic\Entity\AbstractElasticEntity $elasticEntity,
6158
): void
@@ -113,12 +110,18 @@ public function elasticIds(): array
113110
}
114111

115112

113+
/**
114+
* @return array<T>
115+
*/
116116
protected function collection(): array
117117
{
118118
return $this->collection;
119119
}
120120

121121

122+
/**
123+
* @return \ArrayIterator<int|string, \Spameri\Elastic\Entity\AbstractElasticEntity>
124+
*/
122125
public function getIterator(): \ArrayIterator
123126
{
124127
if ( ! $this->initialized) {
@@ -244,6 +247,9 @@ public function __serialize(): array
244247
];
245248
}
246249

250+
/**
251+
* @param array<mixed> $data
252+
*/
247253
public function __unserialize(array $data): void
248254
{
249255
$this->collection = $data;

src/Entity/Collection/AbstractEntityCollection.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace Spameri\Elastic\Entity\Collection;
44

5+
/**
6+
* @template-covariant T of \Spameri\Elastic\Entity\EntityInterface
7+
* @template-implements \Spameri\Elastic\Entity\EntityCollectionInterface<T>
8+
*/
59
abstract class AbstractEntityCollection implements \Spameri\Elastic\Entity\EntityCollectionInterface
610
{
711

@@ -30,12 +34,18 @@ public function add(
3034
}
3135

3236

37+
/**
38+
* @return array<T>
39+
*/
3340
protected function collection(): array
3441
{
3542
return $this->collection;
3643
}
3744

3845

46+
/**
47+
* @return \ArrayIterator<int|string, \Spameri\Elastic\Entity\EntityInterface>
48+
*/
3949
public function getIterator(): \ArrayIterator
4050
{
4151
return new \ArrayIterator($this->collection);

src/Entity/Collection/ElasticEntityCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Spameri\Elastic\Entity\Collection;
44

55
/**
6-
* @template-covariant T
7-
* @template-extends AbstractElasticEntityCollection<T>
6+
* @template-covariant T of \Spameri\Elastic\Entity\AbstractElasticEntity
7+
* @template-extends \Spameri\Elastic\Entity\Collection\AbstractElasticEntityCollection<T>
88
*/
99
class ElasticEntityCollection extends AbstractElasticEntityCollection
1010
{

src/Entity/Collection/EntityCollection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace Spameri\Elastic\Entity\Collection;
44

5+
/**
6+
* @template-covariant T of \Spameri\Elastic\Entity\EntityInterface
7+
* @template-extends \Spameri\Elastic\Entity\Collection\AbstractEntityCollection<T>
8+
*/
59
class EntityCollection extends AbstractEntityCollection
610
{
711

src/Entity/Collection/STIEntityCollection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace Spameri\Elastic\Entity\Collection;
44

5+
/**
6+
* @template-covariant T of \Spameri\Elastic\Entity\EntityInterface
7+
* @template-extends \Spameri\Elastic\Entity\Collection\AbstractEntityCollection<T>
8+
*/
59
class STIEntityCollection extends AbstractEntityCollection
610
{
711

0 commit comments

Comments
 (0)