From e3be926ccc458d8d093ed6ba5c84d304c5f907a3 Mon Sep 17 00:00:00 2001 From: Huzaifa Al Mesbah Date: Tue, 6 Oct 2026 09:46:13 +0600 Subject: [PATCH] HTML API: Annotate WP_HTML_Processor::next_token() as impure for PHPStan --- phpstan.neon.dist | 1 - .../html-api/class-wp-html-processor.php | 2 ++ .../baselines/booleanNot.alwaysTrue.neon | 5 ---- .../baselines/booleanOr.alwaysTrue.neon | 25 ------------------- .../baselines/deadCode.unreachable.neon | 5 ---- 5 files changed, 2 insertions(+), 36 deletions(-) delete mode 100644 tests/phpstan/baselines/booleanOr.alwaysTrue.neon diff --git a/phpstan.neon.dist b/phpstan.neon.dist index f324ca1827e52..6fb2c0e003c52 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -33,7 +33,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/catch.neverThrown.neon - tests/phpstan/baselines/class.notFound.neon - tests/phpstan/baselines/deadCode.unreachable.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 c278cca8b0e23..d5dc8663b9ac0 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -779,6 +779,8 @@ public function next_tag( $query = null ): bool { * @since 6.7.2 Refactored so subclasses may extend. * * @return bool Whether a token was parsed. + * + * @phpstan-impure */ public function next_token(): bool { return $this->next_visitable_token(); diff --git a/tests/phpstan/baselines/booleanNot.alwaysTrue.neon b/tests/phpstan/baselines/booleanNot.alwaysTrue.neon index ae0b0afe52c56..f60969836878e 100644 --- a/tests/phpstan/baselines/booleanNot.alwaysTrue.neon +++ b/tests/phpstan/baselines/booleanNot.alwaysTrue.neon @@ -43,11 +43,6 @@ parameters: identifier: booleanNot.alwaysTrue count: 1 path: ../../../src/wp-includes/class-wp-block-templates-registry.php - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 1 - path: ../../../src/wp-includes/class-wp-block.php - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue 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 diff --git a/tests/phpstan/baselines/deadCode.unreachable.neon b/tests/phpstan/baselines/deadCode.unreachable.neon index 2282799c3903d..259fafb963feb 100644 --- a/tests/phpstan/baselines/deadCode.unreachable.neon +++ b/tests/phpstan/baselines/deadCode.unreachable.neon @@ -48,11 +48,6 @@ parameters: identifier: deadCode.unreachable count: 1 path: ../../../src/wp-includes/capabilities.php - - - message: '#^Unreachable statement \- code above always terminates\.$#' - identifier: deadCode.unreachable - count: 1 - path: ../../../src/wp-includes/class-wp-block.php - message: '#^Unreachable statement \- code above always terminates\.$#' identifier: deadCode.unreachable