Conversation
…/criteria Converts the loosely-typed array<string, mixed> overrides/criteria params on ProductMethods::haveProductInDatabase/haveManyProductsInDatabase, CouponMethods::haveCouponInDatabase and its discount-type wrappers, and OrderMethods::haveOrderInDatabase/haveManyOrdersInDatabase/haveOrderAddressInDatabase/ seeOrderAddressInDatabase/haveOrderItemInDatabase into unsealed @phpstan-type array shapes with enum literals for post/order status, stock status, tax status, and discount-type values. At PHPStan level max over src and tests, these shapes now double as the machine-readable allowed-keys map for agents and as assertions checked against every shipped Cest on CI. Closes #37
edpittol
deleted the
37-typed-argument-shapes-phpstan-type-aliases-unsealed-enum-literals-for-high-arity-builders
branch
July 11, 2026 20:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts the loosely-typed
array<string, mixed>overrides/criteriaparams on the WooCommerce Method Traits' high-arity, error-prone builders into unsealed@phpstan-typearray shapes with enum literals for status/stock/discount values:ProductMethods::haveProductInDatabase/haveManyProductsInDatabase—ProductOverrides(nestedProductMeta,ProductStatus,ProductStockStatus,ProductTaxStatus,ProductBackordersenums).CouponMethods::haveCouponInDatabaseand itshavePercentageCouponInDatabase/haveFixedCartCouponInDatabase/haveFixedProductCouponInDatabase/haveFreeShippingCouponInDatabasewrappers —CouponOverrides(nestedCouponMeta,CouponStatus,CouponDiscountTypeenums).OrderMethods::haveOrderInDatabase/haveManyOrdersInDatabase—OrderOverrides(OrderStatusenum, nestedaddress/items/meta).OrderMethods::haveOrderAddressInDatabase/seeOrderAddressInDatabase—OrderAddressshape +OrderAddressTypeenum.OrderMethods::haveOrderItemInDatabase(the order-item builder) —OrderItemOverrideswith anOrderItemTypeenum.All shapes are unsealed (
...) so the merge-defaults pass-through pattern keeps working and legitimate extra keys aren't rejected. Trivial 2-3 keycriteriaparams (meta lookups, simple ID/field queries) were left as prose@param, per scope. No@exampleblocks were added or rewritten.Two defensive runtime checks in
CouponMethodsandProductMethodsthat tested for array/string-ness of now-strictly-typed keys were simplified, since PHPStan flagged them as always-true/always-false once the shapes made the guarantee static.Note: issue #35 (the cold-agent eval this issue's "Blocked by" pointed at) is closed, but its failure-log Cest was never actually committed to the repo — there's no
tests/acceptance/*Cest.phprecording the specific hallucinated keys. The shapes here were instead derived directly from each builder's existing implementation and are validated against the Cests that do exist (ProductCest,CouponCest,OrderCest,OrderHPOSCest).Closes #37
Test plan
vendor/bin/phpstan analyse— no errors (level max oversrcandtests)vendor/bin/phpcs— cleanvendor/bin/codecept run unit— 32/32 passingvendor/bin/codecept run acceptance(via pre-push hook, full suite) — 198/198 passing