Skip to content

Commit 68f19f6

Browse files
committed
Fix linter issues
1 parent f0142b5 commit 68f19f6

File tree

8 files changed

+23
-6
lines changed

8 files changed

+23
-6
lines changed

src/Platform/EmptyPlatform.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
namespace TypeLang\Mapper\Platform;
66

77
use TypeLang\Mapper\Context\Direction;
8+
use TypeLang\Mapper\Type\Builder\TypeBuilderInterface;
9+
use TypeLang\Mapper\Type\Coercer\TypeCoercerInterface;
10+
use TypeLang\Mapper\Type\TypeInterface;
811

912
final class EmptyPlatform implements PlatformInterface
1013
{
@@ -13,11 +16,17 @@ public function getName(): string
1316
return 'empty';
1417
}
1518

19+
/**
20+
* @return array<class-string<TypeInterface>, TypeCoercerInterface>
21+
*/
1622
public function getTypeCoercers(Direction $direction): array
1723
{
1824
return [];
1925
}
2026

27+
/**
28+
* @return array<array-key, TypeBuilderInterface>
29+
*/
2130
public function getTypes(Direction $direction): array
2231
{
2332
return [];

src/Platform/Platform.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract class Platform implements PlatformInterface
2727
protected readonly array $types;
2828

2929
/**
30-
* @var list<TypeCoercerInterface>
30+
* @var array<class-string<TypeInterface>, TypeCoercerInterface>
3131
*/
3232
protected readonly array $coercers;
3333

@@ -86,13 +86,13 @@ public function getTypes(Direction $direction): iterable
8686
}
8787

8888
/**
89-
* @param iterable<mixed, TypeCoercerInterface> $coercers
89+
* @param iterable<class-string<TypeInterface>, TypeCoercerInterface> $coercers
9090
*
91-
* @return list<TypeCoercerInterface>
91+
* @return array<class-string<TypeInterface>, TypeCoercerInterface>
9292
*/
9393
protected function formatCoercers(iterable $coercers): array
9494
{
95-
return iterable_to_array($coercers, true);
95+
return iterable_to_array($coercers);
9696
}
9797

9898
public function getTypeCoercers(Direction $direction): iterable

src/Type/Builder/BackedEnumToScalarTypeBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class BackedEnumToScalarTypeBuilder extends BackedEnumTypeBuilder
1515
{
1616
protected function create(string $class, string $definition, TypeInterface $type): BackedEnumToScalarType
1717
{
18+
/** @phpstan-ignore-next-line : Too complicated checks for PHPStan */
1819
return new BackedEnumToScalarType($class);
1920
}
2021
}

src/Type/DateTimeFromStringType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function match(mixed $value, Context $context): bool
3636
}
3737

3838
try {
39+
/** @var string $value */
3940
return $this->tryParseDateTime($value) !== null;
4041
} catch (\Throwable) {
4142
return false;

src/Type/Repository/LoggableTypeRepository.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public function getTypeByStatement(TypeStatement $statement): TypeInterface
9595
private function unwrap(TypeInterface $type): TypeInterface
9696
{
9797
if ($type instanceof TypeDecoratorInterface) {
98+
/** @var TypeInterface<TArgResult> */
9899
return $type->getDecoratedType();
99100
}
100101

src/Type/Repository/TypeDecorator/TypeDecorator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function __construct(
2727
public function getDecoratedType(): TypeInterface
2828
{
2929
if ($this->delegate instanceof TypeDecoratorInterface) {
30+
/** @var TypeInterface<TResult> */
3031
return $this->delegate->getDecoratedType();
3132
}
3233

src/Type/Repository/TypeRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141
) {
4242
$this->context = $this;
4343
$this->builders = iterable_to_array($builders, false);
44-
$this->coercers = iterable_to_array($coercers, true);
44+
$this->coercers = iterable_to_array($coercers);
4545
}
4646

4747
/**

src/helpers.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88
* The {@see \iterator_to_array()} function supports {@see array} only starting
99
* with PHP 8.2. To ensure compatibility, you can use this function.
1010
*
11+
* @template TArgKey of mixed
1112
* @template TArgValue of mixed
1213
*
13-
* @return list<TArgValue>
14+
* @param iterable<TArgKey, TArgValue> $iterator
15+
*
16+
* @return ($preserveKeys is true ? array<TArgKey, TArgValue> : list<TArgValue>)
1417
*/
1518
function iterable_to_array(iterable $iterator, bool $preserveKeys = true): array
1619
{
1720
if (\PHP_VERSION_ID >= 80200 || !\is_array($iterator)) {
21+
/** @var array<TArgKey, TArgValue> */
1822
return \iterator_to_array($iterator, $preserveKeys);
1923
}
2024

0 commit comments

Comments
 (0)