Move the whole compiler GET of the component object to now use the container->component object/class.

This commit is contained in:
2023-01-22 02:38:21 +02:00
parent f44f385159
commit e6c02a29f6
115 changed files with 13148 additions and 6292 deletions

View File

@@ -502,9 +502,9 @@ abstract class Minify
protected static function str_replace_first($search, $replace, $subject)
{
$pos = strpos($subject, $search);
$pos = strpos((string) $subject, (string) $search);
if ($pos !== false) {
return substr_replace($subject, $replace, $pos, strlen($search));
return substr_replace((string) $subject, (string) $replace, $pos, strlen((string) $search));
}
return $subject;

View File

@@ -174,7 +174,7 @@ class Css extends Minify
$matches = array();
foreach ($importRegexes as $importRegex) {
if (preg_match_all($importRegex, $content, $regexMatches, PREG_SET_ORDER)) {
$matches = array_merge($matches, $regexMatches);
$matches = [...$matches, ...$regexMatches];
}
}
@@ -390,7 +390,7 @@ class Css extends Minify
$matches = array();
foreach ($relativeRegexes as $relativeRegex) {
if (preg_match_all($relativeRegex, $content, $regexMatches, PREG_SET_ORDER)) {
$matches = array_merge($matches, $regexMatches);
$matches = [...$matches, ...$regexMatches];
}
}
@@ -498,9 +498,7 @@ class Css extends Minify
return preg_replace_callback(
'/(?<=[: ])(' . implode('|', array_keys($colors)) . ')(?=[; }])/i',
function ($match) use ($colors) {
return $colors[strtoupper($match[0])];
},
fn($match) => $colors[strtoupper((string) $match[0])],
$content
);
}
@@ -519,9 +517,7 @@ class Css extends Minify
'bold' => 700,
);
$callback = function ($match) use ($weights) {
return $match[1] . $weights[$match[2]];
};
$callback = fn($match) => $match[1] . $weights[$match[2]];
return preg_replace_callback('/(font-weight\s*:\s*)(' . implode('|', array_keys($weights)) . ')(?=[;}])/', $callback, $content);
}
@@ -662,7 +658,7 @@ class Css extends Minify
$minifier = $this;
$callback = function ($match) use ($minifier, $pattern, &$callback) {
$function = $match[1];
$length = strlen($match[2]);
$length = strlen((string) $match[2]);
$expr = '';
$opened = 0;
@@ -710,7 +706,7 @@ class Css extends Minify
'/(?<=^|[;}{])\s*(--[^:;{}"\'\s]+)\s*:([^;{}]+)/m',
function ($match) use ($minifier) {
$placeholder = '--custom-' . count($minifier->extracted) . ':0';
$minifier->extracted[$placeholder] = $match[1] . ':' . trim($match[2]);
$minifier->extracted[$placeholder] = $match[1] . ':' . trim((string) $match[2]);
return $placeholder;
}

View File

@@ -421,9 +421,9 @@ class JavaScript extends Minify
$minifier = $this;
$callback = function ($match) use ($minifier) {
if (
substr($match[2], 0, 1) === '!' ||
strpos($match[2], '@license') !== false ||
strpos($match[2], '@preserve') !== false
substr((string) $match[2], 0, 1) === '!' ||
strpos((string) $match[2], '@license') !== false ||
strpos((string) $match[2], '@preserve') !== false
) {
// preserve multi-line comments that start with /*!
// or contain @license or @preserve annotations
@@ -735,9 +735,7 @@ class JavaScript extends Minify
$escaped = array_map('preg_quote', $keywords, $delimiter);
// add word boundaries
array_walk($keywords, function ($value) {
return '\b' . $value . '\b';
});
array_walk($keywords, fn($value) => '\b' . $value . '\b');
$keywords = array_combine($keywords, $escaped);
@@ -820,7 +818,7 @@ class JavaScript extends Minify
* character and check if it's a `.`
*/
$callback = function ($match) {
if (trim($match[1]) === '.') {
if (trim((string) $match[1]) === '.') {
return $match[0];
}