Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\SessionHandlerInterface::read return type error #12748

Closed
alexkart opened this issue Mar 17, 2025 · 1 comment · Fixed by phpstan/phpstan-src#3884
Closed

\SessionHandlerInterface::read return type error #12748

alexkart opened this issue Mar 17, 2025 · 1 comment · Fixed by phpstan/phpstan-src#3884
Labels
Milestone

Comments

@alexkart
Copy link

alexkart commented Mar 17, 2025

Bug report

In the following code $session = $sessionHandler->read('123'); PhpStan assumes that $session is string but it can be string or false according to PHP docs https://www.php.net/manual/en/sessionhandlerinterface.read.php

public SessionHandlerInterface::read(string $id): string|false

PhpStan generates the following error for this code:

if ($session === false) {
	return null;
}
Strict comparison using === between string and false will always evaluate to false.

Code snippet that reproduces the problem

https://phpstan.org/r/a1080965-9212-4b2a-af05-3ce9fa7734cc

Expected output

No errors.

Did PHPStan help you today? Did it make you happy in any way?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants