validation-bugsnag-email
This commit is contained in:
		| @@ -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; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 RafficMohammed
					RafficMohammed