Skip to content

fix(server): deduplicate generateUuid() into Phlix\Common\Uuid::v4() (Step C2)#335

Closed
detain wants to merge 1 commit into
masterfrom
fix/server-c2-dedupe-uuid
Closed

fix(server): deduplicate generateUuid() into Phlix\Common\Uuid::v4() (Step C2)#335
detain wants to merge 1 commit into
masterfrom
fix/server-c2-dedupe-uuid

Conversation

@detain

@detain detain commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

Step C2 of the deduplication plan: consolidate ~32 duplicate generateUuid() methods into a single shared implementation.

What changed

  • New src/Common/Uuid.php: A final readonly class with a single static v4() method producing RFC 4122 v4 UUIDs matching the historical per-class implementation format.
  • 32 classes updated: Each private function generateUuid() now delegates to Uuid::v4() — all call sites unchanged (BC wrappers preserved).
  • PluginRepository: The one public static function generateUuid() is kept as a BC wrapper calling Uuid::v4().
  • Removed dead code: UUID_FORMAT constant from PluginRepository (was only used by the replaced method); UUID_FORMAT constant from WebhookDispatcher (was only used by the replaced method).
  • New test tests/Unit/Common/UuidTest.php: 7 focused tests covering format compliance, version digit, variant digit, length, and uniqueness.

Verification

Check Result
PHPStan level 9 ✅ PASS
PHPCS PSR-12 ✅ PASS
Integration tests ✅ 41 pass (5 skipped)
New UuidTest ✅ 7 tests, 11 assertions

Note on Unit test suite

The full phpunit suite (Unit tests) has a pre-existing bootstrap failure: WorkermanArrTransportTest.php references Phlix\Shared\Arr\Transport\ArrTransportInterface which does not exist in detain/phlix-shared: 0.10.0. This is unrelated to this PR — it fails on origin/master too. The Integration suite runs clean.

Step C2: Consolidate ~32 duplicate private generateUuid() methods into a
single shared Phlix\Common\Uuid::v4() implementation.

- Add new Phlix\Common\Uuid final readonly class with static v4() method
  producing RFC 4122 v4 UUIDs matching the historical sprintf format.
- Replace all private generateUuid() method bodies with 'return Uuid::v4()'
  as BC wrappers (callers unchanged).
- For PluginRepository, keep public static generateUuid() as BC wrapper.
- Remove now-unused UUID_FORMAT constant from PluginRepository.
- Add comprehensive UuidTest covering format, version digit, variant
  digit, and uniqueness across multiple calls.
- Remove duplicate UUID_FORMAT constant from WebhookDispatcher (unused).
- All call sites preserved; no behaviour change.

PHPStan level 9: clean.
PHPCS PSR-12: clean.
Integration tests: 41 pass (5 skipped).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 37 medium · 26 minor

Alerts:
⚠ 63 issues (≤ 0 issues of at least minor severity)

Results:
63 new issues

Category Results
BestPractice 37 medium
1 minor
Documentation 12 minor
CodeStyle 13 minor

View in Codacy

🟢 Metrics 7 complexity · 0 duplication

Metric Results
Complexity 7
Duplication 0

View in Codacy

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

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.45455% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.93%. Comparing base (55646ae) to head (58fb069).

Files with missing lines Patch % Lines
src/Admin/BackupManager.php 0.00% 1 Missing ⚠️
src/Auth/WebAuthn/WebAuthnManager.php 0.00% 1 Missing ⚠️
src/Common/Uuid.php 91.66% 1 Missing ⚠️
src/Dlna/PlayToManager.php 0.00% 1 Missing ⚠️
src/LiveTv/GuideManager.php 0.00% 1 Missing ⚠️
src/LiveTv/LiveTvManager.php 0.00% 1 Missing ⚠️
src/LiveTv/Relay/HlsRelayManager.php 0.00% 1 Missing ⚠️
src/Media/Extras/ExtrasRepository.php 0.00% 1 Missing ⚠️
src/Media/Library/LibraryManager.php 0.00% 1 Missing ⚠️
src/Media/Streaming/StreamManager.php 0.00% 1 Missing ⚠️
... and 3 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #335      +/-   ##
============================================
- Coverage     59.93%   59.93%   -0.01%     
- Complexity    13005    13007       +2     
============================================
  Files           480      481       +1     
  Lines         42399    42123     -276     
============================================
- Hits          25413    25246     -167     
+ Misses        16986    16877     -109     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@detain detain closed this Jun 29, 2026
@detain detain deleted the fix/server-c2-dedupe-uuid branch June 29, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant