Docs: Replace void with null in union return types in link-template.php#11004
Docs: Replace void with null in union return types in link-template.php#11004apermo wants to merge 1 commit intoWordPress:trunkfrom
Conversation
Update 13 functions in `link-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 #64699. 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. |
noruzzamans
left a comment
There was a problem hiding this comment.
The modernization in link-template.php to replace void with null in union types looks solid and aligns with PHP standards. I appreciate the attention to detail in updating the function bodies as well—like the explicit return null; in get_edit_comment_link()—ensuring they match the new PHPDoc types. Everything is consistently implemented and follows the coding standards.
|
@noruzzamans Are you using AI to write #11004 (review) and #11022 (review)? You should disclose this, if so, for example the model and how you prompted it. AI reviews can be helpful, but not if they don't add value; in the worst case, they can just add noise. (The em-dashes in your comment are a tell that AI was used.) Thanks! |
Update 13 functions in
link-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/64699
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.