Commit 00295f4b6b for woocommerce

commit 00295f4b6b02c13f034bb0678ae52454d0e0bcc6
Author: Michael Pretty <prettyboymp@users.noreply.github.com>
Date:   Sat Jan 24 01:54:42 2026 -0500

    Fix PHPStan errors in wc_get_product_attachment_props() (#62919)

diff --git a/plugins/woocommerce/changelog/62919-fix-phpstan-wc-get-product-attachment-props b/plugins/woocommerce/changelog/62919-fix-phpstan-wc-get-product-attachment-props
new file mode 100644
index 0000000000..bab7020b5f
--- /dev/null
+++ b/plugins/woocommerce/changelog/62919-fix-phpstan-wc-get-product-attachment-props
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix PHPStan errors in wc_get_product_attachment_props() by adding is_array() checks before accessing array offsets.
\ No newline at end of file
diff --git a/plugins/woocommerce/includes/wc-product-functions.php b/plugins/woocommerce/includes/wc-product-functions.php
index c13c023339..a70f2d3b47 100644
--- a/plugins/woocommerce/includes/wc-product-functions.php
+++ b/plugins/woocommerce/includes/wc-product-functions.php
@@ -1201,34 +1201,58 @@ function wc_get_product_attachment_props( $attachment_id = null, $product = fals
 		$alt_text     = array_filter( $alt_text );
 		$props['alt'] = $alt_text ? reset( $alt_text ) : '';

-		// Large version.
+		/**
+		 * Filters the size for the full gallery image.
+		 *
+		 * @param string $size Image size name.
+		 *
+		 * @since 2.6.0
+		 */
 		$full_size           = apply_filters( 'woocommerce_gallery_full_size', apply_filters( 'woocommerce_product_thumbnails_large_size', 'full' ) );
 		$src                 = wp_get_attachment_image_src( $attachment_id, $full_size );
-		$props['full_src']   = $src[0];
-		$props['full_src_w'] = $src[1];
-		$props['full_src_h'] = $src[2];
+		$props['full_src']   = $src[0] ?? null;
+		$props['full_src_w'] = $src[1] ?? null;
+		$props['full_src_h'] = $src[2] ?? null;

-		// Gallery thumbnail.
-		$gallery_thumbnail                = wc_get_image_size( 'gallery_thumbnail' );
+		$gallery_thumbnail = wc_get_image_size( 'gallery_thumbnail' );
+		/**
+		 * Filters the size for the gallery thumbnail.
+		 *
+		 * @param array $size Array containing width and height dimensions.
+		 *
+		 * @since 2.6.0
+		 */
 		$gallery_thumbnail_size           = apply_filters( 'woocommerce_gallery_thumbnail_size', array( $gallery_thumbnail['width'], $gallery_thumbnail['height'] ) );
 		$src                              = wp_get_attachment_image_src( $attachment_id, $gallery_thumbnail_size );
-		$props['gallery_thumbnail_src']   = $src[0];
-		$props['gallery_thumbnail_src_w'] = $src[1];
-		$props['gallery_thumbnail_src_h'] = $src[2];
+		$props['gallery_thumbnail_src']   = $src[0] ?? null;
+		$props['gallery_thumbnail_src_w'] = $src[1] ?? null;
+		$props['gallery_thumbnail_src_h'] = $src[2] ?? null;

-		// Thumbnail version.
+		/**
+		 * Filters the thumbnail size.
+		 *
+		 * @param string $size Image size name.
+		 *
+		 * @since 2.6.0
+		 */
 		$thumbnail_size       = apply_filters( 'woocommerce_thumbnail_size', 'woocommerce_thumbnail' );
 		$src                  = wp_get_attachment_image_src( $attachment_id, $thumbnail_size );
-		$props['thumb_src']   = $src[0];
-		$props['thumb_src_w'] = $src[1];
-		$props['thumb_src_h'] = $src[2];
+		$props['thumb_src']   = $src[0] ?? null;
+		$props['thumb_src_w'] = $src[1] ?? null;
+		$props['thumb_src_h'] = $src[2] ?? null;

-		// Image source.
+		/**
+		 * Filters the size for the gallery image.
+		 *
+		 * @param string $size Image size name.
+		 *
+		 * @since 2.6.0
+		 */
 		$image_size      = apply_filters( 'woocommerce_gallery_image_size', 'woocommerce_single' );
 		$src             = wp_get_attachment_image_src( $attachment_id, $image_size );
-		$props['src']    = $src[0];
-		$props['src_w']  = $src[1];
-		$props['src_h']  = $src[2];
+		$props['src']    = $src[0] ?? null;
+		$props['src_w']  = $src[1] ?? null;
+		$props['src_h']  = $src[2] ?? null;
 		$props['srcset'] = function_exists( 'wp_get_attachment_image_srcset' ) ? wp_get_attachment_image_srcset( $attachment_id, $image_size ) : false;
 		$props['sizes']  = function_exists( 'wp_get_attachment_image_sizes' ) ? wp_get_attachment_image_sizes( $attachment_id, $image_size ) : false;
 	}
diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index 24d95d16bc..1d12ddb055 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -40551,24 +40551,6 @@ parameters:
 			count: 1
 			path: includes/wc-product-functions.php

-		-
-			message: '#^Cannot access offset 0 on array\{string, int, int, bool\}\|false\.$#'
-			identifier: offsetAccess.nonOffsetAccessible
-			count: 4
-			path: includes/wc-product-functions.php
-
-		-
-			message: '#^Cannot access offset 1 on array\{string, int, int, bool\}\|false\.$#'
-			identifier: offsetAccess.nonOffsetAccessible
-			count: 4
-			path: includes/wc-product-functions.php
-
-		-
-			message: '#^Cannot access offset 2 on array\{string, int, int, bool\}\|false\.$#'
-			identifier: offsetAccess.nonOffsetAccessible
-			count: 4
-			path: includes/wc-product-functions.php
-
 		-
 			message: '#^Cannot access property \$slug on WP_Error\|WP_Term\|null\.$#'
 			identifier: property.nonObject