Skip to content

Commit 68257a6

Browse files
committed
Fix CS
1 parent b5c64fb commit 68257a6

5 files changed

Lines changed: 22 additions & 11 deletions

File tree

src/Type/Constant/ConstantArrayType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
use function sort;
7979
use function sprintf;
8080
use function str_contains;
81+
use function usort;
8182

8283
/**
8384
* @api

src/Type/TypeCombinator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,9 +1714,11 @@ private static function intersectDefiniteConstantArrays(ConstantArrayType $a, Co
17141714
$keysToProcess[$keyValue] = [$k, $bKeyByValue[$keyValue] ?? null];
17151715
}
17161716
foreach ($bKeyByValue as $keyValue => $k) {
1717-
if (!array_key_exists($keyValue, $keysToProcess)) {
1718-
$keysToProcess[$keyValue] = [null, $k];
1717+
if (array_key_exists($keyValue, $keysToProcess)) {
1718+
continue;
17191719
}
1720+
1721+
$keysToProcess[$keyValue] = [null, $k];
17201722
}
17211723

17221724
foreach ($keysToProcess as [$aIdx, $bIdx]) {

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2929,7 +2929,7 @@ public function testBug11494(): void
29292929
[
29302930
'Parameter #1 $a of function Bug11494\test expects array{long: string, details: string}|array{short: string}, array{short: \'thing\', extra: \'other\'} given.',
29312931
18,
2932-
"• Type #1 from the union: Sealed array shape does not accept array with extra key 'extra'.\n• Type #2 from the union: Sealed array shape does not accept array with extra key 'extra'."
2932+
"• Type #1 from the union: Sealed array shape does not accept array with extra key 'extra'.\n• Type #2 from the union: Sealed array shape does not accept array with extra key 'extra'.",
29332933
],
29342934
]);
29352935
}

tests/PHPStan/Type/Constant/ConstantArrayTypeTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use PHPUnit\Framework\Attributes\DataProvider;
3232
use stdClass;
3333
use function array_map;
34+
use function is_string;
3435
use function sprintf;
3536

3637
class ConstantArrayTypeTest extends PHPStanTestCase
@@ -616,9 +617,11 @@ public function testAccepts(Type $type, Type $otherType, TrinaryLogic $expectedR
616617
$actualResult->result->describe(),
617618
$testDescription,
618619
);
619-
if ($reasons !== null) {
620-
$this->assertSame($reasons, $actualResult->reasons, $testDescription);
620+
if ($reasons === null) {
621+
return;
621622
}
623+
624+
$this->assertSame($reasons, $actualResult->reasons, $testDescription);
622625
}
623626

624627
public static function dataIsSuperTypeOf(): iterable

tests/PHPStan/Type/TypeCombinatorTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
use function array_reverse;
6868
use function get_class;
6969
use function implode;
70+
use function is_string;
7071
use function sprintf;
7172
use const PHP_VERSION_ID;
7273

@@ -5094,7 +5095,7 @@ public static function dataIntersect(): iterable
50945095
[new IntegerType(), new UnionType([
50955096
new ConstantStringType('0'),
50965097
new ConstantStringType('foo'),
5097-
])]
5098+
])],
50985099
),
50995100
new ConstantArrayType(
51005101
[new ConstantIntegerType(0), new ConstantIntegerType(1)],
@@ -5297,9 +5298,11 @@ public function testIntersect(
52975298
$typeStringResolver = self::getContainer()->getByType(TypeStringResolver::class);
52985299
foreach ($types as $i => $type) {
52995300
BleedingEdgeToggle::setBleedingEdge(true);
5300-
if (is_string($type)) {
5301-
$types[$i] = $typeStringResolver->resolve($type, null);
5301+
if (!is_string($type)) {
5302+
continue;
53025303
}
5304+
5305+
$types[$i] = $typeStringResolver->resolve($type, null);
53035306
}
53045307

53055308
BleedingEdgeToggle::setBleedingEdge($bleedingEdgeBackup);
@@ -5315,7 +5318,7 @@ public function testIntersect(
53155318
}
53165319

53175320
/**
5318-
* @param list<Type> $types
5321+
* @param list<Type>|list<string> $types
53195322
* @param class-string<Type> $expectedTypeClass
53205323
*/
53215324
#[DataProvider('dataIntersect')]
@@ -5329,9 +5332,11 @@ public function testIntersectInversed(
53295332
$typeStringResolver = self::getContainer()->getByType(TypeStringResolver::class);
53305333
foreach ($types as $i => $type) {
53315334
BleedingEdgeToggle::setBleedingEdge(true);
5332-
if (is_string($type)) {
5333-
$types[$i] = $typeStringResolver->resolve($type, null);
5335+
if (!is_string($type)) {
5336+
continue;
53345337
}
5338+
5339+
$types[$i] = $typeStringResolver->resolve($type, null);
53355340
}
53365341

53375342
BleedingEdgeToggle::setBleedingEdge($bleedingEdgeBackup);

0 commit comments

Comments
 (0)