Add in and not-in expression operators (#170)#179
Conversation
Add support for 'in' and 'not in' (written as '! in') as expression-level
operators, enabling SQL-like membership tests in Zephir code.
Syntax:
if x in [1, 2, 3] { }
if x ! in [1, 2, 3] { }
The parser produces AST nodes with types 'in' and 'not-in' respectively.
The existing 'in' keyword for for-loops is unaffected.
Closes #170
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #179 +/- ##
==========================================
+ Coverage 77.07% 77.24% +0.17%
==========================================
Files 5 5
Lines 2992 2997 +5
Branches 131 131
==========================================
+ Hits 2306 2315 +9
+ Misses 686 682 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
Closing this PR. After investigating the original cphalcon issue (phalcon/cphalcon#16812), the root cause is a string literal typo in The PHQL scanner/parser already handles See analysis comment: phalcon/cphalcon#16812 (comment) |



Summary
Add support for
inandnot in(! in) as expression-level operators, enabling SQL-like membership tests in Zephir code.Resolves #170
Related: phalcon/cphalcon#16812
Syntax
AST Output
expr in exprproduces a node with type"in"expr ! in exprproduces a node with type"not-in"Changes
INto operator precedence (same level asINSTANCEOF). Added two newxx_common_exprgrammar rules forinandnot in.inandnot intest.ininsideforloops still works andinas expression works within loop bodies.Notes
inkeyword forforloops is completely unaffected (0 parser conflicts)."in"and"not-in"AST node types — a companion issue will be created inzephir-lang/zephir.In raising this pull request, I confirm the following: