BladeScanner
class BladeScanner
Finds the code Blade compiles in a view by following Blade's own passes, without compiling the view.
Traits
Constants
| private VERBATIM_REGEX |
Verbatim blocks, which Blade sets aside before compiling anything else. |
| private PHP_BLOCK_REGEX |
Blocks of PHP statements, which Blade sets aside next. |
| private COMMENT_REGEX |
|
| private DIRECTIVE_REGEX |
The start of a directive with arguments, up to its opening parenthesis. Blade leaves an @@ prefixed directive, or one that follows a word character as in an email address, as text. |
Properties
| protected Container|null | $container | from HasContainer |
Methods
Set aside the verbatim and @php blocks and remove the comments, as Blade does before compiling anything else.
Get the text outside a view's PHP tags, which is what Blade compiles, with each block's line.
Get the directives with arguments that Blade compiles in the given text, with each one's argument list and its offset.
Take the matches of the given pattern out of the view text, keeping every offset and line.
Details
in
HasContainer at line 19
void
setContainer(Container $container)
Set the container used for resolution.
in
HasContainer at line 27
Container
getContainer()
Return the current container.
in
HasContainer at line 35
mixed
resolve(string $abstract)
Resolve the given type from the container.
at line 65
array
setAside(string $source)
Set aside the verbatim and @php blocks and remove the comments, as Blade does before compiling anything else.
Each is blanked in the source, keeping every offset and line. Blade sets the blocks aside before it removes comments, so a comment around a block removes the block too.
at line 97
array
text(string $source)
Get the text outside a view's PHP tags, which is what Blade compiles, with each block's line.
Blade splits the view with PHP's tokenizer, so a view whose PHP only becomes valid once Blade compiles it, such as native PHP opening a block that @endif closes, still has text.
at line 118
array
directives(string $html)
Get the directives with arguments that Blade compiles in the given text, with each one's argument list and its offset.
Blade leaves an unknown directive as text, and a custom directive's handler decides what its arguments mean, so neither is included.
at line 157
array
take(string $pattern, string $html)
Take the matches of the given pattern out of the view text, keeping every offset and line.