Skip to content

Revert "Docs: Indicate absint() returns non-negative-int for static analysis. - #12940

Closed
dmsnell wants to merge 2 commits into
WordPress:trunkfrom
dmsnell:revert/absint-type-is-not-int
Closed

Revert "Docs: Indicate absint() returns non-negative-int for static analysis.#12940
dmsnell wants to merge 2 commits into
WordPress:trunkfrom
dmsnell:revert/absint-type-is-not-int

Conversation

@dmsnell

@dmsnell dmsnell commented Aug 7, 2026

Copy link
Copy Markdown
Member

Trac ticket: Core-65826
Replaces #12917

This reverts commit 395dd74.

When the return-type annotation was added to absint() it failed to recoginize that the function can return float as well. In the cases where it does this, WordPress started crashing requests.

Reverting remove the type constraint where PHP enforces it in order to avoid the fatal errors.

…ic analysis."

Trac ticket: Core-65826
Replaces WordPress#12917

This reverts commit 395dd74.

When the return-type annotation was added to `absint()` it failed to
recoginize that the function can return `float` as well. In the cases
where it does this, WordPress started crashing requests.

Reverting remove the type constraint where PHP enforces it in order
to avoid the fatal errors.

Co-Authored-By: Joseph Scott <josephscott@git.wordpress.org>
Co-Authored-By: Weston Ruter <westonruter@git.wordpress.org>
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dmsnell, westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Comment on lines -21 to -25
-
message: '#^Strict comparison using \!\=\= between ''all'' and int will always evaluate to true\.$#'
identifier: notIdentical.alwaysTrue
count: 1
path: ../../../src/wp-admin/includes/class-wp-links-list-table.php

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was confused why this error went away, but it makes sense to me now.

It's the int native type hint which makes PHPStan more strict, beyond the @return int type in phpdoc.

So with just PHPDoc saying it @return int, then if ( 'all' !== $cat_id ) { is not considered an error.

Since in theory the function could still return non-int and not be a PHP error.

But with a native int type hint, then it absolutely never can happen.

pento pushed a commit that referenced this pull request Aug 7, 2026
The introduction of a return-type annotation for `absint()` created fatal errors in cases where the function returns a `float` value. This resulted when the value passed into the function is smaller than `PHP_INT_MIN`. Since PHP’s `int` type is unable to represent the magnitude of that number in the positive, it returns a `float` value instead.

Reverting the type annotation prevents the crashing, but additional follow-up is warranted to ensure that the function produces the expected return types.

Developed in: #12940
Discussed in: https://core.trac.wordpress.org/ticket/65826

Follow-up to [62647].

Props dmsnell, josephscott, westonruter.
Fixes #65826. See #64898.


git-svn-id: https://develop.svn.wordpress.org/trunk@63158 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 63158
GitHub commit: 6fe43d7

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Aug 7, 2026
@dmsnell
dmsnell deleted the revert/absint-type-is-not-int branch August 7, 2026 19:13
@dmsnell
dmsnell restored the revert/absint-type-is-not-int branch August 7, 2026 19:14
@dmsnell
dmsnell deleted the revert/absint-type-is-not-int branch August 7, 2026 19:14
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Aug 7, 2026
The introduction of a return-type annotation for `absint()` created fatal errors in cases where the function returns a `float` value. This resulted when the value passed into the function is smaller than `PHP_INT_MIN`. Since PHP’s `int` type is unable to represent the magnitude of that number in the positive, it returns a `float` value instead.

Reverting the type annotation prevents the crashing, but additional follow-up is warranted to ensure that the function produces the expected return types.

Developed in: WordPress/wordpress-develop#12940
Discussed in: https://core.trac.wordpress.org/ticket/65826

Follow-up to [62647].

Props dmsnell, josephscott, westonruter.
Fixes #65826. See #64898.

Built from https://develop.svn.wordpress.org/trunk@63158


git-svn-id: http://core.svn.wordpress.org/trunk@62357 1a063a9b-81f0-0310-95a4-ce76da25c4cd
DanielHudson2 pushed a commit to DanielHudson2/wordpress-develop that referenced this pull request Aug 10, 2026
The introduction of a return-type annotation for `absint()` created fatal errors in cases where the function returns a `float` value. This resulted when the value passed into the function is smaller than `PHP_INT_MIN`. Since PHP’s `int` type is unable to represent the magnitude of that number in the positive, it returns a `float` value instead.

Reverting the type annotation prevents the crashing, but additional follow-up is warranted to ensure that the function produces the expected return types.

Developed in: WordPress#12940
Discussed in: https://core.trac.wordpress.org/ticket/65826

Follow-up to [62647].

Props dmsnell, josephscott, westonruter.
Fixes #65826. See #64898.


git-svn-id: https://develop.svn.wordpress.org/trunk@63158 602fd350-edb4-49c9-b593-d223f7449a82
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 this pull request may close these issues.

2 participants