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

void
setContainer(Container $container)

Set the container used for resolution.

getContainer()

Return the current container.

mixed
resolve(string $abstract)

Resolve the given type from the container.

array
setAside(string $source)

Set aside the verbatim and @php blocks and remove the comments, as Blade does before compiling anything else.

array
text(string $source)

Get the text outside a view's PHP tags, which is what Blade compiles, with each block's line.

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.

array
take(string $pattern, string $html)

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.

Parameters

Container $container

Return Value

void

in HasContainer at line 27
Container getContainer()

Return the current container.

Return Value

Container

in HasContainer at line 35
mixed resolve(string $abstract)

Resolve the given type from the container.

Parameters

string $abstract

Return Value

mixed

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.

Parameters

string $source

Return Value

array

the content and offset of each remaining verbatim block, then of each remaining @php block

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.

Parameters

string $source

Return Value

array

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.

Parameters

string $html

Return Value

array

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.

Parameters

string $pattern
string $html

Return Value

array