Skip to content

Add declarative deprecation handling for commands and assoc args - #6343

Merged
swissspidy merged 20 commits into
mainfrom
copilot/add-deprecation-checks
Jul 21, 2026
Merged

swissspidy merged 20 commits into
mainfrom
copilot/add-deprecation-checks

Conversation

Copilot AI commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

This introduces framework-level deprecation handling based on command docblocks and argument YAML metadata, so command authors no longer need to manually emit warnings. Deprecated commands/args are now surfaced consistently in both help output and runtime execution paths.

  • Command-level deprecation from PHPDoc

    • Added DocParser::get_deprecation_message() to parse @deprecated ....
    • Subcommand::invoke() now emits a warning before execution when the command is marked deprecated.
  • Argument-level deprecation from synopsis YAML

    • Added assoc-arg deprecation extraction in Subcommand from option metadata:
      • deprecated: <message>
    • Emits warning only when a deprecated argument is actually provided by the user.
  • Help output integration

    • Help_Command now appends a deprecation sentence in SYNOPSIS for deprecated commands.
    • Argument deprecation messages are injected into option descriptions in help output.
  • Coverage updates

    • Added unit coverage for @deprecated parsing in DocParserTest.
    • Added feature coverage for command + argument deprecation behavior in features/command.feature.
/**
 * Deprecated command.
 *
 * ## OPTIONS
 *
 * [--old=<old>]
 * : Old parameter.
 * ---
 * deprecated: Use `--new` instead.
 * ---
 *
 * @deprecated Use `wp replacement` instead.
 */

With this, help includes deprecation guidance and runtime prints warnings before invoking deprecated command paths.

Summary by CodeRabbit

  • New Features
    • Added support for declaring deprecated commands and arguments via command annotations.
    • Help output now surfaces command- and argument-level deprecation details, including optional guidance.
  • Behavior Updates
    • Deprecation warnings are emitted only when the corresponding deprecated commands or options/arguments are actually used (including during prompt flows), while still allowing successful execution.
  • Tests
    • Expanded help and deprecation parsing coverage to verify messaging and warning behavior.

@codecov

codecov Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 19.75309% with 65 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
php/commands/src/Help_Command.php 0.00% 39 Missing ⚠️
php/WP_CLI/Dispatcher/Subcommand.php 0.00% 24 Missing ⚠️
php/WP_CLI/DocParser.php 88.88% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI changed the title [WIP] Add a declarative way to mark commands and arguments deprecated Add declarative deprecation handling for commands and assoc args Jul 16, 2026
Copilot AI requested a review from swissspidy July 16, 2026 09:26
Comment thread features/command.feature Outdated
@coderabbitai

This comment was marked as resolved.

This comment was marked as resolved.

swissspidy and others added 3 commits July 16, 2026 12:28
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Comment thread php/commands/src/Help_Command.php Outdated
Comment thread features/command.feature Outdated
@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

@swissspidy
swissspidy marked this pull request as ready for review July 16, 2026 13:40
@swissspidy
swissspidy requested a review from a team as a code owner July 16, 2026 13:40
coderabbitai[bot]

This comment was marked as resolved.

@swissspidy swissspidy added this to the 3.0.0 milestone Jul 20, 2026
Comment thread php/WP_CLI/DocParser.php Outdated
Comment thread php/commands/src/Help_Command.php Outdated
Comment thread php/WP_CLI/Dispatcher/Subcommand.php

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
php/WP_CLI/DocParser.php (1)

141-145: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the explicit deprecated: false branch with a regression test.

Current tests cover non-empty and empty-string messages, but not the newly introduced behavior that explicitly disabled metadata is ignored. Add a fixture asserting deprecated: false is omitted from the returned map.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@php/WP_CLI/DocParser.php` around lines 141 - 145, Add a regression fixture
for the deprecation parsing flow in DocParser, asserting that an argument with
explicit deprecated: false is omitted from the returned map. Keep existing
coverage for non-empty and empty-string deprecated messages unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@php/WP_CLI/DocParser.php`:
- Around line 141-145: Add a regression fixture for the deprecation parsing flow
in DocParser, asserting that an argument with explicit deprecated: false is
omitted from the returned map. Keep existing coverage for non-empty and
empty-string deprecated messages unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d06dcab1-fa4d-4d3a-a960-e6cebe0805bd

📥 Commits

Reviewing files that changed from the base of the PR and between baacc30 and 43a1716.

📒 Files selected for processing (5)
  • features/command.feature
  • php/WP_CLI/Dispatcher/Subcommand.php
  • php/WP_CLI/DocParser.php
  • php/commands/src/Help_Command.php
  • tests/DocParserTest.php
🚧 Files skipped from review as they are similar to previous changes (4)
  • php/commands/src/Help_Command.php
  • tests/DocParserTest.php
  • php/WP_CLI/Dispatcher/Subcommand.php
  • features/command.feature

Covers the branch in `DocParser::get_deprecated_assoc_args()` where an
explicit `deprecated: false` marks an argument as not deprecated, so it
is omitted from the returned map. Complements existing coverage for the
non-empty and empty-string deprecation messages.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Declarative way to mark commands and arguments deprecated

4 participants