Skip to content

Conversation

@Soare-Robert-Daniel
Copy link
Contributor

@Soare-Robert-Daniel Soare-Robert-Daniel commented Nov 19, 2025

Re-add the extra type verification for values that are computed with filters.

All Submissions:

Changes proposed in this Pull Request:

Re-add some type verifications from 407e4fe

Closes #1002

How to test the changes in this Pull Request:

  1. Add a custom filter for the WP hook 'wp_calculate_image_srcset' that returns a non-array value.
  2. Check the logs for warnings

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Re-add the extra type verification for values that are computed with filters.
@pirate-bot
Copy link
Collaborator

Plugin build for 49dffaf is ready 🛎️!

Copilot finished reviewing on behalf of Soare-Robert-Daniel November 19, 2025 15:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR re-adds defensive type verification for filter values to prevent warnings when custom WordPress filters return unexpected types. The changes ensure that functions hooked to WordPress filters properly handle non-array return values from other filters.

  • Added type guards to check if parameters are arrays before processing them
  • Updated PHPDoc annotations to reflect that parameters can be mixed types
  • Removed resolved PHPStan baseline entries for improved type specificity

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
inc/tag_replacer.php Added array type check for $sources parameter in filter_srcset_attr method to handle non-array values from wp_calculate_image_srcset filter
inc/app_replacer.php Added array type check for $resize parameter in get_optimized_image_url method to prevent errors when accessing array keys
inc/admin.php Added array type check for $links parameter in add_action_links method to handle non-array values from plugin action links filter
phpstan-baseline.neon Removed baseline entries for methods that now have proper type annotations with mixed types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid array for $sources in filter_srcset_attr hook

4 participants