Document why getClass existed, and which of it and new is right where - #187
Merged
Conversation
The plugin docs already tell a plugin author what to write. What was missing is the overarching version: what changed, why the factory existed in the first place, and the rule for choosing between the two. The "why it existed" half matters most, because without it the change reads as a style preference someone imposed. It was not. FOG's move into namespaces renamed 226 files, the tree had to keep working after every commit, and one function turning a bare name into whatever the namespace happened to be that week is exactly the right tool for that -- 459 literal call sites across 120 files went through the whole migration unedited. The project's own refactor brief called it the reason the migration was tractable. It stopped earning that keep when the migration finished. The "why it went" half is the evidence: a factory declared @return object|mixed erases the type, so converting the tree surfaced 90 PHPStan errors on a baseline that reported zero, every one pre-existing and previously unreachable. And it was never a substitution seam, which is the usual argument for keeping a factory -- qualify() consults core's map before the plugins', so a bare name could only ever resolve to one class. The rule, as a table: a literal gets new (imported inside packages/web/src, fully qualified in a file with no namespace and throughout fog-plugins); a variable gets getClass(), which is the one shape new cannot express and is what the function is now for. Plus the two literal forms that survive because they have no new equivalent at all. Numbers verified against the current tree rather than taken from the ADR: 43 variable-named sites remain in packages/web/src, and the gate reports 3 literals in 2 distinct names, which are the surviving forms. Also adds install-script-architecture and fos-release-workflows to the Development index, which had been listing six of its eight pages. Verified: docs:build clean, check-anchors 0 broken (including the path-qualified anchor into plugin-development), check-version-split consistent, node --test 63/63, show-nav places the page, no unparsed wikilink. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014PabMCuXYVRKbye7RAHaBC
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.
The plugin docs already tell a plugin author what to write (PR #182). What was missing is the overarching version you asked for: what changed, why the factory existed in the first place, and the rule for choosing between the two.
New page:
development/naming-a-class— Naming a Class — new and getClass.Why the "why it existed" half matters
Without it the change reads as a style preference someone imposed. It was not. FOG's move into namespaces renamed 226 files and the tree had to keep working after every commit; one function turning a bare name into whatever the namespace happened to be that week is exactly the right tool for that job. 459 literal call sites across 120 files went through the entire migration unedited — the project's own refactor brief called it the reason the migration was tractable.
It stopped earning its keep when the migration finished.
Why the literal form went
@return object|mixedmeans nothing can check what you do with the result. Converting the tree surfaced 90 PHPStan errors on a baseline that reported zero — every one pre-existing and previously unreachable.qualify()consults core's map before the plugins', so a bare name could only ever resolve to one class.The rule, as a table
packages/web/srcuseimport +new Host()fog-pluginsnew \FOG\Items\Host()self::getClass($name)self::getClass($name, '', true)Plus the two literal forms that survive because they have no
newequivalent at all, how the gate enforces it, andbin/getclass-to-new.phpfor re-running the sweep on a plugin tree or a long-lived branch.Numbers
Verified against the current tree rather than taken from ADR 0043: 43 variable-named sites remain in
packages/web/src, andtests/getclass-literals.test.phpreports 3 literals in 2 distinct names, which are the surviving forms.Also adds
install-script-architectureandfos-release-workflowsto the Development index, which had been listing six of its eight pages.Verification
docs:buildclean ·check-anchors0 broken (including the path-qualified anchor intoplugin-development) ·check-version-splitconsistent ·node --test63/63 ·show-navplaces the page · no unparsed wikilink.🤖 Generated with Claude Code
https://claude.ai/code/session_014PabMCuXYVRKbye7RAHaBC