Closed pascalbaljet closed 1 year ago
The linked line refers to the compilation behavior of
@php ($counter = 1)
The following will also produce the same resulting PHP as the library:
<?php
use Illuminate\Support\Facades\Blade;
$result = Blade::compileString('@php $counter = 1 @endphp');
Example of behavior parity:
nvm (shouldn't review when so tired) - spotted the issue
Corrected in 1.0.3 🙂
Nice! I've found another case that leads to a false positive:
@php
if ($someVar) {
echo 'Yes';
} else {
echo 'No';
}
@endphp
Nice! I've found another case that leads to a false positive:
@php if ($someVar) { echo 'Yes'; } else { echo 'No'; } @endphp
Is this triggering the Anticipated PHP compilation error: [syntax error, unexpected end of file]
for you in 1.0.3? If so, are there any other @php
directives in the template?
I'm have trouble reproducing on the latest version with that template by itself. Thanks!
Blade supports PHP code without a closing semicolon:
The validator returns this error:
Anticipated PHP compilation error: [syntax error, unexpected end of file]
See also: https://github.com/laravel/framework/blob/0ec445970da249578296796ee0aeefc03813bc23/src/Illuminate/View/Compilers/Concerns/CompilesRawPhp.php#L16