| Subject | Details |
| :--------- | :------------------------------------------------------- |
| Issue type | Bug |
| IDE | PhpStorm v2018.2.2 |
| Plugin | Php Inspections (EA Extended), v3.0.5.1 |
This section of code is producing a red inspection warning on the return line:
// Ensure that series with specific types are listed before others
usort($allSeries, function ($firstItem, $secondItem) {
return !array_key_exists('type', $firstItem) <=> !array_key_exists('type', $secondItem);
});
The message when hovering over is:
Operations priority might differ from what you expect: please wrap needed with '(...)'.
When seeing what the suggested completion is, the inspection is named 'Suspicious binary operations' and the corrected form of the return line looks like this:
return (!array_key_exists('type', $firstItem)) <=> !array_key_exists('type', $secondItem);
To me, the original line doesn't contain any strange operator precedence. As far as I understand PHP, both of the 'not' (!) operators are right associative and should bind to their immediate right expression, which are the results of array_key_exists(). The spaceship (<=>) operator should then work on these two expressions, which has the same precedence as identity ===, which when substituted for the spaceship doesn't produce the warning.
Unless there's some flaw in this logic, then this error shouldn't appear.
Thank you for reporting @jtaylor100, fixed (spaceship operator will not be analyzed in this context).
Thanks for the quick fix!