Repository navigation
🐛 fix: Flags::withPath() works statically, as the docs show - #2
Merged
Merged
Conversation
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.
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
added a commit
to wpbones/WPKirk-Packages-Boilerplate
that referenced
this pull request
Oct 7, 2026
wpbones/flags 8deb594 → 5066d1d (wpbones/flags#2). Lock only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The docs and README show
Flags::withPath('config/flags.yaml')->get(...), butwithPath()was a declared instance method, which PHP refuses to call statically:Error: Non-static method WPKirk\Flags\Flags::withPath() cannot be called statically. The privatecallabeWithPath()meant for it was misspelt and, withwithPath()declared, never reached either.withPath()andflags()are now magic likeget():__calland__callStaticroute all three tocallable*(), so each works on an instance and statically. The lookup is the privatevalue();@methodtags 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 itsconfig/flags.yaml:wpbones_flags()->get(…),(new Flags())->get(…),wpbones_flags($path)->get(…),->withPath(…)->get(…)×2wpbones_flags()->flags(…),Flags::get(…), a missing key's defaultFlags::withPath(…)->get(…)withPath()really reads the other file (instance and static)To be released as 1.1.0 together with main's unreleased
__call(2025-05), which fixed the five instance forms.