BladeCompiler
class BladeCompiler extends Compiler implements CompilerInterface (View source)
Traits
Properties
protected Filesystem | $files | The filesystem instance. |
from Compiler |
protected string | $cachePath | The cache path for the compiled views. |
from Compiler |
protected string | $basePath | The base path that should be removed from paths before hashing. |
from Compiler |
protected bool | $shouldCache | Determines if compiled views should be cached. |
from Compiler |
protected string | $compiledExtension | The compiled view file extension. |
from Compiler |
static protected array | $componentHashStack | The component name hash stack. |
from CompilesComponents |
protected bool | $firstCaseInSwitch | Identifier for the first case in the switch statement. |
from CompilesConditionals |
protected array | $echoHandlers | Custom rendering callbacks for stringable objects. |
from CompilesEchos |
protected string | $lastFragment | The last compiled fragment. |
from CompilesFragments |
protected string | $lastSection | The name of the last section that was started. |
from CompilesLayouts |
protected int | $forElseCounter | Counter to keep track of nested forelse statements. |
from CompilesLoops |
protected array | $extensions | All of the registered extensions. |
|
protected array | $customDirectives | All custom "directive" handlers. |
|
protected array | $conditions | All custom "condition" handlers. |
|
protected array | $prepareStringsForCompilationUsing | The registered string preparation callbacks. |
|
protected array | $precompilers | All of the registered precompilers. |
|
protected string | $path | The file currently being compiled. |
|
protected string[] | $compilers | All of the available compiler functions. |
|
protected string[] | $rawTags | Array of opening and closing tags for raw echos. |
|
protected string[] | $contentTags | Array of opening and closing tags for regular echos. |
|
protected string[] | $escapedTags | Array of opening and closing tags for escaped echos. |
|
protected string | $echoFormat | The "regular" / legacy echo string format. |
|
protected array | $footer | Array of footer lines to be added to the template. |
|
protected array | $rawBlocks | Array to temporarily store the raw blocks found in the template. |
|
protected array | $anonymousComponentPaths | The array of anonymous component paths to search for components in. |
|
protected array | $anonymousComponentNamespaces | The array of anonymous component namespaces to autoload from. |
|
protected array | $classComponentAliases | The array of class component aliases and their class names. |
|
protected array | $classComponentNamespaces | The array of class component namespaces to autoload from. |
|
protected bool | $compilesComponentTags | Indicates if component tags should be compiled. |
|
protected | $template |
Methods
Create a new compiler instance.
Create the compiled file directory if necessary.
Compile the can statements into valid PHP.
Compile the cannot statements into valid PHP.
Compile the canany statements into valid PHP.
Compile the else-can statements into valid PHP.
Compile the else-cannot statements into valid PHP.
Compile the else-canany statements into valid PHP.
Compile the end-cannot statements into valid PHP.
Compile the end-canany statements into valid PHP.
Compile the conditional class statement into valid PHP.
Compile Blade comments into an empty string.
Compile the component statements into valid PHP.
Get a new component hash for a component name.
Compile a class component opening.
Compile the end-component statements into valid PHP.
Compile the end-component statements into valid PHP.
Compile the slot statements into valid PHP.
Compile the component-first statements into valid PHP.
Compile the end-component-first statements into valid PHP.
Compile the prop statement into valid PHP.
Compile the aware statement into valid PHP.
Sanitize the given component attribute value.
Compile the if-auth statements into valid PHP.
Compile the else-auth statements into valid PHP.
Compile the env statements into valid PHP.
Compile the production statements into valid PHP.
Compile the end-production statements into valid PHP.
Compile the if-guest statements into valid PHP.
Compile the else-guest statements into valid PHP.
Compile the has-section statements into valid PHP.
Compile the section-missing statements into valid PHP.
Compile the if statements into valid PHP.
Compile the unless statements into valid PHP.
Compile the else-if statements into valid PHP.
Compile the end-unless statements into valid PHP.
Compile the if-isset statements into valid PHP.
Compile the switch statements into valid PHP.
Compile the case statements into valid PHP.
Compile the default statements in switch case into valid PHP.
Compile the end switch statements into valid PHP.
Compile a once block into valid PHP.
Compile a boolean value into a raw true / false value for embedding into HTML attributes or JavaScript.
Compile a checked block into valid PHP.
Compile a disabled block into valid PHP.
Compile a required block into valid PHP.
Compile a readonly block into valid PHP.
Compile a selected block into valid PHP.
Compile the push statements into valid PHP.
Compile the else-if push statements into valid PHP.
Compile the else push statements into valid PHP.
Add a handler to be executed before echoing a given class.
Add an instance of the blade echo handler to the start of the compiled string.
Wrap the echoable value in an echo handler if applicable.
Apply the echo handler for the value if it exists.
Compile the error statements into valid PHP.
Compile the enderror statements into valid PHP.
Compile the fragment statements into valid PHP.
Compile the end-fragment statements into valid PHP.
Compile the "dd" statements into valid PHP.
Compile the "dump" statements into valid PHP.
Compile the method statements into valid PHP.
Compile the "vite" statements into valid PHP.
Compile the "viteReactRefresh" statements into valid PHP.
Compile the each statements into valid PHP.
Compile the include statements into valid PHP.
Compile the include-if statements into valid PHP.
Compile the include-when statements into valid PHP.
Compile the include-unless statements into valid PHP.
Compile the include-first statements into valid PHP.
Compile the inject statements into valid PHP.
Compile the extends statements into valid PHP.
Compile the extends-first statements into valid PHP.
Compile the section statements into valid PHP.
Compile the yield statements into valid PHP.
Compile the for-else statements into valid PHP.
Compile the for-else-empty and empty statements into valid PHP.
Compile the for-each statements into valid PHP.
Compile the break statements into valid PHP.
Compile the continue statements into valid PHP.
Compile the while statements into valid PHP.
Compile the raw PHP statements into valid PHP.
Compile the unset statements into valid PHP.
Compile the session statements into valid PHP.
Compile the endsession statements into valid PHP.
Compile the stack statements into the content.
Compile the push statements into valid PHP.
Compile the push-once statements into valid PHP.
Compile the end-push-once statements into valid PHP.
Compile the prepend statements into valid PHP.
Compile the prepend-once statements into valid PHP.
Compile the end-prepend-once statements into valid PHP.
Compile the conditional style statement into valid PHP.
Compile the lang statements into valid PHP.
Compile the choice statements into valid PHP.
Compile the use statements into valid PHP.
Get the class name of the first parameter of the given Closure.
Get the class names of the first parameter of the given Closure, including union types.
Get the class names / types of the parameters of the given Closure.
Compile the view at the given path.
Append the file path to the compiled string.
Get the open and closing PHP tag tokens from the given string.
Get the path currently being compiled.
Set the path currently being compiled.
Compile the given Blade template contents.
No description
Details
protected void
ensureCompiledDirectoryExists(string $path)
Create the compiled file directory if necessary.
protected string
compileElsecannot(string $expression)
Compile the else-cannot statements into valid PHP.
protected string
compileElsecanany(string $expression)
Compile the else-canany statements into valid PHP.
protected string
compileClass(string $expression)
Compile the conditional class statement into valid PHP.
protected string
compileComponent(string $expression)
Compile the component statements into valid PHP.
static string
compileClassComponentOpening(string $component, string $alias, string $data, string $hash)
Compile a class component opening.
protected string
compileComponentFirst(string $expression)
Compile the component-first statements into valid PHP.
protected string
compileEndComponentFirst()
Compile the end-component-first statements into valid PHP.
protected string
compileAuth(string|null $guard = null)
Compile the if-auth statements into valid PHP.
protected string
compileElseAuth(string|null $guard = null)
Compile the else-auth statements into valid PHP.
protected string
compileGuest(string|null $guard = null)
Compile the if-guest statements into valid PHP.
protected string
compileElseGuest(string|null $guard = null)
Compile the else-guest statements into valid PHP.
protected string
compileHasSection(string $expression)
Compile the has-section statements into valid PHP.
protected string
compileSectionMissing(string $expression)
Compile the section-missing statements into valid PHP.
protected string
compileBool(bool $condition)
Compile a boolean value into a raw true / false value for embedding into HTML attributes or JavaScript.
protected string
compileElsePushIf(string $expression)
Compile the else-if push statements into valid PHP.
protected string
compileElsePush(string $expression)
Compile the else push statements into valid PHP.
void
stringable(string|callable $class, callable|null $handler = null)
Add a handler to be executed before echoing a given class.
protected string
addBladeCompilerVariable(string $result)
Add an instance of the blade echo handler to the start of the compiled string.
protected string
wrapInEchoHandler(string $value)
Wrap the echoable value in an echo handler if applicable.
protected string
compileEnderror(string $expression)
Compile the enderror statements into valid PHP.
protected string
compileFragment(string $expression)
Compile the fragment statements into valid PHP.
protected string
compileViteReactRefresh()
Compile the "viteReactRefresh" statements into valid PHP.
protected string
compileIncludeIf(string $expression)
Compile the include-if statements into valid PHP.
protected string
compileIncludeWhen(string $expression)
Compile the include-when statements into valid PHP.
protected string
compileIncludeUnless(string $expression)
Compile the include-unless statements into valid PHP.
protected string
compileIncludeFirst(string $expression)
Compile the include-first statements into valid PHP.
protected string
compileExtendsFirst(string $expression)
Compile the extends-first statements into valid PHP.
protected string
compileForelse(string|null $expression)
Compile the for-else statements into valid PHP.
protected string
compileEmpty(string $expression)
Compile the for-else-empty and empty statements into valid PHP.
protected string
compileForeach(string|null $expression)
Compile the for-each statements into valid PHP.
protected string
compileContinue(string $expression)
Compile the continue statements into valid PHP.
protected string
compileEndsession(string $expression)
Compile the endsession statements into valid PHP.
protected string
compilePushOnce(string $expression)
Compile the push-once statements into valid PHP.
protected string
compilePrependOnce(string $expression)
Compile the prepend-once statements into valid PHP.
protected string
compileStyle(string $expression)
Compile the conditional style statement into valid PHP.
protected string
firstClosureParameterType(Closure $closure)
Get the class name of the first parameter of the given Closure.
protected array
firstClosureParameterTypes(Closure $closure)
Get the class names of the first parameter of the given Closure, including union types.
protected array
closureParameterTypes(Closure $closure)
Get the class names / types of the parameters of the given Closure.
protected Collection
getOpenAndClosingPhpTokens(string $contents)
Get the open and closing PHP tag tokens from the given string.