-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Docs: Replace void with null in union return types in Administration #11008
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
544414a
b123868
2f1d8d5
7d677fa
12a2bc5
0a3e8f1
4013816
8f8ec70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -982,15 +982,15 @@ function wp_write_post() { | |||||
| * | ||||||
| * @since 2.0.0 | ||||||
| * | ||||||
| * @return int|void Post ID on success, void on failure. | ||||||
| * @return int|never Post ID on success. Dies on failure. | ||||||
|
||||||
| * @return int|never Post ID on success. Dies on failure. | |
| * @return int|0|never Post ID on success, 0 on failure that is not represented as WP_Error. Dies on WP_Error failures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Humm. 0 is an int
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But a special int.
Joke aside, I made Claude review all core
That pattern (int|0) doesn't make sense as a PHPDoc type anyway — 0 isn't a type, it's a value
But none of them use 0 as a literal type in the union (like int|0|WP_Error). They all use int|WP_Error as the type and explain the 0 value in the description text.
The int|0|never pattern from your question doesn't exist anywhere in core. Literal value types like 0 in @return unions aren't a convention WordPress follows — the only instance is @return -1|0|1 in the vendored SimplePie library, which is a
spaceship-operator-style comparison return.
So I'd say this falls under AI hallucination.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, using a literal for a type is okay, and PHPStan supports that. But it doesn't make sense when int is a superset of 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And according to the research through core it was never done besides the vendored library. And -1|0|1 is cherry picking 3 ints, vs int|0 is saying all integers and a single one from all integers. So thats a huge difference.
Uh oh!
There was an error while loading. Please reload this page.