[BUG] Volt - "in" array check did not work as expected if multiple conditions
Expected and Actual Behavior
Well, the issue is ease to reproduce. Lets look that example in volt:
{% if 'Tes' in ['Tes', 'Test2'] %}
YEY
{% endif %}
Will return "YEY", but in that example:
{% if 'Tes' in ['Tes', 'Test2'] and 'Tes2' in ['Tes2', 'Test3'] %}
YEY
{% endif %}
...will throw exception: "Phalcon\Mvc\View\Exception: Invalid haystack" and the reason is (volt php generated code):
<?php if ($this->isIncluded($this->isIncluded('Tes', ['Tes', 'Test2'] && 'Tes2'), ['Tes2', 'Test3'])) { ?>
YEY
<?php } ?>
If I place the conditions in brackets - it works. The question is- is it a feature i didnt know about... or it is a little volt bug?
:) Greeeetings! and may the force be with u!
Details
- Phalcon version: 3.4.3
- PHP Version: 7.3.2
- Operating System: Windows 64
- Server: Apache
Can you try this?
{% if ('Tes' in ['Tes', 'Test2']) and ('Tes2' in ['Tes2', 'Test3']) %}
Well... When i place brackets it works. Yes, i already confirm that in first post. Amm... okay. Just dont think regular developer will think about that... Php 'if-else' conditions can be used without brackets.
@borisdelev It is most likely something that we can work with in the volt parser to make it identical to PHP. Personally I don't recall seeing this because I am always using parentheses and @sergeyklay is nagging at me all the time :)
If you want you can add an issue to be checked in the future.
@niden no worries, u right. Have fun and... be happy :)