Skip to content

v1.1.0

Choose a tag to compare

@tommyknocker tommyknocker released this 25 Oct 15:28
· 1 commit to master since this release

πŸš€ 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 ValidationRule interface with built-in rules
    • EmailRule - Email format validation
    • RangeRule - Numeric range validation
    • RequiredRule - Required field validation
  • Data Transformation System: TransformerInterface for data processing
    • StringToUpperTransformer - Convert strings to uppercase
    • StringToLowerTransformer - Convert strings to lowercase
  • Specialized Exception Handling:
    • ValidationException - Detailed validation errors
    • FieldNotFoundException - 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.sh script
  • 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

  • ValidationRule interface
  • TransformerInterface interface
  • ValidationResult class
  • FieldValidator class
  • MetadataFactory class
  • StructFactory class
  • JsonSerializer class
  • ReflectionCache class

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