From f446d717b8477313893d3e8798f595ebfbae8429 Mon Sep 17 00:00:00 2001 From: Francis Date: Sat, 7 Oct 2023 00:38:22 +0100 Subject: [PATCH 1/4] Update Less Analyzer to be able to handle imports of files Related to #73 - option 2, if you wish to see a more indepth writeup The Less Analyzer class cannot handle Less files that import css as the object they convert into mean the $node->path->value is a Link_Tree_Quoted object and not a string castable value, so we add an additional check for if we are a CSS quoted file or if value is an object which contains another value and use that instead (In the off chance similar future issues may arise with new objects) --- src/Analyzer/Less/Analyzer.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Analyzer/Less/Analyzer.php b/src/Analyzer/Less/Analyzer.php index 1ef3fe02..5bf402df 100644 --- a/src/Analyzer/Less/Analyzer.php +++ b/src/Analyzer/Less/Analyzer.php @@ -128,7 +128,11 @@ private function getNodes(LessRegistry $registry): array if (property_exists($node, 'name')) { $nodeKey = $node->name; } elseif (property_exists($node, 'type') && property_exists($node, 'path')) { - $nodeKey = $node->type . ' with value: \'' . $node->path->value . '\''; + if ($node->path->value instanceof \Less_Tree_Quoted || property_exists($node->path->value, 'value')) { + $nodeKey = $node->type . ' with value: \'' . $node->path->value->value . '\''; + } else { + $nodeKey = $node->type . ' with value: \'' . $node->path->value . '\''; + } } else { $nodeKey = get_class($node); } From d201d711ba32a51c85909368d78eb598180c00a7 Mon Sep 17 00:00:00 2001 From: Francis Date: Sat, 7 Oct 2023 00:56:13 +0100 Subject: [PATCH 2/4] Avoid line length issue on expanded conditional --- src/Analyzer/Less/Analyzer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Analyzer/Less/Analyzer.php b/src/Analyzer/Less/Analyzer.php index 5bf402df..7f2d36a9 100644 --- a/src/Analyzer/Less/Analyzer.php +++ b/src/Analyzer/Less/Analyzer.php @@ -128,8 +128,9 @@ private function getNodes(LessRegistry $registry): array if (property_exists($node, 'name')) { $nodeKey = $node->name; } elseif (property_exists($node, 'type') && property_exists($node, 'path')) { - if ($node->path->value instanceof \Less_Tree_Quoted || property_exists($node->path->value, 'value')) { - $nodeKey = $node->type . ' with value: \'' . $node->path->value->value . '\''; + if ($node->path->value instanceof \Less_Tree_Quoted + || property_exists($node->path->value, 'value')) + { $nodeKey = $node->type . ' with value: \'' . $node->path->value->value . '\''; } else { $nodeKey = $node->type . ' with value: \'' . $node->path->value . '\''; } From dafe4dc86a885b48bd9e87e98318c10ce372ebe2 Mon Sep 17 00:00:00 2001 From: Francis Date: Sat, 7 Oct 2023 00:57:06 +0100 Subject: [PATCH 3/4] Correct spacing issue caused by quick copy/paste --- src/Analyzer/Less/Analyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Analyzer/Less/Analyzer.php b/src/Analyzer/Less/Analyzer.php index 7f2d36a9..b2b8665e 100644 --- a/src/Analyzer/Less/Analyzer.php +++ b/src/Analyzer/Less/Analyzer.php @@ -130,7 +130,8 @@ private function getNodes(LessRegistry $registry): array } elseif (property_exists($node, 'type') && property_exists($node, 'path')) { if ($node->path->value instanceof \Less_Tree_Quoted || property_exists($node->path->value, 'value')) - { $nodeKey = $node->type . ' with value: \'' . $node->path->value->value . '\''; + { + $nodeKey = $node->type . ' with value: \'' . $node->path->value->value . '\''; } else { $nodeKey = $node->type . ' with value: \'' . $node->path->value . '\''; } From 1a61439a2607240250e32d306a7e1d4e08de615f Mon Sep 17 00:00:00 2001 From: Francis Date: Sat, 7 Oct 2023 01:00:13 +0100 Subject: [PATCH 4/4] Fix trailing whitespace I really shouldn't edit on git gui at 1am --- src/Analyzer/Less/Analyzer.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Analyzer/Less/Analyzer.php b/src/Analyzer/Less/Analyzer.php index b2b8665e..45faedfd 100644 --- a/src/Analyzer/Less/Analyzer.php +++ b/src/Analyzer/Less/Analyzer.php @@ -128,9 +128,10 @@ private function getNodes(LessRegistry $registry): array if (property_exists($node, 'name')) { $nodeKey = $node->name; } elseif (property_exists($node, 'type') && property_exists($node, 'path')) { - if ($node->path->value instanceof \Less_Tree_Quoted - || property_exists($node->path->value, 'value')) - { + if ( + $node->path->value instanceof \Less_Tree_Quoted + || property_exists($node->path->value, 'value') + ) { $nodeKey = $node->type . ' with value: \'' . $node->path->value->value . '\''; } else { $nodeKey = $node->type . ' with value: \'' . $node->path->value . '\'';