Read version from Composer runtime, not hardcoded constants#81
Merged
Conversation
The previous implementation pinned MAJOR/MINOR/PATCH to 4.1.1 and
required someone to manually bump the constants on every release.
Nobody did — every install reported v4.1.1 regardless of what composer
actually pulled. The MCP serverInfo handshake surfaced this on a v4.3.1
install during Phase 2 verification.
Read \Composer\InstalledVersions::getPrettyVersion('keyqcloud/kyte-php')
instead. Returns:
- "v4.3.2" on a tagged install
- "dev-master" / "dev-feature/..." on a branch install
- "unknown" if composer's runtime data isn't present (raw git clone)
This is the standard Composer 2.x API for "what version of this
package is installed." Zero maintenance, correct result.
3 new tests in tests/VersionTest.php pin the new contract:
non-empty string return, parity with Composer\InstalledVersions,
guard against regression to the old hardcoded "v4.1.1" string.
34/34 unit tests green.
Pre-existing flake noted: tests/ModelTest.php seeds rows in TestTable
that don't get torn down between runs; rerunning phpunit against the
same mariadb container fails at line 285. Fresh container passes.
Worth adding tearDown logic when ModelTest is next touched. Not
addressed here (scope discipline).
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.
Summary
MAJOR/MINOR/PATCHconstants insrc/Core/Version.phpwith\Composer\InstalledVersions::getPrettyVersion('keyqcloud/kyte-php').Why
The old implementation required manual bumps on every release. Nobody did — every install reported
v4.1.1regardless of what composer actually pulled. The MCPserverInfo.versionhandshake surfaced this on a v4.3.1 install during Phase 2 dev verification last session.Composer 2.x's
InstalledVersionsAPI is the idiomatic answer: returns"v4.3.2"on tagged installs,"dev-master"on branch installs,"unknown"if composer runtime data isn't present. Zero maintenance.Test plan
docker compose -f tests/docker-compose.test.yml run --rm php vendor/bin/phpunit --testsuite unit→ 34/34 green locallyNote
Pre-existing flake spotted while running this:
tests/ModelTest.phpseeds rows inTestTablethat don't get torn down between runs. Rerunning phpunit against the same mariadb container fails at line 285. Fresh container passes. Worth addingtearDownwhen ModelTest is next touched — not addressed here (scope discipline).