validation-bugsnag-email

This commit is contained in:
RafficMohammed
2023-01-31 13:17:59 +05:30
parent 2ec836b447
commit 9dd3f53910
769 changed files with 20242 additions and 14060 deletions

View File

@@ -499,16 +499,67 @@ class BladeCompiler extends Compiler implements CompilerInterface
/**
* Compile Blade statements that start with "@".
*
* @param string $value
* @param string $template
* @return string
*/
protected function compileStatements($value)
protected function compileStatements($template)
{
return preg_replace_callback(
'/\B@(@?\w+(?:::\w+)?)([ \t]*)(\( ( (?>[^()]+) | (?3) )* \))?/x', function ($match) {
return $this->compileStatement($match);
}, $value
);
preg_match_all('/\B@(@?\w+(?:::\w+)?)([ \t]*)(\( ( [\S\s]*? ) \))?/x', $template, $matches);
for ($i = 0; isset($matches[0][$i]); $i++) {
$match = [
$matches[0][$i],
$matches[1][$i],
$matches[2][$i],
$matches[3][$i] ?: null,
$matches[4][$i] ?: null,
];
// Here we check to see if we have properly found the closing parenthesis by
// regex pattern or not, and will recursively continue on to the next ")"
// then check again until the tokenizer confirms we find the right one.
while (isset($match[4]) &&
Str::endsWith($match[0], ')') &&
! $this->hasEvenNumberOfParentheses($match[0])) {
$rest = Str::before(Str::after($template, $match[0]), ')');
$match[0] = $match[0].$rest.')';
$match[3] = $match[3].$rest.')';
$match[4] = $match[4].$rest;
}
$template = Str::replaceFirst($match[0], $this->compileStatement($match), $template);
}
return $template;
}
/**
* Determine if the given expression has the same number of opening and closing parentheses.
*
* @param string $expression
* @return bool
*/
protected function hasEvenNumberOfParentheses(string $expression)
{
$tokens = token_get_all('<?php '.$expression);
if (Arr::last($tokens) !== ')') {
return false;
}
$opening = 0;
$closing = 0;
foreach ($tokens as $token) {
if ($token == ')') {
$closing++;
} elseif ($token == '(') {
$opening++;
}
}
return $opening === $closing;
}
/**

View File

@@ -52,7 +52,7 @@ trait CompilesHelpers
/**
* Compile the "vite" statements into valid PHP.
*
* @param ?string $arguments
* @param string|null $arguments
* @return string
*/
protected function compileVite($arguments)

View File

@@ -90,6 +90,49 @@ class View implements ArrayAccess, Htmlable, ViewContract
});
}
/**
* Get the evaluated contents for a given array of fragments.
*
* @param array $fragments
* @return string
*/
public function fragments(array $fragments)
{
return collect($fragments)->map(fn ($f) => $this->fragment($f))->implode('');
}
/**
* Get the evaluated contents of a given fragment if the given condition is true.
*
* @param bool $boolean
* @param string $fragment
* @return string
*/
public function fragmentIf($boolean, $fragment)
{
if (value($boolean)) {
return $this->fragment($fragment);
}
return $this->render();
}
/**
* Get the evaluated contents for a given array of fragments if the given condition is true.
*
* @param bool $boolean
* @param array $fragments
* @return string
*/
public function fragmentsIf($boolean, array $fragments)
{
if (value($boolean)) {
return $this->fragments($fragments);
}
return $this->render();
}
/**
* Get the string contents of the view.
*