Skip to content
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

Introducing CompileVisitor using the visitor pattern #112

Open
wants to merge 68 commits into
base: 1.x
Choose a base branch
from

Conversation

koriym
Copy link
Member

@koriym koriym commented May 22, 2024

Stop using php-parser and assemble code with strings. Also, compile using the visitor pattern.

Summary by CodeRabbit

  • Chores

    • Updated .gitignore to exclude /tests/Fake/tmp.
    • Updated composer.json to modify version constraints for dependencies and adjust static analysis configuration.
    • Added a new requirement check task req-check in composer.json.
    • Updated composer-require-checker.json to adjust allowed types.
  • Refactor

    • Deprecated AbstractInjectorContext class and added @psalm-immutable annotation.
    • Removed unnecessary imports in various documentation files.
    • Removed use Ray\Di\NullCache; from CachedInjectorFactory.php.
  • New Features

    • Added AirInjector class implementing InjectorInterface for managing singleton instances and dynamic class loading.
  • Bug Fixes

    • Adjusted path in CachedFactoryTest.php for CachedInjectorFactory::getInstance().

Closes #78

Copy link

coderabbitai bot commented May 22, 2024

Walkthrough

The updates encompass various refinements, including dependency version adjustments in composer.json, static analysis configurations, and removal of deprecated entities. Additionally, a new class AirInjector and modifications to caching strategies have been introduced. These changes aim to enhance dependency management, code quality, and caching mechanisms, addressing issues like unbound interface dependencies.

Changes

Files/Paths Change Summary
.gitignore Added /tests/Fake/tmp to ignore list.
composer.json Updated version constraints for dependencies (ray/aop, ray/di, doctrine/cache), adjusted static analysis configuration, and added a new req-check task.
composer-require-checker.json Removed Ray\\Di entities, added Doctrine\\Common\\Annotations\\Reader, Doctrine\\Common\\Cache\\CacheProvider, Koriym\\Printo\\Printo to allowed types.
docs/example/DevInjectorContext.php Removed imports for ApcuCache, DiCompileModule, FakeCarModule.
docs/example/ProdInjectorContext.php Removed import use Ray\Compiler\FakeCarModule.
phpcs.xml Excluded specific rules related to function and variable declarations.
phpstan.neon Removed checkGenericClassInNonGenericObjectType parameter.
src-deprecated/AbstractInjectorContext.php Marked AbstractInjectorContext class as deprecated and added @psalm-immutable annotation.
src/AirInjector.php Introduced AirInjector class implementing InjectorInterface, managing singleton instances and dynamic class loading.
src-cached-injector-factory/CachedInjectorFactory.php Removed use Ray\Di\NullCache; statement.
src-cached-injector-factory/NullCache.php Provided methods for cache operations, extending CacheProvider.
tests/CachedFactoryTest.php Modified path passed to CachedInjectorFactory::getInstance() by removing /prod directory from the path.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant Client
    participant AirInjector
    participant Dependency
    Client->>AirInjector: getInstance(interface, name)
    AirInjector->>AirInjector: Check Singleton Cache
    AirInjector-->>Client: Return Instance (if cached)
    AirInjector->>Dependency: Load Dependency
    Dependency-->>AirInjector: Return Instance
    AirInjector->>Client: Return Instance
Loading

Assessment against linked issues

