feat: strengthen type safety and module boundaries#351
Open
Chemaclass wants to merge 9 commits intomainfrom
Open
feat: strengthen type safety and module boundaries#351Chemaclass wants to merge 9 commits intomainfrom
Chemaclass wants to merge 9 commits intomainfrom
Conversation
Split AbstractFactory responsibilities into focused interfaces: - ServiceFactoryInterface: for managing service singletons - ConfigAccessorInterface: for accessing module configuration - ProviderAccessorInterface: for accessing provided dependencies This improves separation of concerns and enables more flexible architecture patterns.
Implement PHPStan extension to enforce module boundaries and prevent direct cross-module access to Domain and Infrastructure classes. Modules can now only communicate through Facades, ensuring better encapsulation and maintainability.
Enhanced generic type hints across core framework classes: - Added @template with return type constraints for better type inference - Improved AbstractFacade with @psalm-consistent-constructor - Enhanced singleton() with callable return type specification - Added @psalm-return annotations for PHPStan/Psalm - Strengthened generic bounds in AbstractFactory and AbstractProvider - Updated all interface contracts with template generics This enables better IDE autocomplete and static analysis for module development.
Added ModuleDependenciesInterface and dependencies() method to AbstractFacade: - New ModuleDependenciesInterface for declaring inter-module dependencies - Default empty implementation in AbstractFacade - Returns array of facade class names that the module depends on - Enables dependency graph visualization and circular dependency detection Modules can now override dependencies() to explicitly declare their dependencies.
cd1894d to
7237016
Compare
Chemaclass
added a commit
that referenced
this pull request
Feb 13, 2026
- Add return type annotation to arrow function in Container.php lazy services - Fix preg_match conditions to explicitly check === 1 in ModuleBoundaryRule - Remove deleted Event classes references from multiple files: - PhpConfigReader, DocBlockResolverCache, ClassResolverCache - AbstractClassResolver, ClassNameFinder - SetupMerger, Config - Add template parameter specifications for generic classes: - AbstractFacade<AbstractFactory<AbstractConfig>> - AbstractProvider<AbstractConfig> - Remove template TDependency from ProviderAccessorInterface (non-inferrable) - Regenerate Psalm baseline after all fixes Note: Additional event dispatcher cleanup needed in Setup classes
- Delete SetupEventDispatcher.php - Remove event properties from Properties, SetupGacela, SetupGacelaInterface - Remove event methods: getEventDispatcher, setEventDispatcher, get/setGenericListeners, get/setSpecificListeners, canCreateEventDispatcher - Remove event properties from GacelaConfig and GacelaConfigTransfer - Remove event registration methods from GacelaConfig - Remove event constants from AbstractSetupGacela Note: 23 PHPStan errors remain, mainly type covariance issues
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.
TL;DR
Introduces stricter type safety through interface segregation, generic types, and PHPStan rules to enforce module boundaries and explicit dependency declarations.
Summary
Key Changes
New Interfaces:
ConfigAccessorInterface- Access to module configurationProviderAccessorInterface- Access to dependency providersServiceFactoryInterface- Access to service factoriesNew Commands:
analyze:dependencies- Analyze module dependencies with multiple output formatsversion:check- Check module version compatibilityPHPStan Integration:
Dependency Management:
Infrastructure: