From 005716a57e0bb9bfbb6f7a3df8b26b3f24af0f85 Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Sun, 16 Aug 2026 13:38:30 -0700 Subject: [PATCH] fix: remove foreach.nonIterable baseline and fix its issue --- phpstan.neon.dist | 1 - src/wp-includes/class-wp-post-type.php | 2 +- .../baselines/foreach.nonIterable.neon | 25 ------------------- 3 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 tests/phpstan/baselines/foreach.nonIterable.neon diff --git a/phpstan.neon.dist b/phpstan.neon.dist index e2e72fb367482..f35cd537b5559 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -43,7 +43,6 @@ includes: - tests/phpstan/baselines/empty.property.neon - tests/phpstan/baselines/empty.variable.neon - tests/phpstan/baselines/encapsedStringPart.nonString.neon - - tests/phpstan/baselines/foreach.nonIterable.neon - tests/phpstan/baselines/function.alreadyNarrowedType.neon - tests/phpstan/baselines/function.impossibleType.neon - tests/phpstan/baselines/function.resultUnused.neon diff --git a/src/wp-includes/class-wp-post-type.php b/src/wp-includes/class-wp-post-type.php index b53a244d7de84..b69f892f8e6ef 100644 --- a/src/wp-includes/class-wp-post-type.php +++ b/src/wp-includes/class-wp-post-type.php @@ -820,7 +820,7 @@ public function remove_rewrite_rules() { } // Remove registered custom meta capabilities. - foreach ( $this->cap as $cap ) { + foreach ( (array) $this->cap as $cap ) { unset( $post_type_meta_caps[ $cap ] ); } } diff --git a/tests/phpstan/baselines/foreach.nonIterable.neon b/tests/phpstan/baselines/foreach.nonIterable.neon deleted file mode 100644 index be8bba17a113c..0000000000000 --- a/tests/phpstan/baselines/foreach.nonIterable.neon +++ /dev/null @@ -1,25 +0,0 @@ -# PHPStan baseline for the `foreach.nonIterable` errors in WordPress core. -# -# https://phpstan.org/error-identifiers/foreach.nonIterable -# -# 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=foreach.nonIterable -# -# which reruns the analysis with this file suppressed so the errors surface again. - -parameters: - ignoreErrors: - - - message: '#^Argument of an invalid type stdClass supplied for foreach, only iterables are supported\.$#' - identifier: foreach.nonIterable - count: 1 - path: ../../../src/wp-includes/class-wp-post-type.php