Skip to content

Commit 67c1b4e

Browse files
committed
Test updates
1 parent 11c241d commit 67c1b4e

10 files changed

Lines changed: 14 additions & 17 deletions

File tree

src/Type/Constant/ConstantArrayType.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,9 +2321,6 @@ public function mergeWith(self $otherArray): self
23212321
$mergedUnsealedKey = TypeCombinator::union($thisUnsealedKey, $otherUnsealedKey);
23222322
$mergedUnsealedValue = TypeCombinator::union($thisUnsealedValue, $otherUnsealedValue);
23232323

2324-
$resultUnsealed = [$mergedUnsealedKey, $mergedUnsealedValue];
2325-
$resultHasExtras = !($mergedUnsealedKey instanceof NeverType && $mergedUnsealedKey->isExplicit());
2326-
23272324
$absorbIntoExtras = static function (Type $keyType, Type $valueType) use (&$mergedUnsealedKey, &$mergedUnsealedValue): void {
23282325
$mergedUnsealedKey = TypeCombinator::union($mergedUnsealedKey, $keyType);
23292326
$mergedUnsealedValue = TypeCombinator::union($mergedUnsealedValue, $valueType);

tests/PHPStan/Analyser/nsrt/bug-14314.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function testIntRangeWithUnionAndEmpty(array $arr, int $twoToFour): void
7979
assertType('array{string, string, string, string}', $arr);
8080
return;
8181
}
82-
assertType('array{}|array{string, string, string, string}|array{string}', $arr);
82+
assertType('array{}|array{string}', $arr);
8383
}
8484
}
8585

tests/PHPStan/Analyser/nsrt/bug-5584.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ public function unionSum(): void
1919
$b = ['b' => 6];
2020
}
2121

22-
assertType('array{}|array{b?: 6, a?: 5}', $a + $b);
22+
assertType('array{b?: 6, a?: 5}', $a + $b);
2323
}
2424
}

tests/PHPStan/Analyser/nsrt/bug-9985.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function (): void {
1717
$warnings['c'] = true;
1818
}
1919

20-
assertType('array{}|array{a?: true, b: true}|array{a?: true, c?: true}', $warnings);
20+
assertType('array{a?: true, b: true}|array{a?: true, c?: true}', $warnings);
2121

2222
if (!empty($warnings)) {
2323
assertType('array{a?: true, b: true}|non-empty-array{a?: true, c?: true}', $warnings);

tests/PHPStan/Analyser/nsrt/generalize-scope-recursive.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function doFoo(array $array, array $values)
1616
}
1717
}
1818

19-
assertType('array{}|array{foo?: array}', $data);
19+
assertType('array{foo?: array}', $data);
2020
}
2121

2222
/**

tests/PHPStan/Analyser/nsrt/has-offset-type-bug.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ public function doBar(array $result): void
6363
*/
6464
public function testIsset($range): void
6565
{
66-
assertType("array{}|array{min?: bool|float|int|string|null, max?: bool|float|int|string|null}", $range);
66+
assertType("array{min?: bool|float|int|string|null, max?: bool|float|int|string|null}", $range);
6767
if (isset($range['min']) || isset($range['max'])) {
6868
assertType("non-empty-array{min?: bool|float|int|string|null, max?: bool|float|int|string|null}", $range);
6969
} else {
70-
assertType("array{}|array{min?: bool|float|int|string|null, max?: bool|float|int|string|null}", $range);
70+
assertType("array{min?: bool|float|int|string|null, max?: bool|float|int|string|null}", $range);
7171
}
7272

73-
assertType("array{}|array{min?: bool|float|int|string|null, max?: bool|float|int|string|null}", $range);
73+
assertType("array{min?: bool|float|int|string|null, max?: bool|float|int|string|null}", $range);
7474
}
7575

7676
}

tests/PHPStan/Analyser/nsrt/list-count.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,15 @@ protected function testOptionalKeysInListsOfTaggedUnion($row): void
291291
}
292292

293293
if (count($row) === 1) {
294-
assertType('array{0: int, 1?: string|null}|array{string}', $row);
294+
assertType('array{int}|array{string}', $row);
295295
} else {
296296
assertType('array{int, string|null}', $row);
297297
}
298298

299299
if (count($row) === 2) {
300300
assertType('array{int, string|null}', $row);
301301
} else {
302-
assertType('array{0: int, 1?: string|null}|array{string}', $row);
302+
assertType('array{int}|array{string}', $row);
303303
}
304304

