Phpinspectionsea: [FP] "explode(...) limit can be used" when leaving out the first item in destructuring

Created on 11 Dec 2019  路  3Comments  路  Source: kalessil/phpinspectionsea


| Subject | Details |
| :------------- | :---------------------------------------------------------------------------- |
| Plugin | Php Inspections (EA Ultimate) |
| Language level | PHP 7.2 |

Current behaviour

When leaving out the first parameter of list(...) EA thinks the second one is the first and suggests adding the $limit parameter to explode(...) which changes the behavior of the code.
image

Expected behaviour

The inspection doesn't get triggered.

bug / false-positive fixed

All 3 comments

Confirmed.

[ , $b ] = explode(',', 'a,b,c,d');  
// Should suggests: 
// explode(',', 'a,b,c,d', 3);
// But suggests: 
// explode(',', 'a,b,c,d', 2);

Additionally, it is not triggered when have more than one variable:

[ $a, $b ] = explode(',', 'a,b,c,d');  
// Should suggests: 
// explode(',', 'a,b,c,d', 3);

Will fix! Thank you for reporting @jdreesen and @rentalhost for confirming.

Fixed!

Was this page helpful?
0 / 5 - 0 ratings