@@ -175,7 +175,7 @@ public function format($text)
175175 return $ text ;
176176 }
177177
178- foreach ($ matches [0 ] as $ i => $ m ) {
178+ foreach (( array ) $ matches [0 ] as $ i => $ m ) {
179179 if (array_key_exists ($ matches [1 ][$ i ], $ this ->styles )) {
180180 $ text = $ this ->replaceColor ($ text , $ matches [1 ][$ i ], $ matches [2 ][$ i ], $ this ->styles [$ matches [1 ][$ i ]]);
181181
@@ -198,8 +198,8 @@ public function format($text)
198198 */
199199 protected function replaceColor ($ text , $ tag , $ match , Style $ style )
200200 {
201- $ style = $ style ->toString ();
202- $ replace = $ this ->noColor ? $ match : "\033[ {$ style }m {$ match }\033[0m " ;
201+ $ styleStr = $ style ->toString ();
202+ $ replace = $ this ->noColor ? $ match : "\033[ {$ styleStr }m {$ match }\033[0m " ;
203203
204204 return str_replace ("< $ tag> $ match</ $ tag> " , $ replace , $ text );
205205 }
@@ -220,7 +220,9 @@ public function addStyle($name, $fg = '', $bg = '', array $options = [])
220220 {
221221 if (is_array ($ fg )) {
222222 return $ this ->addStyleByArray ($ name , $ fg );
223- } elseif (is_object ($ fg ) && $ fg instanceof Style) {
223+ }
224+
225+ if (is_object ($ fg ) && $ fg instanceof Style) {
224226 $ this ->styles [$ name ] = $ fg ;
225227 } else {
226228 $ this ->styles [$ name ] = Style::make ($ fg , $ bg , $ options );
@@ -249,7 +251,7 @@ public function addStyleByArray($name, array $styleConfig)
249251 ];
250252
251253 $ config = array_merge ($ style , $ styleConfig );
252- list ( $ fg , $ bg , $ options) = array_values ($ config );
254+ [ $ fg , $ bg , $ options] = array_values ($ config );
253255
254256 $ this ->styles [$ name ] = Style::make ($ fg , $ bg , $ options );
255257
0 commit comments