Phpinspectionsea: Explode false positive when assigning variables with list like construct

Created on 14 Jan 2020  路  6Comments  路  Source: kalessil/phpinspectionsea

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

Current behaviour

        $str = 'kikoo1,kikoo2,kikoo3';
        [$kikoo1, $kikoo2, $kikoo3] = explode( ',', $str);

A warning is raised. "[EA] 'explode(',', $str, 2)' could be used here (only some parts has been used). "

Expected behaviour

No. Warning. if we had 2, a php error is raised.

Environment details

duplicate

Most helpful comment

Looks like a duplicate of #1463

I think it's more a duplicate of #1484

All 6 comments

No. Warning. if we had 2, a php error is raised.

It shouldn't: https://3v4l.org/cNKVr

Do you have an example of an error in such case?

I don't understand, you have modified the code so it's normal it work. It should be:

$str = 'kikoo1,kikoo2,kikoo3';
[$kikoo1, $kikoo2, $kikoo3] = explode( ',', $str, 2);

Looks like a duplicate of https://github.com/kalessil/phpinspectionsea/issues/1463

I am closing.

I don't understand, you have modified the code so it's normal it work.

Sorry, I misread the suggested fix.

Looks like a duplicate of #1463

I think it's more a duplicate of #1484

Duplicates #1484

Was this page helpful?
0 / 5 - 0 ratings