The math expression engine has several faults:
1) max() and min() don't work because functions can have only one argument.
2) There is no support for strings.
3) There is no support for if() or equality operators.
This significant retool improves this engine quite a bit, adding a simple if(), basic equality operators, fixing max() and min(), and adding support for strings as long as they're quoted. It also improves code style a little bit, though maybe not vastly, because I just used PHPStorm's re-format.
Create tests (Added as issue tag): see.
I noticed another bug, too: strtolower() is inappropriate. Added a TODO to the growing list. I would appreciate feedback on these:
- TODO: Is this supposed to remove all constants? we should remove all
- TODO: Because the expr can contain string operands, using strtolower here is a bug.
- TODO: A really bad idea: It might be good for those using the 12,345.67
User interface changes
Data model changes