Cphalcon: [BUG]: Volt is defined and array in

Created on 5 Feb 2020  路  3Comments  路  Source: phalcon/cphalcon

Questions? Forum: https://phalcon.link/forum or Discord: https://phalcon.link/discord

Describe the bug
Using these two together will give the wrong result.

Steps to reproduce the behavior:

Provide minimal script to reproduce the issue

// WRONG Result:
{% if categoryIds is defined AND category['id'] in categoryIds %}
    checked
{% endif %}

// Correct Result:
{% if categoryIds is defined AND (category['id'] in categoryIds) %}
    checked
{% endif %}

Expected behavior
A clear and concise description of what you expected to happen.

// WRONG RESULT
<?php if ($this->isIncluded(isset($categoryIds) && $category['id'], $categoryIds)) { ?>
   checked
<php } ?>

// Correct RESULT
<?php if (isset($categoryIds) && $this->isIncluded($category['id'], $categoryIds)) { ?>
   checked
<php } ?>

Screenshots
If applicable, add screenshots to help explain your problem.

Details

  • Phalcon version: v3.4.5
  • PHP Version: 7.3
  • Operating System: Windows
  • Installation type: installing via package manager
  • Zephir version (if any): Latest
  • Server: FASTCGI
bug medium

All 3 comments

Confirmed, here is screenshot of generated code from volt

image

Details
Phalcon version: 4.0.x
PHP version: 7.4

This needs work on the PHQL parser since the right part after the && is not parsed on its own.

For now the workaround with parentheses works but the suggested syntax should work also.

Fixed in 4.0.x branch. Thank you for the report, and for helping us make Phalcon better.

Was this page helpful?
0 / 5 - 0 ratings