Skip to content

🐛 fix: Flags::withPath() works statically, as the docs show - #2

Merged
gfazioli merged 1 commit into
mainfrom
fix/static-with-path
Oct 7, 2026
Merged

gfazioli merged 1 commit into
mainfrom
fix/static-with-path

Conversation

@gfazioli

@gfazioli gfazioli commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

What

The docs and README show Flags::withPath('config/flags.yaml')->get(...), but withPath() was a declared instance method, which PHP refuses to call statically: Error: Non-static method WPKirk\Flags\Flags::withPath() cannot be called statically. The private callabeWithPath() meant for it was misspelt and, with withPath() declared, never reached either.

withPath() and flags() are now magic like get(): __call and __callStatic route all three to callable*(), so each works on an instance and statically. The lookup is the private value(); @method tags keep the three visible to IDEs.

Proof

A live smoke (packages-live-smoke.sh flags) runs every call form of the docs page inside the Packages boilerplate on a real WordPress, reading its config/flags.yaml:

Call form 1.0.4 (last tag) main this branch
wpbones_flags()->get(…), (new Flags())->get(…), wpbones_flags($path)->get(…), ->withPath(…)->get(…) ×2 ✗ fatal (5 forms) ✓ ✓
wpbones_flags()->flags(…), Flags::get(…), a missing key's default ✓ ✓ ✓
Flags::withPath(…)->get(…) ✗ fatal ✗ fatal ✓
withPath() really reads the other file (instance and static) ✗ ✗ static ✓

To be released as 1.1.0 together with main's unreleased __call (2025-05), which fixed the five instance forms.

The docs and README show Flags::withPath('config/flags.yaml')->get(...),
but withPath() was a declared instance method, which PHP refuses to call
statically ("Non-static method ... cannot be called statically"). The
private callabeWithPath() meant for it was misspelt and, with withPath()
declared, never reached either.

withPath() and flags() are now magic like get(): __call and __callStatic
route all three to callable*(), so each works on an instance and
statically. The lookup is the private value(); @method tags keep them
visible to IDEs.
@gfazioli
gfazioli requested a balanced review from Copilot October 7, 2026 09:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gfazioli

gfazioli commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Reviews: Copilot unavailable (quota). Codex (gpt-6-sol) round 1 clean: it exercised the instance and static dispatch of get/flags/withPath against other files and found no regression. Live smoke 12/12 on this branch (2 ✗ on main, 8 ✗ on 1.0.4).

@gfazioli
gfazioli merged commit 5066d1d into main Oct 7, 2026
@gfazioli
gfazioli deleted the fix/static-with-path branch October 7, 2026 09:42
gfazioli added a commit to wpbones/WPKirk-Packages-Boilerplate that referenced this pull request Oct 7, 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