| Subject | Details |
| :------------- | :---------------------------------------------------------------------------- |
| Plugin | Php Inspections (EA Extended) - v3.0.13 |
| Language level | PHP 7.3.1 |
Code like this:
$foo = $_COOKIE['bar'] ?? '';
$foo = substr($bar, 3) ?? '';
Produces the warnings:
Resolved operands types are not complimentary, while they should be ([string, array] vs [string]).
Resolved operands types are not complimentary, while they should be ([bool, string] vs [string]).
These are from Code Style > Proper null-coalescing operator usage.
That inspection has an option "Verify complimentary operands types" which would let me turn the checking off completely, but really I'd like an additional option for 'Match if types overlap'. So that if there is an intersection between the 2 arrays in the warning messages it would mark it as a pass.
E.g.
OK: [string, array] vs [string]
OK: [string, array] vs [bool, string]
Not OK: [string] vs [int]
Not OK: [string, array] vs [bool, int]
Implemented!
I'm sorry, I just got this warning. What problem will it cause, and how should I fix it?
$foo = $_COOKIE['bar'] ?? '';
Most helpful comment
Implemented!