You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently attempted to upgrade from 0.2.0 to 0.3.0 and found that the contains operators are incompatible because the argument orders are reversed.
This code dumps "true" for version 0.2.0 and "false" for version 0.3.0:
$haystack = new \Ruler\Variable('haystack');
$needle = new \Ruler\Variable('needle');
$rule = new Ruler\Rule(new Ruler\Operator\LogicalAnd([
new Ruler\Operator\Contains($needle, $haystack)
])
);
$context = new \Ruler\Context([
'haystack' => 'The quick brown fox',
'needle' => 'quick',
]);
var_dump($rule->evaluate($context));
I suspect part of the issue is the ambiguity of left/right - clearly the author in 0.2.0 had one idea and the author of 0.3.0 had a different idea about what left/right meant. It would be helpful to clarify this in the documentation and to note the incompatibility so that would be upgraders won't be in for an unpleasant surprise.
The text was updated successfully, but these errors were encountered:
I recently attempted to upgrade from 0.2.0 to 0.3.0 and found that the contains operators are incompatible because the argument orders are reversed.
This code dumps "true" for version 0.2.0 and "false" for version 0.3.0:
I realize that in 0.3.0 the contains operator is deprecated. If I replace the contains operator usage above with StringContains, false instead of true is dumped out.
The difference appears to be in the class Value and how strpos is called:
https://github.com/bobthecow/Ruler/blob/v0.2.0/src/Ruler/Value.php#L73
https://github.com/bobthecow/Ruler/blob/v0.3.0/src/Ruler/Value.php#L92
I suspect part of the issue is the ambiguity of left/right - clearly the author in 0.2.0 had one idea and the author of 0.3.0 had a different idea about what left/right meant. It would be helpful to clarify this in the documentation and to note the incompatibility so that would be upgraders won't be in for an unpleasant surprise.
The text was updated successfully, but these errors were encountered: