Skip to content

Tracking: PHPStan Remediations#1

Open
justlevine wants to merge 35 commits intofeat/phpstanfrom
chore/phpstan/level-0
Open

Tracking: PHPStan Remediations#1
justlevine wants to merge 35 commits intofeat/phpstanfrom
chore/phpstan/level-0

Conversation

@justlevine
Copy link
Copy Markdown
Owner

Remediating PHPStan fixes in-situ.

Individual fixes are cherry-picked into separate PRs onto trunk, and then removed from here when this is periodically rebased.

Trac ticket:


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
Copy link
Copy Markdown

github-actions Bot commented Apr 12, 2025

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 justlevine.

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

@justlevine justlevine force-pushed the chore/phpstan/level-0 branch from ba1b7ed to 6c9e72b Compare May 10, 2025 14:27
@justlevine justlevine force-pushed the feat/phpstan branch 2 times, most recently from 6695813 to 947a5fe Compare May 23, 2025 16:46
@justlevine justlevine force-pushed the chore/phpstan/level-0 branch from 682af29 to 7a29cd9 Compare May 23, 2025 17:59
@justlevine justlevine force-pushed the chore/phpstan/level-0 branch 3 times, most recently from 2ea3189 to 0802cca Compare May 31, 2025 18:22
@justlevine justlevine force-pushed the chore/phpstan/level-0 branch from f69ef87 to c575bbb Compare June 1, 2025 16:31
@justlevine justlevine force-pushed the chore/phpstan/level-0 branch 2 times, most recently from e4cbd2f to 3277cd6 Compare June 12, 2025 21:55
@justlevine justlevine force-pushed the chore/phpstan/level-0 branch from 3277cd6 to 7a54a48 Compare June 18, 2025 17:53
@justlevine justlevine force-pushed the feat/phpstan branch 2 times, most recently from 47d4cd2 to f1f214d Compare June 28, 2025 07:40
@justlevine justlevine force-pushed the chore/phpstan/level-0 branch 2 times, most recently from bec2a94 to bee227b Compare June 28, 2025 09:43
@justlevine justlevine force-pushed the chore/phpstan/level-0 branch from bee227b to 738b3b5 Compare July 8, 2025 22:24
@justlevine justlevine force-pushed the chore/phpstan/level-0 branch from 738b3b5 to 03e7452 Compare July 19, 2025 16:45
@justlevine justlevine force-pushed the chore/phpstan/level-0 branch from a199310 to 80d3039 Compare July 26, 2025 09:00
It's the entrypoint into this codeblock two lines above
remove_query_arg() only takes `string|string[]`. Added a comment because it took me 5 minutes to understand _why_ we were using
@justlevine justlevine force-pushed the chore/phpstan/level-0 branch from 80d3039 to edabf22 Compare October 24, 2025 21:37
justlevine pushed a commit that referenced this pull request Mar 16, 2026
…om `previous_posts()`.

The `esc_url()` function expects to a string for `$url` parameter. There is no input validation within that function. The function contains a `ltrim()` which also expects a string. Passing `null` to this parameter results in `Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated` notice on PHP 8.1+.

Tracing the stack back, a `null` is being passed to it within `previous_posts()` when `get_previous_posts_page_link()` returns `null` (it can return a string or `null`).

On PHP 7.0 to PHP 8.x, an empty string is returned from `esc_url()` when `null` is passed to it. The change in this changeset avoids the deprecation notice by not invoking `esc_url()` when `get_previous_posts_page_link()` returns `null` and instead sets the `$output` to an empty string, thus maintaining the same behavior as before (minus the deprecation notice).

Adds a test to validate an empty string is returned and the absence of the deprecation (when running on PHP 8.1+).

Follow-up to [9632], [11383], [56740].

Props dd32, alexodiy.
Fixes #64864.

git-svn-id: https://develop.svn.wordpress.org/trunk@62034 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.

1 participant