@@ -18,6 +18,7 @@ class Styles
18
18
19
19
protected bool $ readDataOnly ;
20
20
21
+ /** @var array<string, string[]> */
21
22
public static array $ mappings = [
22
23
'borderStyle ' => [
23
24
'0 ' => Border::BORDER_NONE ,
@@ -100,6 +101,7 @@ private function readStyles(SimpleXMLElement $styleRegion, int $maxRow, int $max
100
101
101
102
$ styleAttributes = $ style ->Style ->attributes ();
102
103
104
+ /** @var mixed[][] */
103
105
$ styleArray = [];
104
106
// We still set the number format mask for date/time values, even if readDataOnly is true
105
107
// so that we can identify whether a float is a float or a date value
@@ -117,6 +119,7 @@ private function readStyles(SimpleXMLElement $styleRegion, int $maxRow, int $max
117
119
}
118
120
}
119
121
122
+ /** @param mixed[][] $styleArray */
120
123
private function addBorderDiagonal (SimpleXMLElement $ srssb , array &$ styleArray ): void
121
124
{
122
125
if (isset ($ srssb ->Diagonal , $ srssb ->{'Rev-Diagonal ' })) {
@@ -131,11 +134,14 @@ private function addBorderDiagonal(SimpleXMLElement $srssb, array &$styleArray):
131
134
}
132
135
}
133
136
137
+ /** @param mixed[][] $styleArray */
134
138
private function addBorderStyle (SimpleXMLElement $ srssb , array &$ styleArray , string $ direction ): void
135
139
{
136
140
$ ucDirection = ucfirst ($ direction );
137
141
if (isset ($ srssb ->$ ucDirection )) {
138
- $ styleArray ['borders ' ][$ direction ] = self ::parseBorderAttributes ($ srssb ->$ ucDirection ->attributes ());
142
+ /** @var SimpleXMLElement */
143
+ $ temp = $ srssb ->$ ucDirection ;
144
+ $ styleArray ['borders ' ][$ direction ] = self ::parseBorderAttributes ($ temp ->attributes ());
139
145
}
140
146
}
141
147
@@ -150,22 +156,26 @@ private function calcRotation(SimpleXMLElement $styleAttributes): int
150
156
return $ rotation ;
151
157
}
152
158
159
+ /** @param mixed[][] $styleArray */
153
160
private static function addStyle (array &$ styleArray , string $ key , string $ value ): void
154
161
{
155
162
if (array_key_exists ($ value , self ::$ mappings [$ key ])) {
156
- $ styleArray [$ key ] = self ::$ mappings [$ key ][$ value ];
163
+ $ styleArray [$ key ] = self ::$ mappings [$ key ][$ value ]; //* @phpstan-ignore-line
157
164
}
158
165
}
159
166
167
+ /** @param mixed[][] $styleArray */
160
168
private static function addStyle2 (array &$ styleArray , string $ key1 , string $ key , string $ value ): void
161
169
{
162
170
if (array_key_exists ($ value , self ::$ mappings [$ key ])) {
163
171
$ styleArray [$ key1 ][$ key ] = self ::$ mappings [$ key ][$ value ];
164
172
}
165
173
}
166
174
175
+ /** @return mixed[][] */
167
176
private static function parseBorderAttributes (?SimpleXMLElement $ borderAttributes ): array
168
177
{
178
+ /** @var mixed[][] */
169
179
$ styleArray = [];
170
180
if ($ borderAttributes !== null ) {
171
181
if (isset ($ borderAttributes ['Color ' ])) {
@@ -174,6 +184,7 @@ private static function parseBorderAttributes(?SimpleXMLElement $borderAttribute
174
184
175
185
self ::addStyle ($ styleArray , 'borderStyle ' , (string ) $ borderAttributes ['Style ' ]);
176
186
}
187
+ /** @var mixed[][] $styleArray */
177
188
178
189
return $ styleArray ;
179
190
}
@@ -188,9 +199,11 @@ private static function parseGnumericColour(string $gnmColour): string
188
199
return $ gnmR . $ gnmG . $ gnmB ;
189
200
}
190
201
202
+ /** @param mixed[][] $styleArray */
191
203
private function addColors (array &$ styleArray , SimpleXMLElement $ styleAttributes ): void
192
204
{
193
205
$ RGB = self ::parseGnumericColour ((string ) $ styleAttributes ['Fore ' ]);
206
+ /** @var mixed[][][] $styleArray */
194
207
$ styleArray ['font ' ]['color ' ]['rgb ' ] = $ RGB ;
195
208
$ RGB = self ::parseGnumericColour ((string ) $ styleAttributes ['Back ' ]);
196
209
$ shade = (string ) $ styleAttributes ['Shade ' ];
@@ -221,6 +234,11 @@ private function readStyleRange(SimpleXMLElement $styleAttributes, int $maxCol,
221
234
return $ cellRange ;
222
235
}
223
236
237
+ /**
238
+ * @param mixed[][] $styleArray
239
+ *
240
+ * @return mixed[]
241
+ */
224
242
private function readStyle (array $ styleArray , SimpleXMLElement $ styleAttributes , SimpleXMLElement $ style ): array
225
243
{
226
244
self ::addStyle2 ($ styleArray , 'alignment ' , 'horizontal ' , (string ) $ styleAttributes ['HAlign ' ]);
0 commit comments