From 30f27af0eb7c5b53613abcf42b3b1bfa5dc8cfd9 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 18 Mar 2024 18:49:51 +0100 Subject: [PATCH] Add some spacing and clean up method formatting --- .../CodeIntelligence/CodeIntelligence.php | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/monorepo/CodeIntelligence/CodeIntelligence.php b/monorepo/CodeIntelligence/CodeIntelligence.php index e3c4de806bf..af94714f0c0 100644 --- a/monorepo/CodeIntelligence/CodeIntelligence.php +++ b/monorepo/CodeIntelligence/CodeIntelligence.php @@ -497,24 +497,25 @@ protected function findBladeElementClasses(): array foreach ($this->bladeFiles as $contents) { // Extract static classes from dynamic Alpine.js classes containing boolean logic - $contents = preg_replace_callback( - '/:class=(["\'])(.*?)\1/', - function (array $matches): string { - $staticClasses = ''; - $dynamicClasses = $matches[2]; - - // Parse the dynamic classes to separate static classes - preg_match_all('/\'\s*([^\'\s]*)\s*\'/', $dynamicClasses, $staticMatches); - if (! empty($staticMatches[1])) { - $staticClasses = sprintf('class="%s"', implode(' ', $staticMatches[1])); - } + $contents = preg_replace_callback('/:class=(["\'])(.*?)\1/', function (array $matches): string { + $staticClasses = ''; + $dynamicClasses = $matches[2]; + + // Parse the dynamic classes to separate static classes + preg_match_all('/\'\s*([^\'\s]*)\s*\'/', $dynamicClasses, $staticMatches); + if (! empty($staticMatches[1])) { + $staticClasses = sprintf('class="%s"', implode(' ', $staticMatches[1])); + } - return $staticClasses; - }, + return $staticClasses; + }, $contents ); + $matches = []; + preg_match_all('/class="([^"]+)"/', $contents, $matches); + foreach ($matches[1] as $match) { $match = explode(' ', $match); foreach ($match as $class) {