Repository navigation
v0.1.1 - Method Chaining Support
π Method Chaining Support
This release adds support for method chaining on Struct objects while maintaining full backward compatibility.
β¨ New Features
- Method chaining:
Struct::define()->toJson()now works! - toArray() method: Explicitly convert to array with internal caching
- toJson() method: Direct JSON conversion without extra steps
- ArrayAccess interface: Use schemas like arrays:
$schema['type'] - JsonSerializable: Works seamlessly with
json_encode()
π Changes
The Struct::define() method now returns a Struct object instead of a raw array. This enables method chaining while maintaining backward compatibility through the ArrayAccess interface.
Before (still works):
$schema = Struct::define('User', function (Builder $builder) {
$builder->string('name')->required();
});
$type = $schema['type']; // Array access still works!New (method chaining):
$json = Struct::define('User', function (Builder $builder) {
$builder->string('name')->required();
})->toJson(); // Direct method chaining!π Documentation
- README updated with comprehensive examples of the new API
- Added "Flexible API: Array Access + Object Methods" section
- Updated structure class examples with new return types
- Updated
make:structcommand stub to generate classes with correct return types
π§ͺ Technical Details
- β 119 tests passing with 399 assertions
- β Full backward compatibility maintained
- β PHPStan Level 9 compliance
- β PHP 8.2, 8.3, 8.4 support
- β Laravel 11 & 12 support
π¦ Installation
composer require blaspsoft/forerunner:^0.1Full Changelog: v0.1.0...v0.1.1