feat: Modernize PSR-4 implementation with PHP 8.1+ types#1
Merged
ralflang merged 3 commits intoFRAMEWORK_6_0from Mar 7, 2026
Merged
feat: Modernize PSR-4 implementation with PHP 8.1+ types#1ralflang merged 3 commits intoFRAMEWORK_6_0from
ralflang merged 3 commits intoFRAMEWORK_6_0from
Conversation
Modernize Horde_Constraint PSR-4 implementation with full type declarations, consistent naming, and backward compatibility aliases. Changes: - Fix AndCoupler bug ($_constraints → $constraints) - Rename Coupler → CompoundConstraint (base class) - Add AllOf class (replaces AndCoupler implementation) - Add AnyOf class (replaces OrCoupler implementation) - Keep AndCoupler/OrCoupler/Coupler as BC aliases - Add full PHP 8.1+ type declarations (mixed, bool, readonly) - Update copyright years to 2026 - Improve PHPDoc with @param and @return - Use readonly properties where appropriate - Modern variadic constructor for CompoundConstraint PSR-4 classes now: - Constraint (interface) - evaluate(mixed): bool - CompoundConstraint (abstract) - base for compound constraints - AllOf - all constraints must pass (AND logic) - AnyOf - any constraint must pass (OR logic) - AlwaysTrue, AlwaysFalse - constant constraints - IsEqual, IsInstanceOf, IsNull - comparison constraints - Not - negation wrapper - PregMatch - regex matching Backward compatibility: - AndCoupler extends AllOf (deprecated) - OrCoupler extends AnyOf (deprecated) - Coupler extends CompoundConstraint (deprecated) For Horde_Log migration path.
Add complete test coverage for PSR-4 constraint implementations. Changes: - Update PHPUnit to 11.5 with modern configuration - Update composer.json (PHP ^8.1, PHPUnit ^11.5, keywords) - Create 9 PSR-4 test classes with 40 tests, 68 assertions - Modern PHPUnit attributes (#[CoversClass]) - Separate test suites (psr4, psr0) - Update bootstrap.php (remove Horde_Test dependency) Test Coverage: - AllOfTest (9 tests) - AND logic, flattening, empty case - AnyOfTest (10 tests) - OR logic, short-circuit, flattening - AlwaysTrueTest (1 test) - constant true - AlwaysFalseTest (1 test) - constant false - IsEqualTest (5 tests) - loose comparison, null behavior - IsInstanceOfTest (4 tests) - instanceof checks - IsNullTest (2 tests) - null checking - NotTest (4 tests) - negation, double negation - PregMatchTest (4 tests) - regex matching, modifiers All 40 PSR-4 tests pass on PHP 8.4.
Add complete documentation for PSR-4 modernization and package metadata updates. Documentation: - README.md (220 lines) - Quick start, all constraints, usage examples - UPGRADING.md (280 lines) - Migration guide from PSR-0 to PSR-4 - doc/changelog.yml - Version 3.0.0alpha6 entry Package Metadata: - .horde.yml → 3.0.0alpha6, PHP ^8.1, enhanced description - composer.json - Already updated in previous commits README covers: - Dual-stack architecture (PSR-0 + PSR-4) - Quick start with examples - All 11 constraint types documented - Usage patterns (complex rules, filtering, fluent building) - Architecture overview - Migration guide from PSR-0 - Class mapping table UPGRADING guide covers: - Zero breaking changes guarantee - PSR-4 API improvements (types, variadic, readonly) - Optional migration path (BC aliases vs modern names) - Horde_Log migration example - Deprecation notices - Testing strategies Total documentation: 500+ lines
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.
Modernizes Horde_Constraint with PHP 8.1+ type safety, fixes critical bugs, and provides complete test coverage.
Key changes:
Ready for Horde_Log to adopt PSR-4 constraints.