@@ -18,6 +18,7 @@ class Styles
1818
1919 protected bool $ readDataOnly ;
2020
21+ /** @var array<string, string[]> */
2122 public static array $ mappings = [
2223 'borderStyle ' => [
2324 '0 ' => Border::BORDER_NONE ,
@@ -100,6 +101,7 @@ private function readStyles(SimpleXMLElement $styleRegion, int $maxRow, int $max
100101
101102 $ styleAttributes = $ style ->Style ->attributes ();
102103
104+ /** @var mixed[][] */
103105 $ styleArray = [];
104106 // We still set the number format mask for date/time values, even if readDataOnly is true
105107 // 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
117119 }
118120 }
119121
122+ /** @param mixed[][] $styleArray */
120123 private function addBorderDiagonal (SimpleXMLElement $ srssb , array &$ styleArray ): void
121124 {
122125 if (isset ($ srssb ->Diagonal , $ srssb ->{'Rev-Diagonal ' })) {
@@ -131,11 +134,14 @@ private function addBorderDiagonal(SimpleXMLElement $srssb, array &$styleArray):
131134 }
132135 }
133136
137+ /** @param mixed[][] $styleArray */
134138 private function addBorderStyle (SimpleXMLElement $ srssb , array &$ styleArray , string $ direction ): void
135139 {
136140 $ ucDirection = ucfirst ($ direction );
137141 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 ());
139145 }
140146 }
141147
@@ -150,22 +156,26 @@ private function calcRotation(SimpleXMLElement $styleAttributes): int
150156 return $ rotation ;
151157 }
152158
159+ /** @param mixed[][] $styleArray */
153160 private static function addStyle (array &$ styleArray , string $ key , string $ value ): void
154161 {
155162 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
157164 }
158165 }
159166
167+ /** @param mixed[][] $styleArray */
160168 private static function addStyle2 (array &$ styleArray , string $ key1 , string $ key , string $ value ): void
161169 {
162170 if (array_key_exists ($ value , self ::$ mappings [$ key ])) {
163171 $ styleArray [$ key1 ][$ key ] = self ::$ mappings [$ key ][$ value ];
164172 }
165173 }
166174
175+ /** @return mixed[][] */
167176 private static function parseBorderAttributes (?SimpleXMLElement $ borderAttributes ): array
168177 {
178+ /** @var mixed[][] */
169179 $ styleArray = [];
170180 if ($ borderAttributes !== null ) {
171181 if (isset ($ borderAttributes ['Color ' ])) {
@@ -174,6 +184,7 @@ private static function parseBorderAttributes(?SimpleXMLElement $borderAttribute
174184
175185 self ::addStyle ($ styleArray , 'borderStyle ' , (string ) $ borderAttributes ['Style ' ]);
176186 }
187+ /** @var mixed[][] $styleArray */
177188
178189 return $ styleArray ;
179190 }
@@ -188,9 +199,11 @@ private static function parseGnumericColour(string $gnmColour): string
188199 return $ gnmR . $ gnmG . $ gnmB ;
189200 }
190201
202+ /** @param mixed[][] $styleArray */
191203 private function addColors (array &$ styleArray , SimpleXMLElement $ styleAttributes ): void
192204 {
193205 $ RGB = self ::parseGnumericColour ((string ) $ styleAttributes ['Fore ' ]);
206+ /** @var mixed[][][] $styleArray */
194207 $ styleArray ['font ' ]['color ' ]['rgb ' ] = $ RGB ;
195208 $ RGB = self ::parseGnumericColour ((string ) $ styleAttributes ['Back ' ]);
196209 $ shade = (string ) $ styleAttributes ['Shade ' ];
@@ -221,6 +234,11 @@ private function readStyleRange(SimpleXMLElement $styleAttributes, int $maxCol,
221234 return $ cellRange ;
222235 }
223236
237+ /**
238+ * @param mixed[][] $styleArray
239+ *
240+ * @return mixed[]
241+ */
224242 private function readStyle (array $ styleArray , SimpleXMLElement $ styleAttributes , SimpleXMLElement $ style ): array
225243 {
226244 self ::addStyle2 ($ styleArray , 'alignment ' , 'horizontal ' , (string ) $ styleAttributes ['HAlign ' ]);
0 commit comments