-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
phpstan/phpstan-src
#3901Description
Bug report
One of the recent releases broke the check and now PHPStan reports that isset is redundant when it really isn't.
<?php
declare(strict_types=1);
final class ErrorReportController
{
public function __invoke(ServerRequest $request)
{
if (
isset($_SESSION['prev_error_subm_time'], $_SESSION['error_subm_count'])
&& $_SESSION['error_subm_count'] >= 3
&& ($_SESSION['prev_error_subm_time'] - time()) <= 3000
) {
$_SESSION['error_subm_count'] = 0;
$_SESSION['prev_errors'] = '';
} else {
$_SESSION['prev_error_subm_time'] = time();
$_SESSION['error_subm_count'] = isset($_SESSION['error_subm_count'])
? $_SESSION['error_subm_count'] + 1
: 0;
}
}
}
Offset 'error_subm_count' on non-empty-array in isset() always exists and is not nullable.
Code snippet that reproduces the problem
https://phpstan.org/r/1a948bae-f71e-4886-a376-1d2aadd11b03
Expected output
There should be no warning about the offset.
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels