vimeo/psalm

Incorrect assumptions about mysqli object parameters

Open

#4,502 opened on Nov 7, 2020

View on GitHub
 (6 comments) (0 reactions) (0 assignees)PHP (668 forks)batch import
Help wantedenhancementinternal stubs/callmap

Repository metrics

Stars
 (5,369 stars)
PR merge metrics
 (Avg merge 3d 12h) (5 merged PRs in 30d)

Description

Example: https://psalm.dev/r/c8e212f816

Psalm assumes the PHP documentation is correct. It is not. Specifically the Mysqli object has a lot of shady stuff going on with strange states of the connection.

In PHP 7.4 sqlstate is false in an empty Mysqli object while client_info is a string. client_info will also be false when a connection is attempted and fails. To make matters worse, the behavior of the class in edge cases like this changes between PHP versions. (I know it's different in PHP 8 and in older PHP 5 versions)

Contributor guide