Objective (Issue #78) Addressed Explanation
Correct code generation for unbound interface dependencies The changes introduce improvements, but specific validation for unbound interface dependency handling is unclear.

Poem

In the code's vast, intricate weave,
New injectors and caches now breathe.
Dependencies align,
With a version so fine,
Our project's future we now believe.
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Outside diff range and nitpick comments (1)
src/Compiler.php (1)

15-40: The compile method in Compiler is well-implemented, with clear separation of concerns and effective use of assertions for type safety. Consider adding more detailed comments to explain the process steps.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between b4ad323 and b7d977b.
Files ignored due to path filters (1)
  • vendor-bin/tools/composer.lock is excluded by !**/*.lock
Files selected for processing (52)
  • .gitignore (1 hunks)
  • composer.json (3 hunks)
  • docs/exmaple/DevInjectorContext.php (1 hunks)
  • docs/exmaple/ProdInjectorContext.php (1 hunks)
  • phpcs.xml (2 hunks)
  • phpstan.neon (1 hunks)
  • src-deprecated/AbstractInjectorContext.php (1 hunks)
  • src-deprecated/AopCode.php (1 hunks)
  • src-deprecated/CachedInjectorFactory.php (1 hunks)
  • src-deprecated/Code.php (1 hunks)
  • src-deprecated/ContextInjector.php (1 hunks)
  • src-deprecated/DependencyCode.php (1 hunks)
  • src-deprecated/DependencySaver.php (1 hunks)
  • src-deprecated/DiCompiler.php (1 hunks)
  • src-deprecated/FactoryCode.php (1 hunks)
  • src-deprecated/FunctionCode.php (1 hunks)
  • src-deprecated/GraphDumper.php (2 hunks)
  • src-deprecated/InjectorFactory.php (1 hunks)
  • src-deprecated/IpQualifier.php (1 hunks)
  • src-deprecated/NodeFactory.php (1 hunks)
  • src-deprecated/Normalizer.php (2 hunks)
  • src-deprecated/OnDemandCompiler.php (1 hunks)
  • src-deprecated/OverrideLazyModule.php (1 hunks)
  • src-deprecated/PrivateProperty.php (1 hunks)
  • src-deprecated/ScriptInjector.php (1 hunks)
  • src-deprecated/ScriptinjectorModule.php (1 hunks)
  • src/AirInjector.php (1 hunks)
  • src/CompileInjector.php (1 hunks)
  • src/CompileVisitor.php (1 hunks)
  • src/Compiler.php (1 hunks)
  • src/InjectionPoint.php (2 hunks)
  • src/InstallBuiltinModule.php (1 hunks)
  • src/InstanceScript.php (1 hunks)
  • src/Scripts.php (1 hunks)
  • tests/AssistedTest.php (1 hunks)
  • tests/CachedFactoryTest.php (1 hunks)
  • tests/CompileInjectorTest.php (4 hunks)
  • tests/CompilerTest.php (1 hunks)
  • tests/DependencyCompilerTest.php (4 hunks)
  • tests/DiCompilerTest.php (3 hunks)
  • tests/Fake/Assisted/FakeAssistedConsumer.php (3 hunks)
  • tests/Fake/Assisted/FakeToBindModule.php (1 hunks)
  • tests/Fake/CompileVisitor/FakeFoo.php (1 hunks)
  • tests/Fake/CompileVisitor/FakeFooInterface.php (1 hunks)
  • tests/Fake/CompileVisitor/FakeFooModule.php (1 hunks)
  • tests/Fake/CompileVisitor/FakeFooProvider.php (1 hunks)
  • tests/Fake/Deep/FakeInjectorContext.php (1 hunks)
  • tests/Fake/FakeCarModule.php (1 hunks)
  • tests/Fake/MultiBindings/FakeMultiBindingsModule.php (2 hunks)
  • tests/Fake/MultiBindings/FakeSetNotFoundWithProvider.php (1 hunks)
  • tests/MultiBindingTest.php (6 hunks)
  • tests/ScriptInjectorTest.php (3 hunks)
Files not reviewed due to errors (4)
  • tests/Fake/MultiBindings/FakeMultiBindingsModule.php (no review received)
  • src/InjectionPoint.php (no review received)
  • composer.json (no review received)
  • src-deprecated/AopCode.php (no review received)
Files skipped from review due to trivial changes (26)
  • .gitignore
  • docs/exmaple/DevInjectorContext.php
  • phpstan.neon
  • src-deprecated/CachedInjectorFactory.php
  • src-deprecated/Code.php
  • src-deprecated/ContextInjector.php
  • src-deprecated/DependencyCode.php
  • src-deprecated/DependencySaver.php
  • src-deprecated/FactoryCode.php
  • src-deprecated/FunctionCode.php
  • src-deprecated/GraphDumper.php
  • src-deprecated/InjectorFactory.php
  • src-deprecated/IpQualifier.php
  • src-deprecated/NodeFactory.php
  • src-deprecated/Normalizer.php
  • src-deprecated/OnDemandCompiler.php
  • src-deprecated/OverrideLazyModule.php
  • src-deprecated/PrivateProperty.php
  • src-deprecated/ScriptinjectorModule.php
  • tests/AssistedTest.php
  • tests/CachedFactoryTest.php
  • tests/CompileInjectorTest.php
  • tests/DiCompilerTest.php
  • tests/Fake/CompileVisitor/FakeFooInterface.php
  • tests/Fake/Deep/FakeInjectorContext.php
  • tests/Fake/MultiBindings/FakeSetNotFoundWithProvider.php
Additional comments not posted (29)
tests/Fake/CompileVisitor/FakeFoo.php (1)

3-7: Class FakeFoo correctly implements FakeFooInterface for testing purposes.

tests/Fake/CompileVisitor/FakeFooProvider.php (1)

3-13: Class FakeFooProvider correctly implements ProviderInterface and provides instances of FakeFoo.

tests/Fake/Assisted/FakeToBindModule.php (1)

12-12: Ensure the binding for FakeAssistedConsumer is intended to be unqualified.

Verification successful

The search results indicate that FakeAssistedConsumer is used in various test cases and is bound in FakeToBindModule without specifying a concrete implementation or provider. This suggests that the unqualified binding might be intentional for testing purposes.

  • FakeAssistedConsumer is defined in tests/Fake/Assisted/FakeAssistedConsumer.php.
  • It is used in multiple test methods in tests/AssistedTest.php.

Given this context, it appears that the unqualified binding is indeed intentional and used for testing scenarios.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if `FakeAssistedConsumer` is intended to be unqualified.

# Test: Search for other bindings of `FakeAssistedConsumer`. Expect: No other bindings or a specific reason for unqualified binding.
rg --type php $'bind(FakeAssistedConsumer::class)'

Length of output: 51



Script:

#!/bin/bash
# Description: Verify if `FakeAssistedConsumer` is intended to be unqualified by searching for documentation or comments.

# Search for comments or documentation mentioning `FakeAssistedConsumer`.
rg --type php 'FakeAssistedConsumer' --context 5

# Search for the definition of `FakeAssistedConsumer` to understand its usage.
rg --type php 'class FakeAssistedConsumer'

Length of output: 3997

src/CompileInjector.php (1)

26-26: Method getInstance correctly delegates instance creation to AirInjector.

docs/exmaple/ProdInjectorContext.php (1)

Line range hint 1-18: Class setup in ProdInjectorContext is correctly configured for production dependencies.

tests/Fake/CompileVisitor/FakeFooModule.php (1)

25-30: The DI configuration in FakeFooModule is straightforward and correctly sets up the binding for FakeFooInterface.

tests/Fake/Assisted/FakeAssistedConsumer.php (1)

17-17: Transition from PHPDoc annotations to PHP 8 attributes in FakeAssistedConsumer is correctly implemented.

Also applies to: 29-29, 44-44

src/Scripts.php (1)

13-40: Implementation of the Scripts class is clear and effectively utilizes PHP standard functions for managing script entries.

tests/Fake/FakeCarModule.php (1)

28-32: Addition of new bindings in FakeCarModule is correctly done, with appropriate use of Scope::SINGLETON for certain components.

src-deprecated/ScriptInjector.php (2)

25-30: Constructor logic is well-implemented, ensuring proper initialization of the injector and handling of the module compilation.


36-38: Method getInstance correctly delegates to AirInjector, maintaining clean separation of concerns.

src-deprecated/DiCompiler.php (2)

23-42: Constructor effectively sets up the injector and compiles the module, ensuring that InjectorInterface is bound correctly.


48-50: Method getInstance correctly delegates to AirInjector, maintaining clean separation of concerns.

src/CompileVisitor.php (1)

28-139: The implementation of CompileVisitor adheres to the visitor pattern effectively, handling various types of dependency injections and component interactions within the Ray\Compiler context.

phpcs.xml (1)

Line range hint 31-43: The exclusions in the coding standard configuration are extensive. Ensure that these exclusions do not inadvertently allow code quality issues to pass unnoticed.

tests/DependencyCompilerTest.php (1)

47-55: Ensure that the PHP version requirement (@requires PHP 8.3) is justified by the use of features exclusive to this version.

tests/MultiBindingTest.php (1)

Line range hint 45-91: The type annotations for Map<FakeEngineInterface> are consistently used, which is good for type safety and clarity.

src/AirInjector.php (1)

18-168: The AirInjector class is well-implemented with clear separation of concerns and robust handling of singletons and prototype instances.

src/InstanceScript.php (1)

30-179: The InstanceScript class effectively manages the script generation process, ensuring that dependencies are correctly instantiated and configured.

tests/CompilerTest.php (9)

36-49: Validate the integration of FakeFooInterface with Compiler and AirInjector.

The test method testCompile correctly checks the integration of FakeFooInterface with the Compiler and AirInjector classes by asserting the instance types. This is a good practice to ensure that the components are interacting as expected.


51-64: Check singleton behavior in DI container.

The test testCompileSingleton effectively verifies that the singleton scope is respected by the DI container, ensuring that the same instance is returned on multiple calls.


66-78: Review binding to instance with annotations.

The method testToInstance correctly tests the binding of an instance with a specific annotation. This is crucial for testing DI functionality related to annotated bindings.


80-92: Ensure provider-based dependency injection.

The testCompileProvider method properly tests the DI container's ability to handle provider-based injections, which is a key feature for flexible dependency management.


94-112: Complex DI configurations test.

The testCompileComplex method thoroughly tests complex DI configurations involving multiple bindings and scopes. This comprehensive testing is essential for ensuring the robustness of the DI system.


114-132: Test AOP integration with DI.

The testCompileAop method effectively tests the integration of AOP (Aspect-Oriented Programming) features with the DI system, which is important for ensuring that aspects are correctly applied.


134-152: Check for multiple interceptors in AOP.

The testCompileAopDubleInterceptor method correctly tests the application of multiple interceptors, ensuring that AOP behaviors are compounded as expected.


154-178: Test various types of instance bindings.

The testCompileInstnce method (note the typo in the method name) tests bindings of various types to instances, which is crucial for ensuring the flexibility and correctness of the DI container.


180-192: Test binding to null.

The testCompileNull method tests the functionality of binding interfaces to null, which is important for handling optional dependencies in the DI container.

tests/ScriptInjectorTest.php (1)

132-137: Ensure proper DI configuration in testDependInjector.

The testDependInjector method correctly sets up a DI configuration and asserts the type of an injected property, which is essential for verifying dependency injection functionality.

tests/CompilerTest.php Outdated Show resolved Hide resolved
src/CompileVisitor.php Outdated Show resolved Hide resolved
src/CompileInjector.php Outdated Show resolved Hide resolved
src/InstallBuiltinModule.php Outdated Show resolved Hide resolved
src-deprecated/AbstractInjectorContext.php Outdated Show resolved Hide resolved
src-deprecated/ScriptInjector.php Show resolved Hide resolved
src-deprecated/DiCompiler.php Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between b7d977b and 057b8e8.
Files selected for processing (1)
  • src/Compiler.php (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/Compiler.php

koriym added 27 commits May 23, 2024 02:29
Implemented the new VisitorInjector class with a comprehensive structure for managing script directories, registering loaders, and singleton patterns. Also, adjusted the related test cases in CompilerTest to use this newly added VisitorInjector class instead of the previous ScriptInjector.
The 'VisitorInjector' class was renamed to 'AirInjector' to better represent its functionality. It no longer contains the 'functions' property because it was not being used. Correspondingly, 'CompilerTest' has been updated to instantiate 'AirInjector' instead of 'VisitorInjector'.
Refactored the compile method in 'Compiler' class to include weaving aspect and saving scripts. Aspect-Oriented Programming (AOP) was introduced by adding a new 'AopCompiler' in the compile method. Accordingly, test cases in 'CompilerTest' were modified to accommodate the changes. Additionally, unused functions have been removed from 'AirInjector'.
This commit extends and refactors the CompileVisitor and Compiler. In 'Compiler.php', the container is now derived from InstallBuiltinModule. 'CompileVisitor.php' is also updated to process all scalar values and handle specific interfaces like 'InjectorInterface', 'InjectionPointInterface', and 'MethodInvocationProvider'. Corresponding test expectations have also been updated.
This commit improves the management of non-scalar instances in CompileVisitor class. Specifically, it includes support for arrays, null, and objects. Detailed tests for these new conditions have also been added.
The Compiler class has been modified to support NullObject compilation. This update comes along with the addition of comments that provide better clarity on the sequence of operations including aspect weaving and dependency compilation. The overall changes consequently improve the task execution for script dependencies.
This commit significantly cleans up and refactors the ScriptInjector class, removing surplus variables and methods for improved simplicity and maintainability. The constructor has also been simplified and the injector is now leveraging the newly
Optimized the way qualifiers are retrieved in `InjectionPoint.php`. It now relies on method annotations rather than serialized objects from the file system. This refactoring enhances performance and maintainability and eliminates external dependencies on file I/O operations. The new approach retrieves qualifier directly from method annotations, significantly improving code efficiency.
Simplified the DiCompiler class by changing instantiation and reducing the use of properties. Instances now use AirInjector instead of many separate components. This makes the class more focused and efficient. Some methods have been deprecated as
Prevent not to deleted by cs-fix.

Assertions have been added to the AirInjector class to check if the 'injectionPoint' passed in is callable. This will ensure that the 'injectionPoint', which is critical for instance creation, is always in a valid state before being used, thereby reducing potential errors.
Otherwise, the AOP of the NullObject will not be factored in.

The code has been adjusted to first compile the NullObject before weaving the Aspects in the Compiler.php file. This change in order enhances the efficiency and proper structuring of the code. The alteration could have implications for how dependencies are managed and resolved.
The changes made help in ensuring that dependencies ($injectionPoint, $prototype, $injector, $singleton) are callable before they get used in two anonymous functions. These checks can prevent potential issues which could arise when a non-callable dependency is mistakenly passed.
Simplified the CompileVisitor class by moving logic for argument addition to the InstanceScript class. Now, the container is directly passed to the InstanceScript instead of being kept in the CompileVisitor. The refactoring also introduced context handling for providers and trimmed unused exceptions.
The "install" method in InstallBuiltinModule.php is replaced with "override" to prevent potential conflicts. In the MapModule.php, the binding to the MultiBindings class is removed as it's no longer necessary. Additionally, the deleteFiles function call in the setUp method of MultiBindingTest.php is commented out.
The import statements in ScriptInjector.php, DiCompiler.php and DependencyCode.php have been cleaned up, with all unused imports removed. This simplifies the code and improves readability. Additionally, minor formatting changes have also been made for better consistency.
The commit includes changes made primarily to test cases to improve code readability, with some minor fixes. It takes away few unused imports, adds 'declare(strict_types=1)', standardizes formatting for anonymous classes in multiple files, and corrects some variable assignments. The commit also modifies some bindings to singleton scope, and adds new binding definitions in 'FakeMultiBindingsModule.php'.
Several classes have been officially deprecated in this commit. These classes have been relocated into the "src-deprecated" directory. The corresponding tests have been cleaned as well. Additionally, all affected classes have been marked as deprecated in the code comments for clarity. Minor changes in third-party dependencies in composer.lock file are included as well.
The "nikic/php-parser" package has been removed from the list of dependencies in composer.json. This change suggests that
Replaced the native PHP function file_put_contents with a custom class FilePutContents to write scripts to a file in Scripts.php. This allows for enhanced error handling and file writing flexibility.
Several test files underwent minor changes, including updating temporary file paths, adjusting assertEquals checks, syntax refinements, and tidying up some unused PHP version requirements. The modifications primarily focused on improving readability and accuracy of the tests.
The changes include updating the version of `ray/di` package from `^2.16` to `dev-visitor as 2.17` and removing `ray/aop` package. Furthermore, the `ray/di` package was moved from the "require-dev"
The versions of PHP used in the continuous integration workflow have been adjusted. Previously, it was testing against versions 7.2, 7.3, 7.4, 8.0, 8.1, and 8.2. This commit updates the testing environment
This update modifies the file lookup loop in AirInjector.php. It ensures that each script file is included only once to avoid potential issues arising from multiple inclusions.
The 'testUnbound' function was removed from DiCompilerTest.php as it was not needed. This update helps streamline the testing process by removing redundant or unnecessary tests.
An explicit requirement for PHP 8.3 has been added to the `testDependencyCompile` and
Removed the unused import statements from DiCompilerTest.php and CompilerTest.php to enhance the readability of the code and comply with clean code principles. The removed imports were "Unbound" from DiCompilerTest.php and "count" from CompilerTest.php.
Refactor code for clarity and optimization
Updated several files to improve code readability and efficiency. Refactored conditions to check for null using strict comparison. Added doc comments for better code type hinting. Removed redundant assertion checks. Adjusted PHP code sniffer configuration.
This commit encompasses the removal of the unused 'FakeFooProvider.php' test file. Additionally, annotations in 'Compiler.php' have been renamed and changes are implemented in 'CompilerTest.php' to reflect these changes. Also, refactor 'Scripts.php' class by removing redundant countable interface and its related methods. Fix indentation error in 'InstanceScript.php'.
Copy link

codecov bot commented May 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (50e063e) to head (137515f).
Report is 3 commits behind head on 1.x.

Additional details and impacted files
@@              Coverage Diff              @@
##                1.x      #112      +/-   ##
=============================================
+ Coverage     99.86%   100.00%   +0.13%     
+ Complexity      215        79     -136     
=============================================
  Files            28         9      -19     
  Lines           740       231     -509     
=============================================
- Hits            739       231     -508     
+ Misses            1         0       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 0356eeb and c940915.
Files selected for processing (8)
  • codecov.yml (1 hunks)
  • src/Compiler.php (1 hunks)
  • src/InstanceScript.php (1 hunks)
  • src/Scripts.php (1 hunks)
  • tests/CompilerTest.php (1 hunks)
  • tests/Fake/CompileVisitor/FakeBar.php (1 hunks)
  • tests/Fake/CompileVisitor/FakeBaz.php (1 hunks)
  • tests/Fake/CompileVisitor/FakeQux.php (1 hunks)
Files skipped from review due to trivial changes (1)
  • codecov.yml
Files skipped from review as they are similar to previous changes (4)
  • src/Compiler.php
  • src/InstanceScript.php
  • src/Scripts.php
  • tests/Fake/CompileVisitor/FakeBaz.php
Additional comments not posted (2)
tests/Fake/CompileVisitor/FakeBar.php (1)

5-10: Class FakeBar correctly implements its constructor with dependency injection.

Verification successful

The interface FakeFooInterface is defined in the codebase, specifically in tests/Fake/CompileVisitor/FakeFooInterface.php. This confirms that the constructor in FakeBar correctly references an existing interface.

  • tests/Fake/CompileVisitor/FakeFooInterface.php: interface FakeFooInterface
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `FakeFooInterface` is defined in the expected namespace.

# Test: Search for the interface definition. Expect: Definition found.
ast-grep --lang php --pattern $'namespace Ray\\Compiler\\CompileVisitor {
  interface FakeFooInterface {
    $$$
  }
}'

Length of output: 225



Script:

#!/bin/bash
# Description: Verify that `FakeFooInterface` is defined in the codebase.

# Test: Search for the interface definition. Expect: Definition found.
rg 'interface FakeFooInterface'

Length of output: 107

tests/CompilerTest.php (1)

24-241: The test class CompilerTest is comprehensive, covering various scenarios and correctly using dependency injection.

Verification successful

The classes Compiler, AirInjector, and Scripts are defined in the codebase, as evidenced by the search results:

  • Compiler is defined in src/Compiler.php.
  • AirInjector is defined in src/AirInjector.php.
  • Scripts is defined in src/Scripts.php.

This confirms that the necessary classes and interfaces used in CompilerTest are present in the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all classes and interfaces used in `CompilerTest` are defined in the expected namespaces.

# Test: Search for the class and interface definitions. Expect: Definitions found.
ast-grep --lang php --pattern $'namespace Ray\\Compiler {
  class Compiler {
    $$$
  }
}'
ast-grep --lang php --pattern $'namespace Ray\\Compiler {
  class AirInjector {
    $$$
  }
}'
ast-grep --lang php --pattern $'namespace Ray\\Compiler {
  class Scripts {
    $$$
  }
}'

Length of output: 598



Script:

#!/bin/bash
# Description: Verify that all classes and interfaces used in `CompilerTest` are defined in the expected namespaces.

# Test: Search for the class and interface definitions. Expect: Definitions found.
rg 'namespace Ray\\Compiler;\s*class Compiler' --files-with-matches
rg 'namespace Ray\\Compiler;\s*class AirInjector' --files-with-matches
rg 'namespace Ray\\Compiler;\s*class Scripts' --files-with-matches

Length of output: 211



Script:

#!/bin/bash
# Description: Verify that all classes and interfaces used in `CompilerTest` are defined in the expected namespaces.

# Test: Search for the class and interface definitions in all PHP files. Expect: Definitions found.
rg 'class Compiler' --glob '*.php'
rg 'class AirInjector' --glob '*.php'
rg 'class Scripts' --glob '*.php'

Length of output: 318

tests/Fake/CompileVisitor/FakeQux.php Show resolved Hide resolved
@koriym
Copy link
Member Author

koriym commented May 25, 2024

@coderabbitai review

Copy link

coderabbitai bot commented May 25, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@koriym
Copy link
Member Author

koriym commented May 25, 2024

@coderabbitai Approve ?

Copy link

coderabbitai bot commented May 25, 2024

@koriym, based on the review and the changes outlined in the PR, everything appears to be in order and aligns with the objectives of addressing the issue #78 regarding the wrong code generation for unbound interface dependencies. I will approve the changes now.

Actions Performed

Comments resolved.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between c940915 and 3f3e04c.
Files selected for processing (1)
  • composer.json (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • composer.json

The "ray/di" package version in composer.json has been updated from a dev-visitor version to a stable 2.17 version. This alteration ensures that a stable, tested version of the "ray/di" package is utilized, thereby enhancing the application's trustworthiness and stability.
The import statement for NullCache from the CachedFactoryTest has been removed as it was not being used within the test file. This makes the code cleaner and easier to maintain by reducing unnecessary dependencies.
The version of PHPStan dependency has been updated from 1.11.1 to 1.11.2 in composer.lock. Reference and timestamp have also been updated accordingly. This brings the project up-to-date with
Unused import, Ray\Di\NullCache, has been removed from CachedInjectorFactory.php file. This improves the readability of the code and maintains a cleaner codebase, minimizing extraneous or unnecessary elements.
The "doctrine/cache" requirement has been updated in composer.json file to allow for either versions 1.0 or 2.2. This change will increase the range of compatible Doctrine Cache versions and improve the package's flexibility for different project environments.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3f3e04c and 8b1a91b.
Files ignored due to path filters (1)
  • vendor-bin/tools/composer.lock is excluded by !**/*.lock
Files selected for processing (4)
  • composer.json (3 hunks)
  • src-cached-injector-factory/CachedInjectorFactory.php (1 hunks)
  • src-cached-injector-factory/NullCache.php (1 hunks)
  • tests/CachedFactoryTest.php (2 hunks)
Files skipped from review due to trivial changes (1)
  • src-cached-injector-factory/NullCache.php
Files skipped from review as they are similar to previous changes (3)
  • composer.json
  • src-cached-injector-factory/CachedInjectorFactory.php
  • tests/CachedFactoryTest.php

The version of the "ray/di" package was updated from "2.x-dev" to "^2.17". This change ensures that the project is using a more stable version of the "ray/di" dependency.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 8b1a91b and e1d156a.
Files ignored due to path filters (1)
  • vendor-bin/tools/composer.lock is excluded by !**/*.lock
Files selected for processing (1)
  • composer.json (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • composer.json

This commit upgrades various packages in composer.lock including "amphp/amp", "amphp/byte-stream", "composer/package-versions-deprecated", "composer/pcre", "composer/semver
@koriym
Copy link
Member Author

koriym commented May 27, 2024

@NaokiTsuchiya Ray.Diのリリースに対応しました。

@koriym
Copy link
Member Author

koriym commented Jun 3, 2024

@coderabbitai review

Copy link

coderabbitai bot commented Jun 3, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e1d156a and 137515f.

Files selected for processing (1)
  • composer.json (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • composer.json

@koriym
Copy link
Member Author

koriym commented Jun 10, 2024

@coderabbitai Could you approve?

Copy link

coderabbitai bot commented Jun 10, 2024

@koriym, based on the comprehensive review and the alignment of the changes with the objectives of addressing the issue #78 regarding the wrong code generation for unbound interface dependencies, I approve the changes.

Actions performed

Comments resolved.

@koriym
Copy link
Member Author

koriym commented Jun 10, 2024

@coderabbitai This PR will eliminate the problem with #78!

Copy link

coderabbitai bot commented Jun 10, 2024

Tip

For best results, initiate chat on the files or code changes.

@koriym, that's great to hear! It sounds like the changes introduced in this PR, particularly the adoption of the visitor pattern and the new code assembly method, are well-aligned to tackle the problem outlined in issue #78. I'm optimistic that this will effectively resolve the issues with unbound interface dependencies. Looking forward to seeing the positive impact of these changes in action!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong code generation for unbound interface dependencies
1 participant