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

Incomplete mysqli extension stubs #9851

Closed
braindawg opened this issue May 31, 2023 · 3 comments · Fixed by #10155
Closed

Incomplete mysqli extension stubs #9851

braindawg opened this issue May 31, 2023 · 3 comments · Fixed by #10155
Labels
easy problems Issues that can be fixed without background knowledge of Psalm enhancement internal stubs/callmap

Comments

@braindawg
Copy link

The current mysqli extension stubs contain only a handful of the classes and methods that the extension defines. Notable absences that have tripped up my project in CI environments that do not install the mysqli extension (e.g. while using psalm/psalm-github-actions) include:

  • class mysqli_sql_exception
  • const MYSQLI_ASSOC
  • const MYSQLI_USE_RESULT
  • const MYSQLI_REPORT_ERROR
  • const MYSQLI_REPORT_STRICT
  • const MYSQLI_OPT_CONNECT_TIMEOUT

While fixing these gaps, I think it would be worthwhile to fill in all of the missing constants defined by this extension. Looks like the acpu and dom extensions both define globally-namespaced constants as well, although the stubs for those extensions use different syntax for defining them (define vs. const).

If it's acceptable to copy stubs from php/php-src, we could go ahead and fill in all of the mysqli-defined class APIs and procedural function stubs based on https://github.com/php/php-src/blob/master/ext/mysqli/mysqli.stub.php as well, although I get the sense from other issues/PRs that the php/php-src stubs are not necessarily 100% accurate/current.

@psalm-github-bot
Copy link

Hey @braindawg, can you reproduce the issue on https://psalm.dev ?

@braindawg
Copy link
Author

Hey @braindawg, can you reproduce the issue on https://psalm.dev ?

Can't reproduce. It appears that that environment has the mysqli extension enabled, as constants not defined in the stubs are available.

@orklah
Copy link
Collaborator

orklah commented Jun 1, 2023

I'm not familiar with the licensing of php stubs, it may be worth to ask them if we can just copy them

The syntax used for constants in stubs doesn't matter, for Psalm it's basically more code to analyse. Anything that works in userland will work in stubs

@weirdan weirdan added easy problems Issues that can be fixed without background knowledge of Psalm internal stubs/callmap enhancement labels Aug 26, 2023
weirdan added a commit to weirdan/psalm that referenced this issue Aug 27, 2023
weirdan added a commit to weirdan/psalm that referenced this issue Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy problems Issues that can be fixed without background knowledge of Psalm enhancement internal stubs/callmap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants