Skip to content

fix: Resolve 2.2 review issues#120

Merged
detain merged 1 commit into
masterfrom
fix/2.2-review-fixes
May 23, 2026
Merged

fix: Resolve 2.2 review issues#120
detain merged 1 commit into
masterfrom
fix/2.2-review-fixes

Conversation

@detain
Copy link
Copy Markdown
Owner

@detain detain commented May 23, 2026

Summary

Fixes issues found in the 2.2 review:

Issue 1 (Major): Double file open

Refactored harvestFlacTags() to extract STREAMINFO duration in the same file pass instead of reopening via getFlacDuration(). Added helper method parseFlacDurationFromData() to support this.

Issue 2 (Major): Missing direct unit tests for getFlacDuration()

Added direct unit tests for getFlacDuration() using reflection:

  • testGetFlacDurationWithValidFlacReturnsInt
  • testGetFlacDurationWithInvalidSampleRateReturnsNull
  • testGetFlacDurationWithZeroTotalSamplesReturnsNull
  • testGetFlacDurationWithStreaminfoNotFirstBlockReturnsNull

Issue 3 (Minor): Fix misleading comment

Changed "upper 4 bits" to "lower 4 bits" in byte 7 comment for total_samples[32:35].

Issue 4 (Minor): Strengthen zero-samples test

Verified testHarvestTagsFlacWithZeroTotalSamplesReturnsNoDuration already has assertArrayNotHasKey('duration_secs', $tags).

Testing

All 16 AudioScanner tests pass:

✔ Get flac duration with valid flac returns int
✔ Get flac duration with invalid sample rate returns null
✔ Get flac duration with zero total samples returns null
✔ Get flac duration with streaminfo not first block returns null

PHPStan level 9 passes (only unused method warning for getFlacDuration which is tested via reflection). PHPCS PSR-12 passes.

…n tests, fix comment

- Issue 1 (Major): Refactor harvestFlacTags() to extract STREAMINFO
  duration in the same file pass instead of reopening via getFlacDuration()
- Issue 2 (Major): Add direct unit tests for getFlacDuration() using
  reflection - valid FLAC, invalid sample rate, zero total samples,
  STREAMINFO not first block
- Issue 3 (Minor): Fix misleading comment - byte 7 uses 'lower'
  not 'upper' 4 bits for total_samples[32:35]
- Issue 4 (Minor): Confirm zero-samples test already has
  assertArrayNotHasKey('duration_secs')
@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.

@detain detain merged commit 7006898 into master May 23, 2026
@detain detain deleted the fix/2.2-review-fixes branch May 23, 2026 11:43
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