Skip to content

Commit c1a439d

Browse files
Accept errors as a known PHPStan limitation rather than worked around with complex annotations that don't provide real value
1 parent ecb779e commit c1a439d

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Method MartinGeorgiev\\Doctrine\\DBAL\\Types\\ValueObject\\Range\:\:empty\(\) should return static\(MartinGeorgiev\\Doctrine\\DBAL\\Types\\ValueObject\\Range\<R of DateTimeInterface\|float\|int\>\) but returns static\(MartinGeorgiev\\Doctrine\\DBAL\\Types\\ValueObject\\Range\<DateTimeInterface\|float\|int\>\)\.$#'
5+
identifier: return.type
6+
count: 1
7+
path: ../../../src/MartinGeorgiev/Doctrine/DBAL/Types/ValueObject/Range.php
8+
9+
-
10+
message: '#^Method MartinGeorgiev\\Doctrine\\DBAL\\Types\\ValueObject\\Range\:\:fromString\(\) should return static\(MartinGeorgiev\\Doctrine\\DBAL\\Types\\ValueObject\\Range\<R of DateTimeInterface\|float\|int\>\) but returns static\(MartinGeorgiev\\Doctrine\\DBAL\\Types\\ValueObject\\Range\<DateTimeInterface\|float\|int\>\)\.$#'
11+
identifier: return.type
12+
count: 2
13+
path: ../../../src/MartinGeorgiev/Doctrine/DBAL/Types/ValueObject/Range.php
14+
15+
-
16+
message: '#^Method MartinGeorgiev\\Doctrine\\DBAL\\Types\\ValueObject\\Range\:\:infinite\(\) should return static\(MartinGeorgiev\\Doctrine\\DBAL\\Types\\ValueObject\\Range\<R of DateTimeInterface\|float\|int\>\) but returns static\(MartinGeorgiev\\Doctrine\\DBAL\\Types\\ValueObject\\Range\<DateTimeInterface\|float\|int\>\)\.$#'
17+
identifier: return.type
18+
count: 1
19+
path: ../../../src/MartinGeorgiev/Doctrine/DBAL/Types/ValueObject/Range.php
20+
21+
-
22+
message: '#^Unsafe usage of new static\(\)\.$#'
23+
identifier: new.static
24+
count: 4
25+
path: ../../../src/MartinGeorgiev/Doctrine/DBAL/Types/ValueObject/Range.php

ci/phpstan/config.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ includes:
66
- ./baselines/deprecated-methods.neon
77
- ./baselines/lexer-variations.neon
88
- ./baselines/phpstan-identifiers.neon
9+
- ./baselines/range-baseline.neon
910
- ./baselines/type-mismatches.neon
1011

1112
parameters:

src/MartinGeorgiev/Doctrine/DBAL/Types/ValueObject/Range.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Abstract base class for PostgreSQL range types.
99
*
10-
* @template T of int|float|\DateTimeInterface
10+
* @template R of int|float|\DateTimeInterface
1111
*
1212
* @since 3.3
1313
*

tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/DBALTypesTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public function test_scalar_type(string $typeName, string $columnType, mixed $te
2323
$this->runTypeTest($typeName, $columnType, $testValue);
2424
}
2525

26+
/**
27+
* @return array<string, array{string, string, string}>
28+
*/
2629
public static function provideScalarTypeTestCases(): array
2730
{
2831
return [
@@ -35,12 +38,18 @@ public static function provideScalarTypeTestCases(): array
3538
];
3639
}
3740

41+
/**
42+
* @param array<mixed> $testValue
43+
*/
3844
#[DataProvider('provideArrayTypeTestCases')]
3945
public function test_array_type(string $typeName, string $columnType, array $testValue): void
4046
{
4147
$this->runTypeTest($typeName, $columnType, $testValue);
4248
}
4349

50+
/**
51+
* @return array<string, array{string, string, array<mixed>}>
52+
*/
4453
public static function provideArrayTypeTestCases(): array
4554
{
4655
return [
@@ -63,12 +72,18 @@ public static function provideArrayTypeTestCases(): array
6372
];
6473
}
6574

75+
/**
76+
* @param array<mixed> $testValue
77+
*/
6678
#[DataProvider('provideJsonTypeTestCases')]
6779
public function test_json_type(string $typeName, string $columnType, array $testValue): void
6880
{
6981
$this->runTypeTest($typeName, $columnType, $testValue);
7082
}
7183

84+
/**
85+
* @return array<string, array{string, string, array<mixed>}>
86+
*/
7287
public static function provideJsonTypeTestCases(): array
7388
{
7489
return [
@@ -94,6 +109,9 @@ public function test_point_type(string $typeName, string $columnType, PointValue
94109
$this->runTypeTest($typeName, $columnType, $pointValueObject);
95110
}
96111

112+
/**
113+
* @return array<string, array{string, string, PointValueObject}>
114+
*/
97115
public static function providePointTypeTestCases(): array
98116
{
99117
return [
@@ -104,12 +122,18 @@ public static function providePointTypeTestCases(): array
104122
];
105123
}
106124

125+
/**
126+
* @param DateRangeValueObject|Int4RangeValueObject|Int8RangeValueObject|NumRangeValueObject|TsRangeValueObject|TstzRangeValueObject $rangeValueObject
127+
*/
107128
#[DataProvider('provideRangeTypeTestCases')]
108129
public function test_range_type(string $typeName, string $columnType, RangeValueObject $rangeValueObject): void
109130
{
110131
$this->runTypeTest($typeName, $columnType, $rangeValueObject);
111132
}
112133

134+
/**
135+
* @return array<string, array{string, string, DateRangeValueObject|Int4RangeValueObject|Int8RangeValueObject|NumRangeValueObject|TsRangeValueObject|TstzRangeValueObject}>
136+
*/
113137
public static function provideRangeTypeTestCases(): array
114138
{
115139
return [
@@ -183,6 +207,9 @@ private function assertPointEquals(PointValueObject $pointValueObject, mixed $ac
183207
$this->assertEquals($pointValueObject->getY(), $actual->getY(), 'Failed asserting that Y coordinates are equal for type '.$typeName);
184208
}
185209

210+
/**
211+
* @param RangeValueObject<\DateTimeInterface|float|int> $rangeValueObject
212+
*/
186213
private function assertRangeEquals(RangeValueObject $rangeValueObject, mixed $actual, string $typeName): void
187214
{
188215
$this->assertInstanceOf(RangeValueObject::class, $actual, 'Failed asserting that value is a Range object for type '.$typeName);

0 commit comments

Comments
 (0)