Skip to content

Commit ef0bf7b

Browse files
committed
[Privatization] Narrow ConstantArrayType filter to satisfy PHPStan native type check
1 parent f6db0aa commit ef0bf7b

1 file changed

Lines changed: 0 additions & 40 deletions

File tree

rules/Privatization/TypeManipulator/ArrayTypeLeastCommonDenominatorResolver.php

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use PHPStan\Type\NeverType;
1111
use PHPStan\Type\Type;
1212
use PHPStan\Type\TypeCombinator;
13-
use PHPStan\Type\VerbosityLevel;
1413

1514
/**
1615
* Made with GPT-5
@@ -37,45 +36,6 @@ public function sharedArrayStructure(Type ...$types): Type
3736
}
3837
}
3938

40-
// If all are ConstantArrayType and have the *same* ordered key list -> preserve shape.
41-
$allConstantArrayTypes = array_reduce($types, fn ($c, $t): bool => $c && $t instanceof ConstantArrayType, true);
42-
if ($allConstantArrayTypes) {
43-
/** @var ConstantArrayType[] $consts */
44-
$consts = $types;
45-
46-
// Compare key sets (by stringified key types)
47-
$firstKeys = array_map(
48-
fn (Type $type): string => $type->describe(VerbosityLevel::typeOnly()),
49-
$consts[0]->getKeyTypes()
50-
);
51-
foreach ($consts as $c) {
52-
$keys = array_map(
53-
fn (Type $type): string => $type->describe(VerbosityLevel::typeOnly()),
54-
$c->getKeyTypes()
55-
);
56-
if ($keys !== $firstKeys) {
57-
$allConstantArrayTypes = false;
58-
break;
59-
}
60-
}
61-
62-
if ($allConstantArrayTypes) {
63-
$resultKeyTypes = $consts[0]->getKeyTypes();
64-
$valueColumns = [];
65-
foreach ($consts as $const) {
66-
$valueColumns[] = $const->getValueTypes();
67-
}
68-
69-
$resultValueTypes = [];
70-
foreach (array_keys($resultKeyTypes) as $i) {
71-
$col = array_column($valueColumns, $i);
72-
$resultValueTypes[] = $this->sharedArrayStructure(...$col);
73-
}
74-
75-
return new ConstantArrayType($resultKeyTypes, $resultValueTypes);
76-
}
77-
}
78-
7939
// Generic ArrayType path: reconcile key type + recurse into item types
8040
/** @var ArrayType[] $types */
8141
/** @var ArrayType[] $arrayTypes */

0 commit comments

Comments
 (0)