1010use PHPStan \Type \NeverType ;
1111use PHPStan \Type \Type ;
1212use 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