-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Version: "devtheorem/php-handlebars": "^0.9.8"
PHP Version: PHP 8.4.12
The Compiler::section() method generates functions like this for an {{#each}} block:
function($cx, $in) {return ' * '.LR::encq($in).'
'.$sp.'';}When {{#each}} is called in a partial that function is then wrapped in another function
'phpDoc' => function ($cx, $in, $sp) {return ''.$sp.''.((LR::ifvar($in['phpDoc'] ?? null, false)) ? '/**
'.$sp.''.((LR::ifvar($in['phpDoc']['description'] ?? null, false)) ? ''.LR::sec($cx, $in['phpDoc']['description'] ?? null, null, $in, true, function($cx, $in) {return ' * '.LR::encq($in).'
'.$sp.'';}).'' : '').' */
'.$sp.'' : '').'';}The wrapping function is passed in $sp, which is the whitespace to put before each line. However the each function isn't passed the whitespace, and the generated function doesn't have a use ($sp) to allow it to access the variable from outside its scope.
This means that the template throws warnings (and presumably that whitespace is lost inside the each blocks)
PHP Warning: Undefined variable $sp in /path/to/vendor/devtheorem/php-handlebars/src/Handlebars.php(41) : eval()'d code on line 29
partial used for testing:
{{#if phpDoc}}
/**
{{#if phpDoc.description}}
{{#each phpDoc.description}}
* {{this}}
{{/each}}
{{/if}}
*/
{{/if}}