Generating invalid PHP code with Hoa\Ruler\Visitor\Compiler::visit
crislinu opened this issue · 1 comments
crislinu commented
Hi,
If we have the following rule:
user.logged() = true and points > 30
then when we try to see the PHP code needed to create the model, we will get a PHP code that has syntax errors.
echo Hoa\Ruler\Ruler::interprete(
'user.logged() = true and points > 30'
);
/**
* Will output:
* $model = new \Hoa\Ruler\Model();
* $model->expression =
* $model->and(
* $model->{'='}(
* $model->variable('user')
* ->call(
* $model->func(
* 'logged',
*
* )
* ),
* true
* ),
* $model->{'>'}(
* $model->variable('points'),
* 30
* )
* );
*/
You can see that right after logged
there is a comma and then a closed parenthesis. This leads to a syntax error.
This happens when a method is called with no arguments. The logged
method has no arguments.
Hywan commented
Thank you :-). We have to close another issue (we will do it today) before addressing this one.