Skip to content
This repository was archived by the owner on May 8, 2021. It is now read-only.
This repository was archived by the owner on May 8, 2021. It is now read-only.

Increment and arrays creates unparsable PHP code #8

@skruppy

Description

@skruppy

Reproduction

Use Opt 2.1 beta 1 and execute a post-increment operation (and probably other, related operations) on arrays, like in the example below.

{u:$list.index++}

Result

This results in really wired PHP code, which ends up with a parser error.

<?php echo $ctx->_data['list']++$ctx->_data['list']++['index']++;   ?>
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in foo.tpl.php

Expected

... parseable PHP code like the following.

<?php echo $ctx->_data['list']['index']++;   ?>

Appendix

Using no arrays (from a template point of view), works. The following template creates the correct PHP code shown afterwards.

{u:$foo++}
<?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.

{$item.type is 'Location'}
<?php $ctx->_data['item']='Location'['type']='Location';   ?>

Workaroud

Create a copy of the array value and modify that copy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions