refactor: migrate FFI layer to Lib singleton with instance methods - #25
Merged
CodeWithKyrian merged 1 commit intoJun 1, 2026
Merged
Conversation
CodeWithKyrian
force-pushed
the
refactor/ffi-lib-singleton-and-instance-methods
branch
from
June 1, 2026 14:28
6f3fb7e to
5853681
Compare
CodeWithKyrian
deleted the
refactor/ffi-lib-singleton-and-instance-methods
branch
June 1, 2026 14:43
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.
This PR replaces the old Bindings interface + static helpers FFI pattern with a singleton Lib class that uses
@methodannotations and__call()forwarding for a cleaner, more idiomatic PHP developer experience.Motivation and Context
The old architecture had a separate
Bindingsinterface listing all ~140 C function signatures for IDE autocompletion, plus aLibclass with static helper methods.Lib::get()returned a raw\FFItyped asBindings&\FFI, which wasn't a natural PHP API surface. All helpers were static, making the codebase harder to navigate and refactor.What's Changed
Libis now a proper singleton with@methodPHPDoc annotations (replacingBindings.php, which was deleted)Lib::get()returns aLibinstance with full IDE autocomplete via@method__call()to the underlying\FFIinstancecheckStatus,getLastError,createCArray,readSizeTArray(renamed fromextractShapeFromPointer) converted to instance methodscreateShapeArrayandcreateOutputMetadataBuffersremoved and inlined at all call sites$ffito$libto reflect theLibtypeAGENTS.mdandCONTRIBUTING.mdBreaking Changes
None. All public APIs remain identical; this is purely an internal refactor.