Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Increment and arrays creates unparsable PHP code #8
Use Opt 2.1 beta 1 and execute a post-increment operation (and probably other, related operations) on arrays, like in the example below.
This results in really wired PHP code, which ends up with a parser error.
<?php echo $ctx->_data['list']++$ctx->_data['list']++['index']++; ?>
... parseable PHP code like the following.
<?php echo $ctx->_data['list']['index']++; ?>
Using no arrays (from a template point of view), works. The following template creates the correct PHP code shown afterwards.
<?php echo $ctx->_data['foo']++; ?>
A similar problem (probably caused by the same reason) is an array assignment like the following template and compiled PHP code shows.
<?php $ctx->_data['item']='Location'['type']='Location'; ?>
Create a copy of the array value and modify that copy.