json-logic-php icon indicating copy to clipboard operation
json-logic-php copied to clipboard

Incoherent behaviour

Open RedNeath opened this issue 7 months ago • 0 comments
trafficstars

Hey! How are you doing?

I just wanted to point out that this part of the code is kind of misleading. https://github.com/jwadhams/json-logic-php/blob/060aab5ad36ae1fdd74d3006131b197ca777fa48/src/JWadhams/JsonLogic.php#L173-L179

In the javascript implementation, for the minus operation, the verification is undefined, not null (see this).

The problem is that, with the js implementation, if you try to put two items, the second one being null, you will end up with the first item as a result. However, if you do the same in PHP, you will end up with the opposite of the first item.

I think this is quite a bad thing, since most people (just as I did) will probably test your library on your website, using the js implementation, and then start building their use case with this functioning in mind, and encounter problems if they use a different implementation.

So what should we do? It's up to you to decide, but I think it really is necessary to remain coherent between the multiple implementations you developed over the time 😄

Have a nice day!

RedNeath avatar Apr 11 '25 15:04 RedNeath