Docs: Replace void with null in union return types in general-template.php#11005
Docs: Replace void with null in union return types in general-template.php#11005apermo wants to merge 1 commit intoWordPress:trunkfrom
Conversation
…e.php Update 10 functions in `general-template.php` to use `null` instead of `void` in `@return` union types, and change bare `return;` statements to `return null;`. In PHP's type system, `void` cannot be part of a union type. A bare `return;` actually returns `null` at runtime, so `@return Type|null` is the correct annotation. Fixes #64700. See #64694. Co-Authored-By: xateman <xateman@users.noreply.github.com>
|
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. |
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. |
Update 10 functions in
general-template.phpto usenullinstead ofvoidin@returnunion types, and change barereturn;statements toreturn null;.In PHP's type system,
voidcannot be part of a union type. A barereturn;actually returnsnullat runtime, so@return Type|nullis the correct annotation.Trac ticket: https://core.trac.wordpress.org/ticket/64700
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.