Skip to content

Delete UrlRoutable.php interface and cut off the Model from the routing and PSR12

Choose a tag to compare

@macropay-solutions macropay-solutions released this 04 Sep 19:14
· 93 commits to production since this release
a7f24b4

Refactor: Enforce strict Model architecture, eliminate magic forwarding, and decouple HTTP routing

This commit introduces a fundamental architectural shift to the Macropay-Solutions PHP-Framework, officially transitioning the ORM from a legacy "God Class" pattern to a strictly typed, explicit engine. It removes deep-rooted magic, enforces PHP 8 type contracts globally, and cleanly segregates the Database and HTTP layers.

Key Architectural Changes:

Eliminated Query Builder Proxying: Removed the ForwardsCalls trait and gutted the Model::__call() fallback. Magic queries (e.g., $model->where() or static Model::find()) are no longer supported. Developers must now explicitly request the builder via Model::query()->where().

Decoupled ORM from the HTTP Layer: Deleted the UrlRoutable interface and eradicated all route-binding leakage from the ORM. Gutted implicit model binding resolution from Broadcaster and UrlGenerator, enforcing explicit scalar ID passing across the framework.

Enforced Strict Interface Contracts: Upgraded foundational interfaces (Arrayable, Jsonable, CanBeEscapedWhenCastToString) with strict PHP 8 return types (: array, : string, : static). Systematically propagated these strict contracts across all implementing classes, including Paginator, Collection, Fluent, MessageBag, and ValidatedInput.

Optimized Internal Execution: Replaced legacy call_user_func() mechanisms with highly optimized direct static closure invocations (e.g., (static::$callback)($this, $keys)).

Bypassed Magic Method Overhead: Refactored internal framework logic (such as unique ID generation in HasUniqueIds) to use explicit getAttributeValue() and setAttribute() methods, bypassing expensive __get/__set magic method loops.

Secured Serialization Accuracy: Changed the default value of HasAttributes::$snakeAttributes to false to prevent the hidden mutation of camelCase column names during array/JSON serialization.

Breaking Changes:

UrlRoutable is removed; implicit model injection in controllers and broadcast channels requires manual ID fetching.

Direct builder method calls on model instances will now throw a BadMethodCallException. Always chain from ->query().