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

When WP_Mock is included as dev-dependency, the IDE or static analyzers might flag some WP functions with uncaught exceptions #248

Closed
unfulvio opened this issue Jun 28, 2024 · 0 comments · Fixed by #245
Assignees

Comments

@unfulvio
Copy link
Collaborator

Bug report

WP_Mock adds some function mocks for some common WP functions (mostly gettext related) that are expected to return the arg they are passed to (such as in gettext, when no translations are applied).

In WP_Mock because they are funneled to an handler, this could technically throw an assertion exception (relevant to tests only). However, because these mocks have the same name as WP functions, the result is that the IDE or some static analyzers will assume they will throw an uncaught exception in the codebase, which isn't true. The solution in #245 improves phpdocs so that this false positive should no longer happen.

Replication steps

This happened to me when working at some WP codebase where WP Mock was included as dev dependency in PHPStorm.

Expected behavior

PHPStorm shouldn't flag those functions as throwing exceptions, because that's not what they do in WP.

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

Successfully merging a pull request may close this issue.

7 participants