Repository navigation
v1.1.0
π Struct v1.1.0 - Major Release
This release brings significant architectural improvements, new features, and enhanced developer experience to the Struct library.
β¨ What's New
ποΈ Architectural Improvements
- SOLID Principles: Complete refactoring following SOLID design principles
- Performance Optimization: Reflection caching system for improved performance
- Metadata System: Comprehensive metadata management with caching
- Factory Pattern: Centralized struct creation with dependency injection support
π§ New Features
- Advanced Validation System: New
ValidationRuleinterface with built-in rulesEmailRule- Email format validationRangeRule- Numeric range validationRequiredRule- Required field validation
- Data Transformation System:
TransformerInterfacefor data processingStringToUpperTransformer- Convert strings to uppercaseStringToLowerTransformer- Convert strings to lowercase
- Specialized Exception Handling:
ValidationException- Detailed validation errorsFieldNotFoundException- Missing field errors
- Legacy Validator Support: Backward compatibility for existing validators
π§ͺ Testing & Quality
- 90%+ Code Coverage: Comprehensive test suite with 139 tests
- PHPStan Level 9: Maximum static analysis compliance
- Automated Example Testing: New
test-examples.shscript - Test Fixtures: Organized following "1 file - 1 class" principle
π Documentation & Examples
- Enhanced README: Comprehensive documentation with real-world examples
- New Examples: 8 detailed examples covering all features
- Best Practices: Guidelines for effective library usage
- Migration Guide: Clear upgrade path from previous versions
π Breaking Changes
Field Attribute Changes
// Old (deprecated)
#[Field('string', validator: EmailValidator::class)]
// New (recommended)
#[Field('string', validationRules: [new EmailRule()])]Exception Handling
// Old
try {
$struct = new MyStruct($data);
} catch (RuntimeException $e) {
// Handle error
}
// New
try {
$struct = new MyStruct($data);
} catch (ValidationException $e) {
echo "Field: " . $e->fieldName;
echo "Value: " . $e->value;
} catch (FieldNotFoundException $e) {
// Handle missing field
}π Statistics
- 61 files changed
- 3,935 additions, 302 deletions
- 139 tests (335 assertions)
- 90%+ code coverage
- PHPStan Level 9 compliance
- PSR-12 coding standards
π οΈ Technical Details
New Classes & Interfaces
ValidationRuleinterfaceTransformerInterfaceinterfaceValidationResultclassFieldValidatorclassMetadataFactoryclassStructFactoryclassJsonSerializerclassReflectionCacheclass
Enhanced Features
- Union type support
- Advanced validation rules
- Data transformation pipeline
- Metadata caching system
- Factory pattern implementation
- Comprehensive error handling
π― Use Cases
Perfect for:
- REST API validation with complex rules
- Data Transfer Objects (DTOs) in clean architecture
- Third-party API integration with field mapping
- Form validation with data transformations
- Enterprise applications with centralized creation
- Data processing pipelines with automatic validation
π¦ Installation
composer require tommyknocker/structπ Links
π Contributors
Special thanks to all contributors who helped make this release possible!
Full Changelog: v1.0.0...v1.1.0