Skip to content

[command] show installed DevTools version in list output#340

Merged
coisa merged 11 commits into
mainfrom
chore/339-show-dev-tools-version-in-list
May 11, 2026
Merged

[command] show installed DevTools version in list output#340
coisa merged 11 commits into
mainfrom
chore/339-show-dev-tools-version-in-list

Conversation

@coisa
Copy link
Copy Markdown
Contributor

@coisa coisa commented May 11, 2026

Summary

Show the installed DevTools version in the console application metadata so list and --version reflect the running release, improving runtime visibility for troubleshooting and reproducibility.

Changes

  • Add fast-forward/dev-tools version resolution to src/Console/DevTools.php by passing a second Application constructor argument.
  • Add src/Console/DevTools::resolveVersion() with a safe fallback for environments without installed version metadata.
  • Add a constructor-level test assertion in tests/Console/DevToolsTest.php to confirm application version metadata is populated.
  • Add CHANGELOG.md entry under Unreleased describing the command-list version visibility improvement.

Testing

  • vendor/bin/phpunit tests/Console/DevToolsTest.php (not yet run)
  • Commit-time hook attempt via git commit triggered composer dev-tools, which currently fails later in coverage reporting with an existing RuntimeEnvironmentTest risky test unrelated to this change.
  • Manual command-level smoke not run in this iteration.

Changelog

  • Added notable CHANGELOG.md entry.

Closes #339

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 13117a6a-df98-43a3-ba2c-b4d002123df4

📥 Commits

Reviewing files that changed from the base of the PR and between 0d8e138 and 445e0d6.

📒 Files selected for processing (5)
  • .github/wiki
  • src/Console/DevTools.php
  • src/SelfUpdate/ComposerVersionChecker.php
  • src/SelfUpdate/VersionCheckerInterface.php
  • tests/Console/DevToolsTest.php

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • CLI now shows DevTools version metadata consistently in both listing and version outputs.
  • Tests
    • Tests updated to assert the CLI exposes the expected version string.
  • Chores
    • Wiki submodule reference updated and changelog entry added noting the version-display fix.

Walkthrough

DevTools now accepts a VersionChecker, resolves the installed DevTools version at bootstrap via getCurrentVersion(), and passes it into the Symfony Application so list and --version expose the package version. Composer-based resolution, tests, changelog, and wiki pointer were updated.

Changes

Version Metadata Integration

Layer / File(s) Summary
VersionChecker contract
src/SelfUpdate/VersionCheckerInterface.php
Adds getCurrentVersion(): string to the interface (returns a safe fallback when metadata is unavailable).
Composer resolver helper
src/SelfUpdate/ComposerVersionChecker.php
Adds VERSION_UNKNOWN sentinel, getCurrentVersion(): string (uses InstalledVersions::isInstalled, getPrettyVersion()/getVersion(), catches Throwable), and updates check() to use it and return null when sentinel is returned.
DevTools bootstrap wiring
src/Console/DevTools.php
Imports VersionCheckerInterface, accepts it as a private readonly constructor dependency, and passes $this->versionChecker->getCurrentVersion() to parent::__construct() so the Application carries the installed version.
Unit tests
tests/Console/DevToolsTest.php
Adds a VersionCheckerInterface prophecy in setUp() returning '1.2.3', injects it into DevTools creation, and asserts getVersion() equals '1.2.3'.
Docs / Release notes
CHANGELOG.md, .github/wiki
Adds changelog entry noting CLI shows DevTools version metadata; updates .github/wiki submodule pointer.

Sequence Diagram

sequenceDiagram
  participant DevTools
  participant VersionCheckerInterface
  participant ComposerVersionChecker
  participant InstalledVersions
  participant SymfonyApplication
  DevTools->>VersionCheckerInterface: getCurrentVersion()
  VersionCheckerInterface->>ComposerVersionChecker: getCurrentVersion()
  ComposerVersionChecker->>InstalledVersions: isInstalled('fast-forward/dev-tools')
  ComposerVersionChecker->>InstalledVersions: getPrettyVersion() / getVersion()
  InstalledVersions-->>ComposerVersionChecker: prettyVersion | version | error
  ComposerVersionChecker-->>VersionCheckerInterface: resolvedVersion (or VERSION_UNKNOWN)
  VersionCheckerInterface-->>DevTools: resolvedVersion
  DevTools->>SymfonyApplication: parent::__construct(name, resolvedVersion)
Loading

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • php-fast-forward/dev-tools#340: Both PRs make the same code-level change: wiring a VersionChecker into src/Console/DevTools, adding getCurrentVersion() in ComposerVersionChecker, and extending VersionCheckerInterface.

