-
Notifications
You must be signed in to change notification settings - Fork 35
Enhance type safety with Psalm domain types and fix static analysis errors #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
21b7931
Add comprehensive Psalm domain types and improve type safety
koriym 7579558
Fix duplicate template variable names in Types.php
koriym be27968
Clean up unused type definitions and improve formatting
koriym 1c96b56
Add Psalm type imports to enhance type safety across multiple classes
koriym 5034ccf
Refactor method argument types to use MethodArguments for improved ty…
koriym 0f03923
Replace generic array types with domain-specific type aliases
koriym 984f82b
Fix static analysis errors in Ray.Di type system
koriym f7585a2
Replace legacy demo/ with modern PHP8 Attribute-based demos
koriym 7b3b7a3
Update GitHub Actions to use latest versions of checkout and cache ac…
koriym b8b2773
Clean up demo/tmp directory from temporary files
koriym 64010a8
Rename demo-php8.yml to demo.yml for consistency
koriym a08a24f
Fix duplicate type aliases to standardize naming conventions
koriym d016ec3
Fix parameter annotation order in ContainerFactory
koriym File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| Ray.Di is a dependency injection and AOP (Aspect-Oriented Programming) framework for PHP inspired by Google Guice. It provides annotations-based dependency injection with support for AOP interceptors. | ||
|
|
||
| ## Core Architecture | ||
|
|
||
| ### Key Components | ||
| - **AbstractModule**: Base class for defining dependency bindings. Modules are composed using `install()` and can be overridden using `override()` | ||
| - **Injector**: Main entry point that manages the DI container and creates instances. Auto-registers generated proxy classes and handles untargeted bindings | ||
| - **Bind**: Fluent API for creating bindings (`.to()`, `.toProvider()`, `.toInstance()`, `.in()`) | ||
| - **Container**: Internal storage for all bindings and dependencies | ||
| - **Annotations**: Located in `src/di/Di/` - includes `@Inject`, `@Named`, `@Assisted`, etc. | ||
|
|
||
| ### Directory Structure | ||
| - `src/di/`: Core DI framework code | ||
| - `src-deprecated/`: Legacy code maintained for compatibility | ||
| - `tests/di/`: Unit tests with extensive fake classes for testing | ||
| - `demo/` and `demo-php8/`: Examples showing framework usage | ||
| - Compiled proxy classes are cached in configurable temp directories | ||
|
|
||
| ## Development Commands | ||
|
|
||
| ### Testing | ||
| ```bash | ||
| composer test # Run PHPUnit tests | ||
| composer coverage # Generate test coverage with Xdebug | ||
| composer pcov # Generate coverage with PCOV (faster) | ||
| ``` | ||
|
|
||
| ### Code Quality | ||
| ```bash | ||
| composer cs # Run PHP_CodeSniffer | ||
| composer cs-fix # Auto-fix coding standards | ||
| composer sa # Static analysis (Psalm + PHPStan) | ||
| composer clean # Clear analysis caches | ||
| ``` | ||
|
|
||
| ### Build Pipeline | ||
| ```bash | ||
| composer build # Full build: cs + sa + pcov + metrics | ||
| composer tests # Quick check: cs + sa + test | ||
| ``` | ||
|
|
||
| ### Analysis Tools | ||
| ```bash | ||
| composer phpmd # PHP Mess Detector | ||
| composer metrics # Generate code metrics | ||
| composer baseline # Update static analysis baselines | ||
| ``` | ||
|
|
||
| ## Testing Strategy | ||
|
|
||
| - Tests use extensive fake classes in `tests/di/Fake/` to simulate real-world scenarios | ||
| - Supports both PHP 7.2+ and PHP 8+ with separate test suites | ||
| - Cache files are automatically cleaned between test runs | ||
| - AOP proxy generation is tested with temporary directories | ||
|
|
||
| ## Framework Patterns | ||
|
|
||
| ### Module Definition | ||
| ```php | ||
| class MyModule extends AbstractModule | ||
| { | ||
| protected function configure(): void | ||
| { | ||
| $this->bind(Interface::class)->to(Implementation::class); | ||
| $this->bind(Service::class)->toProvider(ServiceProvider::class); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Injection Usage | ||
| ```php | ||
| $injector = new Injector(new MyModule()); | ||
| $instance = $injector->getInstance(Interface::class); | ||
| ``` | ||
|
|
||
| ## Important Notes | ||
|
|
||
| - Ray.Di generates proxy classes for AOP which are cached in temp directories | ||
| - The framework supports both constructor and setter injection | ||
| - All bindings are resolved at runtime with automatic proxy weaving for aspects | ||
| - Multi-binding support allows collecting multiple implementations of the same interface |
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
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
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| parameters: | ||
| errorFormat: raw | ||
| level: max | ||
| paths: | ||
| - src/di | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.