Open
Description
Subject | Details |
---|---|
Plugin | PHP Inspections (EA Ultimate) |
Language level | 8.4 |
Question
The plugins seems to forget the types of the variables declared before a require_once.
Flor example:
<?php
declare(strict_types=1);
function get_test(): array|false {
return [
'TEST' => 'test',
'TOST' => 'tost',
'TIST' => 'tist',
];
}
function test(): void {
if (!($test = get_test())) {
return;
}
echo $test['TEST'], "\n";
require_once 'huh.php';
echo $test['TEST'], "\n";
}
Above examplew show no problem with the first echo, but de second echo gets marked by the PHP Inspections plugin with: [EA] '$test' may not support offset operations (or its type not annotated properly: [bool, array]).
Am I doing something wrong (apart from doing requires inside code, which I like to do, because it groups the require with the code that requires the require, instead of ending up with 30 requires at the top of a function or file)
Metadata
Metadata
Assignees
Labels
No labels