Fix Psalm errors

This commit is contained in:
Daniel Dudzic 2024-10-18 10:44:02 +02:00
parent 407f526064
commit 763d4a6482
No known key found for this signature in database
GPG key ID: 31B40D33E3465483

View file

@ -256,7 +256,7 @@ return array(
'axo.shipping-wc-enabled-locations' => static function ( ContainerInterface $container ): array {
$default_zone = new \WC_Shipping_Zone( 0 );
$is_method_enabled = fn( $method) => $method->enabled === 'yes';
$is_method_enabled = fn( \WC_Shipping_Method $method): bool => $method->enabled === 'yes';
$is_default_zone_enabled = ! empty(
array_filter(
@ -271,20 +271,21 @@ return array(
$shipping_zones = \WC_Shipping_Zones::get_zones();
$get_zone_locations = fn($zone) =>
!empty(array_filter($zone->get_shipping_methods(), $is_method_enabled))
$get_zone_locations = fn( \WC_Shipping_Zone $zone): array =>
! empty( array_filter( $zone->get_shipping_methods(), $is_method_enabled ) )
? array_map(
fn($location) => $location->code,
fn( object $location): string => $location->code,
$zone->get_zone_locations()
)
: [];
: array();
$enabled_locations = array_unique(
array_merge(
...array_map(
$get_zone_locations,
array_map(
fn( $zone) => $zone instanceof \WC_Shipping_Zone ? $zone : new \WC_Shipping_Zone( $zone['id'] ),
fn( $zone): \WC_Shipping_Zone =>
$zone instanceof \WC_Shipping_Zone ? $zone : new \WC_Shipping_Zone( $zone['id'] ),
$shipping_zones
)
)