Phpinspectionsea: Could provoke a PHP Fatal error ([] operator not supported for strings) triggered when it should not

Created on 22 Jan 2019  路  5Comments  路  Source: kalessil/phpinspectionsea

| Subject | Details |
| :------------- | :---------------------------------------------------------------------------- |
| Issue type | Bug |
| Plugin | Php Inspections (EA Extended) v3.0.10 |
| Language level | PHP 7.2 |

In some cases _Could provoke a PHP Fatal error ([] operator not supported for strings)_ is triggered when it should not.

image

class A {

    protected $prefix = 'abc';
    protected $array = [];

    public function __construct(): void {
        $_POST[$this->prefix][] = $this->prefix;

        $this->array[$this->prefix][] = $this->prefix;
    }

}


$prefix = 'abc';
$_POST[$prefix][] = $prefix;

$prefix = 'abc';
$array = [];
$array[$prefix][] = $prefix;

No error should be triggered

PhpStorm 2018.3.3 (Installed from Jetbrains Toolbox)
Fedora 28, KDE Plasma

bug / false-positive fixed

All 5 comments

Thank you for reporting @Mandy91 , I'll take a look why this gets reported. Agree that superglobals should not be reported in this context.

Fixed!

@kalessil , this problem is back in PHPStorm 2020. EA Extended 4.0.4.1.

image

@kalessil , this problem is back in PHPStorm 2020. EA Extended 4.0.4.1.

image

Same herre
image

PHPStorm 2020.1.2
EA Extended 4.0.5

Hi guys,
The problem is back in version 2020.3.2
EA Extended 4.0.6

Was this page helpful?
0 / 5 - 0 ratings