Open
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
… generic type Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add warning for overriding global arguments in commands
Warn when commands override global arguments
Dec 20, 2025
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Check for global argument conflicts in CommandFactory::create_subcommand() to catch conflicts in class-based commands that bypass WP_CLI::add_command() Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Allows commands to opt-out of global argument conflict warnings by adding @skipglobalargcheck to their PHPdoc. This is useful for built-in commands that intentionally override global arguments. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
- Remove 'This can lead to unexpected behavior' from warning to match test expectations - Use regex pattern matching for @skipglobalargcheck to prevent false positives - Ensures annotation is only detected as an actual PHPDoc tag, not in description text Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 task
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.
Custom commands can define arguments with the same names as WP-CLI's global arguments (
--debug,--user,--quiet, etc.), causing flags to silently fail or behave unexpectedly. This makes it difficult to introduce new global arguments without breaking existing commands.Changes
Added
check_global_arg_conflicts()validation in multiple locations:WP_CLI::add_command()for commands added via the public APICommandFactory::create_subcommand()to catch class-based command methodsAdded
@skipglobalargcheckannotation to allow opt-out:@skipglobalargcheckto their PHPdoc to silence warningsAdded Behat test scenarios covering:
Example
Commands registering conflicting arguments now emit warnings at registration time:
Function-based command (with warning):
Function-based command (warning suppressed):
Class-based command:
Warnings are informational only—commands continue to work. The
--quietflag suppresses warnings as expected.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.