S61 — phlix-server CLI user:* commands with --json + last-admin guard - #742
Conversation
Adds seven user console commands (list, create, promote, delete,
approve, disable, reject) each honouring a shared --json contract, and
the in-repository last-admin guard consumed by the destructive/revoke
paths.
- src/Console/Commands/Concerns/JsonOutput.php: per-repo --json helper
(success {"ok":true,"data":[...]}, failure {"ok":false,"error":...}).
- src/Auth/UserRepository.php: countAdmins() + isLastAdmin() (SELECT-only).
- bin/phlix: register the seven commands via the UserRepository factory.
- tests/Unit/Console/Commands/*: per-command CommandTester coverage,
with/without --json, and guard proofs (rejection AND --force-still-rejected).
- Census re-pinned to the post-change PHP file count.
CLI-only: no HTTP route changes, no migrations.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 15 minor |
| ErrorProne | 7 medium |
| Comprehensibility | 7 minor |
| CodeStyle | 66 minor |
| Complexity | 5 medium |
🟢 Metrics 193 complexity · 6 duplication
Metric Results Complexity 193 Duplication 6
🟢 Coverage 91.87% diff coverage · +0.12% coverage variation
Metric Results Coverage variation ✅ +0.12% coverage variation (-1.00%) Diff coverage ✅ 91.87% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (798adc4) 66835 47960 71.76% Head commit (159ca71) 67204 (+369) 48307 (+347) 71.88% (+0.12%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#742) 369 339 91.87% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #742 +/- ##
============================================
+ Coverage 72.59% 72.72% +0.13%
- Complexity 22863 23008 +145
============================================
Files 711 719 +8
Lines 71267 71687 +420
============================================
+ Hits 51738 52137 +399
- Misses 19529 19550 +21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Line 225 carried a 5-space indent from the re-pin; the sibling census consts use 4. Aligning it clears the sole PHP CodeSniffer error (0 errors, warnings unchanged). CI-faithful: verified with the vendored phpcs 3.13.6.
S61 — phlix-server: CLI
user:*commands with--json+ last-admin guardStep S61 (lane s61srv). Adds operator-facing console commands for user
management with a machine-readable
--jsoncontract, and the in-repositorylast-admin guard consumed by the destructive/revoke paths.
What ships
src/Console/Commands/Concerns/JsonOutput.php— per-repo--jsonhelper.Success renders
{"ok":true,"data":[...]}, failure{"ok":false,"error":"..."}.This is the server-side copy; the hub ships an identical helper as its own
second copy (deliberately not pushed into
detain/phlix-shared, per rulingR6).
src/Auth/UserRepository.php—countAdmins()andisLastAdmin()(SELECT-only; no writes, no migration).
bin/phlixvia a lazyUserRepositoryfactory:user:list(--statusfilter, sensitive columns redacted),user:create,user:promote(--revoke),user:delete(--force),user:approve,user:disable,user:reject.CommandTestertests with and without--json, plusUserRepositoryAdminTestadditions (count predicate, isLastAdmin true/false,non-admin short-circuit asserting
queryis never called).Last-admin guard (absolute)
The destructive/revoke paths refuse to strip the final admin:
--forcebypasses the confirmation step, never the guard. Tests prove boththe plain rejection and that
--forceis still rejected for the last admin.Scope guards (rulings honoured)
edits; the
AdminUserControllerendpoints are untouched.Verification (local, CI-faithful venue)
Unittest suite:OK (10566 tests, 73888 assertions, 5 skipped)— the5 skips are all environment-dependent (Workerman timer ×3, mysqldump, FFI).
phpstan analyze src/ --level=9→ no errors;phpstan -c phpstan-tests.neon→ no errors.phpcs --standard=PSR12 src/→ 0; per-command test files add 0 errors/0 warnings.assertion-escape-check.php→ no escapes;assertion-escape-audit.php --probe→ exit 0, undecided set matches baseline.security-audit-check.php→ no advisories;composer validate --strict→ valid.php_strip_whitespace) corpus scan and absent from every*.md.