Debian Codegraph @

vendor/wikimedia/less.php/lib/Less/VisitorReplacing.php

raw
1 <?php
2 /**
3 * @private
4 */
5 class Less_VisitorReplacing extends Less_Visitor {
6
7 public function visitArray( &$nodes ) {
8 $newNodes = [];
9 foreach ( $nodes as $node ) {
10 $evald = $this->visitObj( $node );
11 if ( $evald ) {
12 if ( is_array( $evald ) ) {
13 self::flatten( $evald, $newNodes );
14 } else {
15 $newNodes[] = $evald;
16 }
17 }
18 }
19 return $newNodes;
20 }
21
22 public function flatten( $arr, &$out ) {
23 foreach ( $arr as $item ) {
24 if ( !is_array( $item ) ) {
25 $out[] = $item;
26 continue;
27 }
28
29 foreach ( $item as $nestedItem ) {
30 if ( is_array( $nestedItem ) ) {
31 self::flatten( $nestedItem, $out );
32 } else {
33 $out[] = $nestedItem;
34 }
35 }
36 }
37
38 return $out;
39 }
40
41 }