Finalize Expression's concrete builder combinators (keep the class extendable) - #102
Merged
MidnightDesign merged 1 commit intoJul 23, 2026
Conversation
The 17 concrete builder combinators (eq, neq, add, subtract, multiply, divide, modulo, gt, lt, gte, lte, or_, and_, not, call, matchesType, isSubtypeOf) are fixed algorithms that assemble the closed, internal node set. A subclass has no legitimate reason to override them, so finalize them. The class stays abstract/open and its four extension-point methods (location, evaluate, equals, getType) stay overridable, so subclassing to add a node still works. Add a reflection guard test pinning the invariant, and document the structural break in UPGRADING.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QUqJ7TWSpSRT1fVinWVRPf
MidnightDesign
deleted the
97-finalize-expressions-concrete-builder-combinators-keep-the-class-extendable
branch
July 23, 2026 14:44
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.
Closes #97. Scoped for the 0.3.0 breaking release.
What
Finalize the 17 concrete builder combinators on
Expression—eq,neq,add,subtract,multiply,divide,modulo,gt,lt,gte,lte,or_,and_,not,call,matchesType,isSubtypeOf. These are fixed algorithms that assemble the closed,@internal-constructed node set, so a subclass has no legitimate reason to override them.The class stays
abstract(notfinal) and its four extension-point methods —location,evaluate,equals,getType— stay abstract and overridable. SubclassingExpressionto add a custom node still works exactly as before; only the combinators are locked.Return types are left untouched — narrowing them to
selfand collapsingEq/Gtis the separate #92.Changes
src/Expression.php—finalon the 17 concrete combinators.tests/unit/ExpressionFinalizationTest.php(new) — reflection guard test matching the repo's structural-invariant style (seeInternalAnnotationConsistencyTest): asserts the class stays open/abstract, every combinator isfinal, and each extension point stays abstract and overridable.UPGRADING.md— API-changes note documenting the structural break.BC impact
Structural break: finalizing previously-published methods. Correct for a
0.MINORbump; the Roave checker will flag it as expected (it can't run in a worktree, so it isn't run here).Verification
phpunit— 1152 tests pass (22 new)psalm,phpstan— no errorsphp-cs-fixer,composer-require-checker— cleaninfection-diff(CI's 100% MSI gate on changed lines) — 16/16 mutations killed, Covered MSI 100%🤖 Generated with Claude Code