305305
if (count($row) === 3) {
@@ -354,7 +354,7 @@ protected function testOptionalKeysInUnionListWithIntRange($row, $listRow, $twoO
354354
if (count($row) >= $twoOrThree) {
355355
assertType('list{0: int, 1: string|null, 2?: int|null, 3?: float|null}', $row);
356356
} else {
357-
assertType('array{string}|list{0: int, 1?: string|null, 2?: int|null, 3?: float|null}', $row);
357+
assertType('array{0: int, 1?: string|null}|array{string}', $row);
358358
}
359359

360360
if (count($row) >= $tenOrEleven) {
@@ -372,7 +372,7 @@ protected function testOptionalKeysInUnionListWithIntRange($row, $listRow, $twoO
372372
if (count($row) >= $maxThree) {
373373
assertType('array{string}|list{0: int, 1?: string|null, 2?: int|null, 3?: float|null}', $row);
374374
} else {
375-
assertType('array{string}|list{0: int, 1?: string|null, 2?: int|null, 3?: float|null}', $row);
375+
assertType('array{0: int, 1?: string|null}|array{string}', $row);
376376
}
377377

378378
if (count($row) >= $threeOrMoreInRangeLimit) {

tests/PHPStan/Analyser/nsrt/narrow-tagged-union.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function arrayIntRangeSize(): void
101101
}
102102

103103
if (count($x) === 1) {
104-
assertType("array{'xy'}|array{0: 'ab', 1?: 'xy'}", $x);
104+
assertType("array{'ab'}|array{'xy'}", $x);
105105
} else {
106106
assertType("array{}|array{0: 'ab', 1?: 'xy'}", $x);
107107
}

tests/PHPStan/Analyser/nsrt/unsealed-array-shapes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function wrongKeyButResolvedToIntString(array $a): void
7777
*/
7878
public function edgeCases(array $a, array $b, array $c): void
7979
{
80-
assertType('array{...<string, UnsealedArrayShapes\Foo>}', $a);
80+
assertType('array<string, UnsealedArrayShapes\Foo>', $a);
8181
assertType('array{a: int, b?: string, c?: string}', $b);
8282
assertType('array{a: int, b: float|string, c?: string}', $c);
8383
}

tests/PHPStan/Rules/Comparison/data/bug-7898.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function getCountryCode(): string
175175
public function getHasDaycationTaxesAndFees(): bool
176176
{
177177
assertType("array{US: array{bar: array{sales_tax: array{type: 'rate', unit: 'per-room-per-night'}, city_tax: array{type: 'both', unit: 'per-room-per-night'}, resort_fee: array{type: 'both', unit: 'per-room-per-night'}, additional_tax_or_fee: array{type: 'both', unit: 'per-room-per-night'}}, foo: array{tax: array{type: 'rate', unit: 'per-room-per-night'}}}, CA: array{bar: array{goods_and_services_tax: array{type: 'rate', unit: 'per-room-per-night'}, provincial_sales_tax: array{type: 'rate', unit: 'per-room-per-night'}, harmonized_sales_tax: array{type: 'rate', unit: 'per-room-per-night'}, municipal_and_regional_district_tax: array{type: 'rate', unit: 'per-room-per-night'}, additional_tax_or_fee: array{type: 'both', unit: 'per-room-per-night'}}}, SG: array{bar: array{service_charge: array{type: 'rate', unit: 'per-room-per-night'}, tax: array{type: 'rate', unit: 'per-room-per-night'}}}, TH: array{bar: array{service_charge: array{type: 'rate', unit: 'per-room-per-night'}, tax: array{type: 'rate', unit: 'per-room-per-night'}, city_tax: array{type: 'rate', unit: 'per-room-per-night'}}}, AE: array{bar: array{vat: array{type: 'rate', unit: 'per-room-per-night'}, service_charge: array{type: 'rate', unit: 'per-room-per-night'}, municipality_fee: array{type: 'rate', unit: 'per-room-per-night'}, tourism_fee: array{type: 'both', unit: 'per-room-per-night'}, destination_fee: array{type: 'both', unit: 'per-room-per-night'}}}, BH: array{bar: array{vat: array{type: 'rate', unit: 'per-room-per-night'}, service_charge: array{type: 'rate', unit: 'per-room-per-night'}, city_tax: array{type: 'rate', unit: 'per-room-per-night'}}}, HK: array{bar: array{service_charge: array{type: 'rate', unit: 'per-room-per-night'}, tax: array{type: 'rate', unit: 'per-room-per-night'}}}, ES: array{bar: array{city_tax: array{type: 'both', unit: 'per-room-per-night'}}}}", FooEnum::APPLICABLE_TAX_AND_FEES_BY_TYPE);
178-
assertType("array{bar: array{city_tax: array{type: 'both', unit: 'per-room-per-night'}}|array{sales_tax: array{type: 'rate', unit: 'per-room-per-night'}, city_tax: array{type: 'both', unit: 'per-room-per-night'}, resort_fee: array{type: 'both', unit: 'per-room-per-night'}, additional_tax_or_fee: array{type: 'both', unit: 'per-room-per-night'}}, foo?: array{tax: array{type: 'rate', unit: 'per-room-per-night'}}}|array{bar: array{goods_and_services_tax: array{type: 'rate', unit: 'per-room-per-night'}, provincial_sales_tax: array{type: 'rate', unit: 'per-room-per-night'}, harmonized_sales_tax: array{type: 'rate', unit: 'per-room-per-night'}, municipal_and_regional_district_tax: array{type: 'rate', unit: 'per-room-per-night'}, additional_tax_or_fee: array{type: 'both', unit: 'per-room-per-night'}}}|array{bar: array{service_charge: array{type: 'rate', unit: 'per-room-per-night'}, tax: array{type: 'rate', unit: 'per-room-per-night'}, city_tax?: array{type: 'rate', unit: 'per-room-per-night'}}}|array{bar: array{vat: array{type: 'rate', unit: 'per-room-per-night'}, service_charge: array{type: 'rate', unit: 'per-room-per-night'}, city_tax: array{type: 'rate', unit: 'per-room-per-night'}}}|array{bar: array{vat: array{type: 'rate', unit: 'per-room-per-night'}, service_charge: array{type: 'rate', unit: 'per-room-per-night'}, municipality_fee: array{type: 'rate', unit: 'per-room-per-night'}, tourism_fee: array{type: 'both', unit: 'per-room-per-night'}, destination_fee: array{type: 'both', unit: 'per-room-per-night'}}}", FooEnum::APPLICABLE_TAX_AND_FEES_BY_TYPE[$this->getCountryCode()]);
178+
assertType("array{bar: array{city_tax: array{type: 'both', unit: 'per-room-per-night'}}}|array{bar: array{goods_and_services_tax: array{type: 'rate', unit: 'per-room-per-night'}, provincial_sales_tax: array{type: 'rate', unit: 'per-room-per-night'}, harmonized_sales_tax: array{type: 'rate', unit: 'per-room-per-night'}, municipal_and_regional_district_tax: array{type: 'rate', unit: 'per-room-per-night'}, additional_tax_or_fee: array{type: 'both', unit: 'per-room-per-night'}}}|array{bar: array{sales_tax: array{type: 'rate', unit: 'per-room-per-night'}, city_tax: array{type: 'both', unit: 'per-room-per-night'}, resort_fee: array{type: 'both', unit: 'per-room-per-night'}, additional_tax_or_fee: array{type: 'both', unit: 'per-room-per-night'}}, foo: array{tax: array{type: 'rate', unit: 'per-room-per-night'}}}|array{bar: array{service_charge: array{type: 'rate', unit: 'per-room-per-night'}, tax: array{type: 'rate', unit: 'per-room-per-night'}, city_tax?: array{type: 'rate', unit: 'per-room-per-night'}}}|array{bar: array{vat: array{type: 'rate', unit: 'per-room-per-night'}, service_charge: array{type: 'rate', unit: 'per-room-per-night'}, city_tax: array{type: 'rate', unit: 'per-room-per-night'}}}|array{bar: array{vat: array{type: 'rate', unit: 'per-room-per-night'}, service_charge: array{type: 'rate', unit: 'per-room-per-night'}, municipality_fee: array{type: 'rate', unit: 'per-room-per-night'}, tourism_fee: array{type: 'both', unit: 'per-room-per-night'}, destination_fee: array{type: 'both', unit: 'per-room-per-night'}}}", FooEnum::APPLICABLE_TAX_AND_FEES_BY_TYPE[$this->getCountryCode()]);
179179
return array_key_exists(FooEnum::FOO_TYPE, FooEnum::APPLICABLE_TAX_AND_FEES_BY_TYPE[$this->getCountryCode()]);
180180
}
181181

0 commit comments

Comments
 (0)