Skip to content

refactor(functions): replace manual validation with webmozart/assert#122

Merged
sectsect merged 3 commits into
masterfrom
refactor-assertion
Feb 16, 2026
Merged

refactor(functions): replace manual validation with webmozart/assert#122
sectsect merged 3 commits into
masterfrom
refactor-assertion

Conversation

@sectsect

@sectsect sectsect commented Feb 16, 2026

Copy link
Copy Markdown
Owner
  • Added webmozart/assert dependency for standardized validation
  • Refactored wp_tag_order_cast_mixed_to_int() to use Assert::numeric()
  • Refactored wp_tag_order_cast_mixed_to_string() to use Assert::scalar()
  • Simplified code from 14 lines to 4 lines total
  • Added phpstan-webmozart-assert extension for enhanced type narrowing

Note

Medium Risk
Adds a new runtime dependency and requires Composer autoloading at plugin startup; mispackaged releases or missing vendor/ could break plugin initialization, though code changes are localized.

Overview
Replaces ad-hoc input validation in wp_tag_order_cast_mixed_to_int() and wp_tag_order_cast_mixed_to_string() with webmozart/assert (Assert::numeric/Assert::scalar), standardizing exception behavior and enabling better static type narrowing.

Introduces Composer runtime dependencies by adding webmozart/assert (plus phpstan/phpstan-webmozart-assert for dev) and loading vendor/autoload.php during plugin bootstrap; CI plugin-check now sets up PHP 8.2 and runs a production composer install before executing the WordPress plugin check.

Written by Cursor Bugbot for commit c7fc777. This will update automatically on new commits. Configure here.

- Added webmozart/assert dependency for standardized validation
- Refactored wp_tag_order_cast_mixed_to_int() to use Assert::numeric()
- Refactored wp_tag_order_cast_mixed_to_string() to use Assert::scalar()
- Simplified code from 14 lines to 4 lines total
- Added phpstan-webmozart-assert extension for enhanced type narrowing
Add PHP setup and composer install steps to plugin-check workflow to fix
Fatal error caused by missing vendor/autoload.php. The refactor-assertion
branch added webmozart/assert as a production dependency, but plugin-check
workflow was not installing dependencies before activating the plugin.
@sectsect sectsect merged commit 753b197 into master Feb 16, 2026
10 checks passed
@sectsect sectsect deleted the refactor-assertion branch February 16, 2026 03:24
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.

1 participant