Skip to content

Remove greater.invalid baseline and fix its issue - #13080

Open
dpanta94 wants to merge 2 commits into
WordPress:trunkfrom
dpanta94:fix/phpstan-baselines.6
Open

Remove greater.invalid baseline and fix its issue#13080
dpanta94 wants to merge 2 commits into
WordPress:trunkfrom
dpanta94:fix/phpstan-baselines.6

Conversation

@dpanta94

Copy link
Copy Markdown

Removes in total 1 errors.

Removes errors from the below phpstan baselines and fixes the issues that they were covering:

  • greater.invalid

How ?

Removes dead else if statement.

Trac ticket: https://core.trac.wordpress.org/ticket/65817

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 5
Used for: Help with suggesting how to fix the phpstan output for the specific errors we are removing the baselines for. The actual result has been reviewed and are owned by me.


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.

@github-actions

github-actions Bot commented Aug 16, 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 dpantazis, dmsnell.

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

@github-actions

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.

$content_length = array(
'type' => 'byte',
'length' => $length,
);

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.

it seems like this function was written when get_col_length() could return a string, and then was moved in 1cccb02 and stuck around even though get_col_length() was changed in 2ce97b2 to never return a string. this dangled on unused.

to that end it seems like this should be safe to remove.

that being said, if we remove it we make the code fragile, because we remove a runtime-enforced type constraint with a source-time assumption about it. if get_col_length() changes again as it changed in the past, this could lead to a crash on property access of a non-array.

the original code would have been clearer as if ( is_string() ) than if ( ! is_array() ), but we could potentially remove this and leave the safety.

} elseif ( ! is_array( $content_length ) ) {
	return;
}

PHPStan might still complain, but avoiding crashes is more important than making the linter gods happy

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think i can come up with a way so that phpstan is not compalining but at the same time im also covering the case you are mentioning.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 99dc673

@dpanta94
dpanta94 force-pushed the fix/phpstan-baselines.6 branch 2 times, most recently from 99dc673 to ddb0d21 Compare August 18, 2026 21:28
@dpanta94
dpanta94 force-pushed the fix/phpstan-baselines.6 branch from ddb0d21 to aadca60 Compare August 23, 2026 13:05
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