Skip to content

Issue-71: Fix type mismatch for condition in am_enqueue_script - #72

Merged
mslinnea merged 3 commits into
productionfrom
fix/issue-71/phpstan-condition-type-mismatch
Jul 14, 2025
Merged

Issue-71: Fix type mismatch for condition in am_enqueue_script#72
mslinnea merged 3 commits into
productionfrom
fix/issue-71/phpstan-condition-type-mismatch

Conversation

@mslinnea

@mslinnea mslinnea commented Jul 11, 2025

Copy link
Copy Markdown
Member

Summary

Fixes #71

Description

This pull request resolves a PHPStan type mismatch error related to the condition parameter in the am_enqueue_script function. Previously, the PHPStan annotation for the $handle parameter incorrectly restricted the condition key to a string, even though the implementation and PHPDoc allowed both array and string types. This update modifies the @phpstan-param annotation in src/helpers.php to accept array<string, mixed>|string for $handle and updates the expected types for related parameters. Now, the condition key is correctly recognized by static analysis tools as supporting both arrays and strings, eliminating false-positive errors from PHPStan.

Testing Instructions

  1. Use am_enqueue_script, passing $handle as an array with a condition key set to an array.
  2. Run PHPStan to ensure there are no errors related to the type of condition.

Additional Context

See the original issue for more details: #71

Checklist

  • I have tested these changes locally.
  • I have updated documentation as needed.
  • I have added relevant tests if applicable.

@mslinnea mslinnea added php Requires understanding PHP bug Something isn't working labels Jul 11, 2025
@mslinnea
mslinnea marked this pull request as ready for review July 11, 2025 21:10

@kingkool68 kingkool68 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

@mslinnea
mslinnea merged commit 47ccb67 into production Jul 14, 2025
5 checks passed
@mslinnea
mslinnea deleted the fix/issue-71/phpstan-condition-type-mismatch branch July 14, 2025 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working php Requires understanding PHP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix type mismatch for condition in am_enqueue_script

2 participants