From ed10d24c674b4649124b81255f729a9492c4da99 Mon Sep 17 00:00:00 2001 From: Tony Hegyes Date: Wed, 28 Oct 2026 20:16:10 +0100 Subject: [PATCH] Relax consumer-a's export lock through the filter's own value consumer-a's acme_ca_is_relaxed() took the safeguard's filter name and called apply_filters() with it, so the export lock's hook had no literal call for its docblock, and PHPStan checked none of its arguments. The template's safeguard recipe, which consumer-a mirrors, now takes the filter's value instead (T4 pre-build ruling 5). acme_ca_is_relaxed() takes the filtered value, and the export lock calls it around its literal apply_filters( 'acme_ca_restrict_exports', true ), documented in place. SG1's rows pass unchanged. Assisted-by: Claude Code:claude-opus-5-5 --- .../consumer-a/includes/safeguards.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/Fixtures/consumer-a/includes/safeguards.php b/tests/Fixtures/consumer-a/includes/safeguards.php index ef08cb2..3d3af18 100644 --- a/tests/Fixtures/consumer-a/includes/safeguards.php +++ b/tests/Fixtures/consumer-a/includes/safeguards.php @@ -13,20 +13,17 @@ add_filter( 'map_meta_cap', 'acme_ca_map_export_capability', 10, 2 ); /** - * Returns whether a safeguard's own filter relaxes it, which takes an explicit false once the plugin has finished booting. + * Returns whether a safeguard's filtered value relaxes it, which takes an explicit false once the plugin has finished booting. * * @since 1.0.0 * @version 1.0.0 * - * @phpstan-param non-empty-string $filter - * - * @param string $filter The safeguard's filter, which receives true and the arguments. - * @param mixed ...$args The arguments the filter receives after true. + * @param mixed $filtered The value the safeguard's filter returned for true. * * @return bool */ -function acme_ca_is_relaxed( string $filter, ...$args ): bool { - return 0 < did_action( 'acme_ca_initialized' ) && false === apply_filters( $filter, true, ...$args ); +function acme_ca_is_relaxed( $filtered ): bool { + return 0 < did_action( 'acme_ca_initialized' ) && false === $filtered; } /** @@ -45,5 +42,13 @@ function acme_ca_map_export_capability( array $caps, string $cap ): array { return $caps; } - return acme_ca_is_relaxed( 'acme_ca_restrict_exports' ) ? array( 'manage_woocommerce' ) : array( 'do_not_allow' ); + /** + * Filters whether order exports stay locked; an explicit false unlocks them once the plugin has booted. + * + * @since 1.0.0 + * @version 1.0.0 + * + * @param bool $restricted Whether order exports stay locked. + */ + return acme_ca_is_relaxed( apply_filters( 'acme_ca_restrict_exports', true ) ) ? array( 'manage_woocommerce' ) : array( 'do_not_allow' ); }