-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Hey! How are you doing?
I just wanted to point out that this part of the code is kind of misleading.
json-logic-php/src/JWadhams/JsonLogic.php
Lines 173 to 179 in 060aab5
| '-' => function ($a, $b=null) { | |
| if ($b===null) { | |
| return -$a; | |
| } else { | |
| return $a - $b; | |
| } | |
| }, |
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!