Commit 9a8cd72ac67 for woocommerce
commit 9a8cd72ac674ed049a01922d9561dec9450ee7a2
Author: Vlad Olaru <vlad.olaru@automattic.com>
Date: Thu Aug 6 07:53:24 2026 +0300
[docs] Fix the Hydration::get_rest_api_response_data() $path docblock type (#67313)
* docs: correct the hydration $path docblock type from array to string
The get_rest_api_response_data() docblock has declared $path as array
since the method was introduced (woocommerce-blocks#10373), but the
body has always required a string: $path is used as an array key,
passed to str_starts_with(), and forwarded as the string $path
parameter of rest_preload_api_request(). The array annotation likely
leaked from WP core's rest_preload_api_request(), whose $path can be
a [ path, method ] array — a form that has never worked through this
wrapper and fatals on the str_starts_with() guard.
All in-tree callers pass strings and the public wrappers in
AssetDataRegistry already document string, so the docblock was the
only surface claiming otherwise. Correcting it resolves five
previously baselined PHPStan errors anchored to the bogus array type;
the corresponding baseline entries are removed per the
shrink-only baseline policy.
* Add changelog entry for the hydration path docblock fix
* fix: remove the last stale Hydration PHPStan baseline entry
The docblock correction also resolved the baselined
'Parameter #2 $path of get_response_from_controller() expects string,
array given' error, but its entry sat outside the baseline region
reviewed in the previous commit and single-file PHPStan runs do not
check unmatched ignored errors. The full-config run CI uses caught it
as an out-of-date baseline. A local full-config run now reports no
unmatched entries.
diff --git a/plugins/woocommerce/changelog/fix-hydration-path-docblock b/plugins/woocommerce/changelog/fix-hydration-path-docblock
new file mode 100644
index 00000000000..e62e7815231
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-hydration-path-docblock
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Correct the Hydration::get_rest_api_response_data() $path docblock type from array to string and drop the now-resolved PHPStan baseline entries.
diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index 2b490c83f76..a659efc043f 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -53685,18 +53685,6 @@ parameters:
count: 2
path: src/Blocks/Domain/Services/Hydration.php
- -
- message: '#^Default value of the parameter \#1 \$path \(string\) of method Automattic\\WooCommerce\\Blocks\\Domain\\Services\\Hydration\:\:get_rest_api_response_data\(\) is incompatible with type array\.$#'
- identifier: parameter.defaultValue
- count: 1
- path: src/Blocks/Domain/Services/Hydration.php
-
- -
- message: '#^Invalid array key type array\.$#'
- identifier: offsetAccess.invalidOffset
- count: 1
- path: src/Blocks/Domain/Services/Hydration.php
-
-
message: '#^Method Automattic\\WooCommerce\\Blocks\\Domain\\Services\\Hydration\:\:cache_store_notices\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -53727,30 +53715,6 @@ parameters:
count: 1
path: src/Blocks/Domain/Services/Hydration.php
- -
- message: '#^Parameter \#1 \$haystack of function str_starts_with expects string\|null, array given\.$#'
- identifier: argument.type
- count: 1
- path: src/Blocks/Domain/Services/Hydration.php
-
- -
- message: '#^Parameter \#1 \$path of method Automattic\\WooCommerce\\Blocks\\Domain\\Services\\Hydration\:\:match_route_to_handler\(\) expects string, array given\.$#'
- identifier: argument.type
- count: 1
- path: src/Blocks/Domain/Services/Hydration.php
-
- -
- message: '#^Parameter \#2 \$path of function rest_preload_api_request expects string, array given\.$#'
- identifier: argument.type
- count: 1
- path: src/Blocks/Domain/Services/Hydration.php
-
- -
- message: '#^Parameter \#2 \$path of method Automattic\\WooCommerce\\Blocks\\Domain\\Services\\Hydration\:\:get_response_from_controller\(\) expects string, array given\.$#'
- identifier: argument.type
- count: 1
- path: src/Blocks/Domain/Services/Hydration.php
-
-
message: '#^Method Automattic\\WooCommerce\\Blocks\\Domain\\Services\\Notices\:\:init\(\) has no return type specified\.$#'
identifier: missingType.return
diff --git a/plugins/woocommerce/src/Blocks/Domain/Services/Hydration.php b/plugins/woocommerce/src/Blocks/Domain/Services/Hydration.php
index 962d60580ac..8d0aabbdf05 100644
--- a/plugins/woocommerce/src/Blocks/Domain/Services/Hydration.php
+++ b/plugins/woocommerce/src/Blocks/Domain/Services/Hydration.php
@@ -41,7 +41,7 @@ class Hydration {
* Hydrates the asset data registry with data from the API. Disables notices and nonces so requests contain valid
* data that is not polluted by the current session.
*
- * @param array $path API paths to hydrate e.g. '/wc/store/v1/cart'.
+ * @param string $path API path to hydrate e.g. '/wc/store/v1/cart'.
* @return array Response data.
*/
public function get_rest_api_response_data( $path = '' ) {