summaryrefslogtreecommitdiffstats
path: root/library/vendor/lessphp/lib/Less/VisitorReplacing.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:39:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:39:39 +0000
commit8ca6cc32b2c789a3149861159ad258f2cb9491e3 (patch)
tree2492de6f1528dd44eaa169a5c1555026d9cb75ec /library/vendor/lessphp/lib/Less/VisitorReplacing.php
parentInitial commit. (diff)
downloadicingaweb2-8ca6cc32b2c789a3149861159ad258f2cb9491e3.tar.xz
icingaweb2-8ca6cc32b2c789a3149861159ad258f2cb9491e3.zip
Adding upstream version 2.11.4.upstream/2.11.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--library/vendor/lessphp/lib/Less/VisitorReplacing.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/library/vendor/lessphp/lib/Less/VisitorReplacing.php b/library/vendor/lessphp/lib/Less/VisitorReplacing.php
new file mode 100644
index 0000000..b773d46
--- /dev/null
+++ b/library/vendor/lessphp/lib/Less/VisitorReplacing.php
@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * Replacing Visitor
+ *
+ * @package Less
+ * @subpackage visitor
+ */
+class Less_VisitorReplacing extends Less_Visitor {
+
+ public function visitObj( $node ) {
+ $funcName = 'visit'.$node->type;
+ if ( isset( $this->_visitFnCache[$funcName] ) ) {
+
+ $visitDeeper = true;
+ $node = $this->$funcName( $node, $visitDeeper );
+
+ if ( $node ) {
+ if ( $visitDeeper && is_object( $node ) ) {
+ $node->accept( $this );
+ }
+
+ $funcName .= "Out";
+ if ( isset( $this->_visitFnCache[$funcName] ) ) {
+ $this->$funcName( $node );
+ }
+ }
+
+ } else {
+ $node->accept( $this );
+ }
+
+ return $node;
+ }
+
+ public function visitArray( $nodes ) {
+ $newNodes = array();
+ foreach ( $nodes as $node ) {
+ $evald = $this->visitObj( $node );
+ if ( $evald ) {
+ if ( is_array( $evald ) ) {
+ self::flatten( $evald, $newNodes );
+ } else {
+ $newNodes[] = $evald;
+ }
+ }
+ }
+ return $newNodes;
+ }
+
+ public function flatten( $arr, &$out ) {
+ foreach ( $arr as $item ) {
+ if ( !is_array( $item ) ) {
+ $out[] = $item;
+ continue;
+ }
+
+ foreach ( $item as $nestedItem ) {
+ if ( is_array( $nestedItem ) ) {
+ self::flatten( $nestedItem, $out );
+ } else {
+ $out[] = $nestedItem;
+ }
+ }
+ }
+
+ return $out;
+ }
+
+}