Docs: Replace void with null in union return types in class-wpdb.php#11009
Docs: Replace void with null in union return types in class-wpdb.php#11009apermo wants to merge 16 commits intoWordPress:trunkfrom
Conversation
Fixes #64703. See #64694. Co-Authored-By: xateman
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
PHPStan cannot verify that wp_die() always terminates due to its conditional return type and treatPhpDocTypesAsCertain being disabled.
Co-authored-by: Christoph Daum <christoph.daum@coding-pioneers.com>
3206f60 to
7b4fbe7
Compare
Co-authored-by: Weston Ruter <westonruter@gmail.com>
|
I've cherry-picked the |
* trunk: (330 commits) Media: Guard against `false` return values from `wp_get_attachment_image_src()` and `wp_getimagesize()`. Code Quality: Replace `is_integer()` with `is_int()` for consistency. Tests: Prevent unconditional HTTP request in `PluralFormsTest` data provider. Code Quality: Simplify boolean assignments. Admin reskin: Remove line-height from input fields. Tests: Fix test that checks MySQL version recommendation. Exports: Exclude `wp_sync_storage` post type from exports. Code Quality: Unwrap `sprintf()` with one argument. Build/Test Tools: Add 7.0-RC2 to upgrade testing workflows. Upgrade/Install: Use new default admin color scheme for language dropdown on the setup screen. Post 7.0 branching version bump. Build/Test Tools: Post-branching updates for `trunk`. Build/Test Tools: Remove unintentional change in [62157]. Build/Test Tools: Remove PHP requirement for the build script. Tests: Add unit tests for `wp_timezone_choice()`. Build/Test: Set svn:global-ignore for built block files. Admin: Add CSS fallback values in button and media views. Post WordPress 7.0 RC 2 version bump. WordPress 7.0 RC 2. Follow-up to [62150]. Bump script versions with `npm run dev`. ...
Add explicit return null at the end of the method to match the documented return type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When show_errors is true, wp_die() is called which never returns. When false, it returns false. So the only actual return value is false. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add explicit return null when the version check passes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two early-exit paths used bare return; instead of return null; to match the documented @return string|null type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When col_info is empty, the method fell through without an explicit return statement. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…elated functions. Replace `void` in union return types with `null`, `false`, or `never` as appropriate, and add explicit `return null` statements where methods previously fell through without a return value. Methods updated in `wpdb`: `prepare()`, `print_error()`, `check_connection()`, `get_row()`, `get_col_info()`, `bail()`, `check_database_version()`. Also adds `@return never` to `dead_db()` and fixes the `@phpstan-return` syntax for `wp_die()`. Developed in #11009 Props apermo, westonruter, xate, mukesh27, SergeyBiryukov. Fixes #64703. git-svn-id: https://develop.svn.wordpress.org/trunk@62177 602fd350-edb4-49c9-b593-d223f7449a82
…elated functions. Replace `void` in union return types with `null`, `false`, or `never` as appropriate, and add explicit `return null` statements where methods previously fell through without a return value. Methods updated in `wpdb`: `prepare()`, `print_error()`, `check_connection()`, `get_row()`, `get_col_info()`, `bail()`, `check_database_version()`. Also adds `@return never` to `dead_db()` and fixes the `@phpstan-return` syntax for `wp_die()`. Developed in WordPress/wordpress-develop#11009 Props apermo, westonruter, xate, mukesh27, SergeyBiryukov. Fixes #64703. Built from https://develop.svn.wordpress.org/trunk@62177 git-svn-id: http://core.svn.wordpress.org/trunk@61459 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Co-Authored-By: xateman
Trac ticket: https://core.trac.wordpress.org/ticket/64703
Use of AI Tools
Used AI for research, documentation and for the replacements. Everything was reviewed by myself and @xateman before opening this PR.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
Drafted Commit Message
Docs: Replace
voidwithnullin union return types inclass-wpdb.php.This also adds a
@return nevertodead_db()in addition to fixing the syntax in the conditional@phpstan-returnforwp_die().Developed in #11009
Follow-up to r61699, r47944, r32654.
Props apermo, westonruter, xate, mukesh27, SergeyBiryukov.
See #64694, #64238.
Fixes #64703.