🐰 I nibble at the morning code,
I plant a tag where versions grow,
Composer whispers what I know,
The CLI now wears its number proud,
A tiny hop — a grateful bow.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: showing the installed DevTools version in list output, which matches the core objective of the pull request.
Description check ✅ Passed The description covers the summary, changes, testing, and changelog sections; however, it is missing the standard template's 'Related Issue', 'Motivation/Context', 'Verification', and 'Documentation/Generated Output' structured sections.
Linked Issues check ✅ Passed The pull request successfully implements all coding requirements from issue #339: version resolution via VersionCheckerInterface is wired into DevTools.php, a safe fallback is provided, tests assert correct version metadata, and the changelog is updated.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #339: DevTools.php version wiring, VersionCheckerInterface extension, ComposerVersionChecker refactoring, test updates, CHANGELOG entry, and a wiki submodule pointer update are all within scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/339-show-dev-tools-version-in-list

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@src/Console/DevTools.php`:
- Around line 99-103: Update the PHPDoc for the method in class DevTools that
"resolves the running DevTools version for command metadata" to use RFC 2119
wording: state that the method MUST return the current package version when
available and MUST fall back to a safe string otherwise, include the `@return`
string tag, and optionally add that callers SHOULD handle the fallback value;
ensure the docblock uses uppercase RFC2119 keywords (MUST, SHOULD) and
references the method behavior.
- Around line 106-108: Guard Composer metadata access by first calling
InstalledVersions::isInstalled(self::PACKAGE) and only then call
InstalledVersions::getPrettyVersion(self::PACKAGE) /
InstalledVersions::getVersion(self::PACKAGE); additionally wrap those calls in a
try-catch for \OutOfBoundsException (or generic \Throwable) so any thrown
exception falls back to self::VERSION_UNKNOWN; update the return logic in the
method that currently calls InstalledVersions::getPrettyVersion / getVersion to
use the isInstalled check and the try-catch so the null-coalescing fallback is
reachable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 40a37296-700f-4e2c-9845-0a428f7f504b

📥 Commits

Reviewing files that changed from the base of the PR and between 933f56a and d45af4b.

📒 Files selected for processing (4)
  • .github/wiki
  • CHANGELOG.md
  • src/Console/DevTools.php
  • tests/Console/DevToolsTest.php

Comment thread src/Console/DevTools.php Outdated
Comment thread src/Console/DevTools.php Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38abd3edee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/SelfUpdate/ComposerVersionChecker.php Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
src/Console/DevTools.php (1)

99-107: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

RFC 2119 keywords still missing from the method docblock.

The past review comment correctly identified that this docblock lacks RFC 2119 keywords required by coding standards. The method MUST return the current package version when available and MUST fall back to VERSION_UNKNOWN otherwise.

📝 Suggested enhancement
     /**
-     * Resolves the running DevTools version for command metadata.
+     * Resolves the running DevTools version for application metadata display.
+     *
+     * The method MUST return the current package version from the version checker when available.
+     * The method MUST fall back to VERSION_UNKNOWN when version resolution returns null.
      *
-     * `@return` string the current package version or a safe fallback
+     * `@return` string the version string for Symfony Console Application metadata
      */

As per coding guidelines, **/*.php: "Use RFC 2119 keywords (MUST, SHOULD, MAY, etc.) in PHPDoc comments".

🤖 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 `@src/Console/DevTools.php` around lines 99 - 107, Update the docblock for
resolveVersion() to include RFC 2119 wording: state that resolveVersion() MUST
return the current package version (obtained via
$this->versionChecker->resolveCurrentVersion()) when available and MUST fall
back to self::VERSION_UNKNOWN when resolveCurrentVersion() returns null; mention
the return type remains string and that resolveCurrentVersion() may return null
which triggers the fallback to VERSION_UNKNOWN.
🤖 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.

Inline comments:
In `@src/SelfUpdate/ComposerVersionChecker.php`:
- Around line 70-72: The PHPDoc for the method that "Returns the installed
DevTools version without running external Composer commands" (method:
ComposerVersionChecker::getInstalledVersion) is missing RFC 2119 terms; update
the docblock to state the contract using MUST/MUST NOT: explicitly document that
ComposerVersionChecker::getInstalledVersion MUST return the installed version
string when metadata is available and MUST return null when resolution fails,
and include any relevant MAY/SHOULD notes if needed (e.g., about caching or
exceptions) so the method's behavior is unambiguous.
- Around line 70-77: The resolveCurrentVersion() implementation must catch cases
where InstalledVersions::getPrettyVersion() or ::getVersion() throw
OutOfBoundsException and return null per the ?string contract; wrap the calls to
InstalledVersions in a try/catch that catches OutOfBoundsException (or
Throwable), return the pretty version if available, fallback to getVersion(),
and return null if an exception occurs or neither value is present (referencing
resolveCurrentVersion and InstalledVersions).

In `@src/SelfUpdate/VersionCheckerInterface.php`:
- Around line 32-37: Update the PHPDoc for the resolveCurrentVersion() method to
include RFC 2119 keywords: state that implementations MUST return the currently
installed DevTools version string when it is available and MAY return null if
the version cannot be resolved; keep the existing short description and `@return`
type but add these MUST/MAY sentences to the docblock for
resolveCurrentVersion().

---

Duplicate comments:
In `@src/Console/DevTools.php`:
- Around line 99-107: Update the docblock for resolveVersion() to include RFC
2119 wording: state that resolveVersion() MUST return the current package
version (obtained via $this->versionChecker->resolveCurrentVersion()) when
available and MUST fall back to self::VERSION_UNKNOWN when
resolveCurrentVersion() returns null; mention the return type remains string and
that resolveCurrentVersion() may return null which triggers the fallback to
VERSION_UNKNOWN.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1d03fcda-1c09-4122-ac26-6f243b4197db

📥 Commits

Reviewing files that changed from the base of the PR and between d45af4b and 0d8e138.

📒 Files selected for processing (5)
  • .github/wiki
  • src/Console/DevTools.php
  • src/SelfUpdate/ComposerVersionChecker.php
  • src/SelfUpdate/VersionCheckerInterface.php
  • tests/Console/DevToolsTest.php

Comment thread src/SelfUpdate/ComposerVersionChecker.php
Comment thread src/SelfUpdate/ComposerVersionChecker.php
Comment thread src/SelfUpdate/VersionCheckerInterface.php Outdated
@coisa coisa merged commit b1e73ab into main May 11, 2026
33 checks passed
@coisa coisa deleted the chore/339-show-dev-tools-version-in-list branch May 11, 2026 21:24
@github-project-automation github-project-automation Bot moved this from Backlog to Released in PHP Fast Forward Project May 11, 2026
github-actions Bot added a commit that referenced this pull request May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

[command] Show installed DevTools version in list output

1 participant