From 82288f67c97a30b9d7aa376c8cfe4219baf0d23c Mon Sep 17 00:00:00 2001 From: rejaulalomkhan Date: Sun, 11 Oct 2026 09:25:49 +0600 Subject: [PATCH 1/2] Code Quality: Annotate WP_HTML_Processor::next_token() as impure for PHPStan. WP_HTML_Processor::next_token() advances the internal parser state, mutates element queues, and changes current depth and bookmarks as side effects. PHPStan inferred the method as pure, which caused loops in WP_Block::replace_rich_text() to be analyzed as constant and led to a false positive booleanOr.alwaysTrue error. Annotating next_token() with @phpstan-impure accurately reflects its side-effecting behavior and allows the booleanOr.alwaysTrue baseline to be retired. Follow-up to [63301], [63357]. See #65817. --- phpstan.neon.dist | 1 - .../html-api/class-wp-html-processor.php | 2 ++ .../baselines/booleanOr.alwaysTrue.neon | 25 ------------------- 3 files changed, 2 insertions(+), 26 deletions(-) delete mode 100644 tests/phpstan/baselines/booleanOr.alwaysTrue.neon diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c4fda7711f053..1178d5be82c0e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -32,7 +32,6 @@ includes: - tests/phpstan/baselines/booleanNot.alwaysFalse.neon - tests/phpstan/baselines/booleanNot.alwaysTrue.neon - tests/phpstan/baselines/booleanOr.alwaysFalse.neon - - tests/phpstan/baselines/booleanOr.alwaysTrue.neon - tests/phpstan/baselines/class.notFound.neon - tests/phpstan/baselines/deadCode.unreachable.neon - tests/phpstan/baselines/empty.offset.neon diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index f6d0d548223b5..01533bb853d13 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -778,6 +778,8 @@ public function next_tag( $query = null ): bool { * @since 6.5.0 Added for internal support; do not use. * @since 6.7.2 Refactored so subclasses may extend. * + * @phpstan-impure + * * @return bool Whether a token was parsed. */ public function next_token(): bool { diff --git a/tests/phpstan/baselines/booleanOr.alwaysTrue.neon b/tests/phpstan/baselines/booleanOr.alwaysTrue.neon deleted file mode 100644 index 3f72ffc6821cc..0000000000000 --- a/tests/phpstan/baselines/booleanOr.alwaysTrue.neon +++ /dev/null @@ -1,25 +0,0 @@ -# PHPStan baseline for the `booleanOr.alwaysTrue` errors in WordPress core. -# -# https://phpstan.org/error-identifiers/booleanOr.alwaysTrue -# -# Each entry is scoped to a single file and carries an exact occurrence count, -# so that a new instance is reported as a new error rather than being absorbed -# silently. Fixing an occurrence therefore means decrementing or removing its -# entry here as part of the same change. -# -# The goal is to empty this file and delete it, along with the `includes` entry -# for it in phpstan.neon.dist. -# -# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with -# -# composer phpstan:baselines -- --identifier=booleanOr.alwaysTrue -# -# which reruns the analysis with this file suppressed so the errors surface again. - -parameters: - ignoreErrors: - - - message: '#^Result of \|\| is always true\.$#' - identifier: booleanOr.alwaysTrue - count: 1 - path: ../../../src/wp-includes/class-wp-block.php From f6ed4bad5427acbdbb2badc1be6530944c14d61a Mon Sep 17 00:00:00 2001 From: rejaulalomkhan Date: Sun, 11 Oct 2026 09:45:07 +0600 Subject: [PATCH 2/2] Trigger CI