Skip to content

Commit

Permalink
Add some spacing and clean up method formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Mar 18, 2024
1 parent 1d62edc commit 30f27af
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions monorepo/CodeIntelligence/CodeIntelligence.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 30f27af

Please sign in to comment.