refactor(functions): replace manual validation with webmozart/assert#122
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
webmozart/assertdependency for standardized validationwp_tag_order_cast_mixed_to_int()to useAssert::numeric()wp_tag_order_cast_mixed_to_string()to useAssert::scalar()phpstan-webmozart-assertextension for enhanced type narrowingNote
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()andwp_tag_order_cast_mixed_to_string()withwebmozart/assert(Assert::numeric/Assert::scalar), standardizing exception behavior and enabling better static type narrowing.Introduces Composer runtime dependencies by adding
webmozart/assert(plusphpstan/phpstan-webmozart-assertfor dev) and loadingvendor/autoload.phpduring plugin bootstrap; CIplugin-checknow sets up PHP 8.2 and runs a productioncomposer installbefore executing the WordPress plugin check.Written by Cursor Bugbot for commit c7fc777. This will update automatically on new commits. Configure here.