Skip to content

Fix Browscap Flysystem namespace scoping mismatch#188

Merged
parhumm merged 1 commit intodevelopmentfrom
fix/187-browscap-flysystem-namespace
Mar 13, 2026
Merged

Fix Browscap Flysystem namespace scoping mismatch#188
parhumm merged 1 commit intodevelopmentfrom
fix/187-browscap-flysystem-namespace

Conversation

@ParhamTehrani
Copy link
Copy Markdown
Contributor

@ParhamTehrani ParhamTehrani commented Mar 13, 2026

  • Update League\Flysystem imports to use SlimStat\Dependencies prefix
  • Fix class_exists() check for LocalFilesystemAdapter
  • Add stub exceptions for Flysystem 1.x compatibility

Fixes #187

Describe your changes

...

Submission Review Guidelines:

  • I have performed a self-review of my code
  • If it is a core feature, I have added thorough tests.
  • Will this be part of a product update? If yes, please write one phrase about this update.
  • I have reviewed my code for security best practices.
  • Following the above guidelines will result in quick merges and clear and detailed feedback when appropriate.
  • My code follows the style guidelines of this project
  • I have updated the change-log in CHANGELOG.md.

Type of change

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced file operation error handling with more specific exception types for file-related scenarios.
  • Refactor

    • Updated internal dependency namespace organization to improve code structure and maintainability.

- Update League\Flysystem imports to use SlimStat\Dependencies prefix
- Fix class_exists() check for LocalFilesystemAdapter
- Add stub exceptions for Flysystem 1.x compatibility

Fixes #187
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d408b465-6b33-4132-9be1-b4fd7a049aef

📥 Commits

Reviewing files that changed from the base of the PR and between b5f5b38 and 9f0e871.

📒 Files selected for processing (4)
  • src/Dependencies/League/Flysystem/FileExistsException.php
  • src/Dependencies/League/Flysystem/FileNotFoundException.php
  • src/Dependencies/MatthiasMullie/Scrapbook/Adapters/Collections/Flysystem.php
  • src/Dependencies/MatthiasMullie/Scrapbook/Adapters/Flysystem.php

📝 Walkthrough

Walkthrough

The PR introduces two new Flysystem exception stub classes and updates namespace references in Scrapbook adapter files from League\Flysystem\* to SlimStat\Dependencies\League\Flysystem\* to align with php-scoper's prefixing, resolving type hint mismatches in the Browscap cache initialization pipeline.

Changes

Cohort / File(s) Summary
New Flysystem Exception Stubs
src/Dependencies/League/Flysystem/FileExistsException.php, src/Dependencies/League/Flysystem/FileNotFoundException.php
Added two minimal compatibility exception classes that extend RuntimeException and implement FilesystemException, serving as type discriminators for Flysystem 1.x compatibility layer.
Scrapbook Adapter Namespace Updates
src/Dependencies/MatthiasMullie/Scrapbook/Adapters/Flysystem.php, src/Dependencies/MatthiasMullie/Scrapbook/Adapters/Collections/Flysystem.php
Updated all Flysystem imports from un-prefixed League\Flysystem\* to properly-scoped SlimStat\Dependencies\League\Flysystem\* namespace; adjusted version detection logic to reference scoped namespace.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A namespace was tangled, the scoper had slipped,
The rabbit hopped in with a prefix-fixing trip!
From League to Dependencies, the paths now align,
Browscap's cache flows smoothly—exceptions now shine! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing the Flysystem namespace scoping mismatch by updating un-prefixed imports to use the SlimStat\Dependencies prefix.
Linked Issues check ✅ Passed The pull request fully addresses issue #187 by updating all un-prefixed League\Flysystem imports to SlimStat\Dependencies\League\Flysystem across both Scrapbook adapter files and adding required Flysystem 1.x exception stubs.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the namespace mismatch: import updates in adapter files, version detection fixes, and new exception stub classes for Flysystem 1.x compatibility.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/187-browscap-flysystem-namespace
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@parhumm
Copy link
Copy Markdown
Contributor

parhumm commented Mar 13, 2026

One review note: this fixes the scoped Flysystem constructor mismatch from #187, but the existing E2E coverage still treats a Flysystem error as an acceptable outcome. In tests/e2e/pr184-server-side-tracking-api.spec.ts the assertions still allow the old fatal path instead of requiring a successful tracking result.

That means CI can keep passing even if this namespace regression comes back on a future dependency refresh. I'd tighten that test and remove the stale "pre-existing Browscap/Flysystem namespace scoping bug" note so this fix is actually pinned down by automation.

I spot-checked the runtime behavior locally: development still reproduces the constructor TypeError, while this PR branch constructs the scoped adapter successfully and passes basic set/get/delete and collection flush() smoke tests.

@parhumm
Copy link
Copy Markdown
Contributor

parhumm commented Mar 13, 2026

E2E QA Test Results — Issue #187 Fix Validation

Environment: WordPress 6.9.4 · PHP 8.5.0 · wp-slimstat 5.4.3 · wp-slimstat-pro 1.2.1 · Local (macOS)

Test Summary: 10/10 PASS

# Test Result
1 SlimStat Dependencies League Flysystem Filesystem class resolves PASS
2 SlimStat Dependencies League Flysystem FileExistsException class resolves PASS
3 SlimStat Dependencies League Flysystem FileNotFoundException class resolves PASS
4 SlimStat Dependencies League Flysystem FilesystemException interface resolves PASS
5 Critical: No TypeError — prefixed Filesystem accepted by Scrapbook adapter PASS
6 Full Browscap pipeline: LocalFilesystemAdapter to Filesystem to Flysystem to SimpleCache to Browscap PASS
7 class_exists() correctly detects Flysystem v2 with prefixed namespace PASS
8 Exception stubs implement FilesystemException and are Throwable PASS
9 No unprefixed League Flysystem classes loaded at runtime PASS
10 No Flysystem TypeError in debug.log after real browser pageviews PASS

Browser Tracking Verified (Playwright)

Two real browser pageviews tracked successfully with Browscap detection:

Code Review (simplify)

Three parallel review agents (reuse, quality, efficiency) found zero issues:

  • Both exception stubs are necessary (caught in 10 places across adapter code)
  • All 9 use statements + class_exists() correctly prefixed
  • FilesystemException interface exists in the prefixed namespace
  • No remaining unprefixed League Flysystem references in runtime code

Pre-existing Issue (not related to this PR)

ReferenceError: handleConsentUpgradeResult is not defined in wp-slimstat.js:1231 — this function is called but never defined. Confirmed present on development branch too. Does not block tracking (pageviews still record). Should be tracked separately.

Verdict: PASS — Ready to merge

The namespace scoping mismatch from #187 is fully resolved. The Browscap to Flysystem to Scrapbook pipeline works end-to-end without TypeError.

@parhumm parhumm merged commit 989f408 into development Mar 13, 2026
1 check passed
@parhumm parhumm deleted the fix/187-browscap-flysystem-namespace branch March 13, 2026 14:37
@parhumm parhumm mentioned this pull request Mar 14, 2026
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.

2 participants