Skip to content

Make Visibility enum string-backed#354

Draft
Firehed wants to merge 4 commits into
mainfrom
295/visibility-string-backed
Draft

Make Visibility enum string-backed#354
Firehed wants to merge 4 commits into
mainfrom
295/visibility-string-backed

Conversation

@Firehed

@Firehed Firehed commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Closes #295.

Visibility was int-backed solely to make isAccessibleFrom a >= comparison, despite significant adjacent string handling (format(), fromString(), and a raw ->value max() in TextFallbackHelper).

Changes

  • Flip the backing from int to string ('private'/'protected'/'public'). Accessibility ordering now lives in a private rank().
  • Add Visibility::atLeast(), replacing the raw Visibility::from(max($minVisibility->value, Visibility::Protected->value)) arithmetic in the text fallback.
  • format() collapses to return $this->value;, removing the duplicated literals.
  • Delete Visibility::fromString() in favor of native Visibility::from(). The three call sites parse a regex capture group that only ever matches the lowercase public|protected|private literals, which are now exactly the enum values; the empty-constant case keeps its existing explicit ternary.

The fromString test was removed alongside the method it covered.

🤖 Generated with Claude Code

@Firehed

Firehed commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

this actually may slightly decrease robustness by removing the lowercase match or pushing it to the edges, leaving it alone for the moment.

@Firehed
Firehed marked this pull request as draft July 18, 2026 01:18
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.78%. Comparing base (6f603d2) to head (549a0af).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #354      +/-   ##
============================================
- Coverage     96.78%   96.78%   -0.01%     
+ Complexity     1625     1624       -1     
============================================
  Files            97       97              
  Lines          4076     4074       -2     
============================================
- Hits           3945     3943       -2     
  Misses          131      131              

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

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.

Visibility enum should be string-backed, not int

1 participant