[Core] Refine ExampleFactoryInterface with Templated Object Type#17753
[Core] Refine ExampleFactoryInterface with Templated Object Type#17753mpysiak merged 2 commits intoSylius:2.0from
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes enhance type safety, immutability, and documentation across many factory classes in the Sylius Core Bundle. Updates include refining PHPDoc annotations with generic type parameters, modifying method signatures to return a generic type, and enforcing constructor dependency immutability by adding the Changes
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
❌ Preview Environment deleted from BunnyshellAvailable commands:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/Sylius/Bundle/CoreBundle/Fixture/Factory/ExampleFactoryInterface.php (1)
24-24: Consider adding explicit return type to the method signature.The PHPDoc now indicates the return type as
T, but the method signature doesn't reflect this change. For consistency and to fully leverage PHP's type system, consider updating the method signature:- public function create(array $options = []); + public function create(array $options = []): T;This change would align with modern PHP practices and enforce the return type at runtime, not just for static analysis.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Sylius/Bundle/CoreBundle/Fixture/Factory/ExampleFactoryInterface.php(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Static checks / PHP 8.2, Symfony ^6.4
🔇 Additional comments (2)
src/Sylius/Bundle/CoreBundle/Fixture/Factory/ExampleFactoryInterface.php (2)
16-16: Excellent improvement to the interface's type safety.Adding the template annotation
@template T of objectmakes the interface generic, allowing implementers to specify the exact object type they'll be working with. This enhances static analysis capabilities and improves IDE autocomplete support.
20-22: Great enhancement to parameter and return type documentation.The parameter annotation clearly defines that
$optionsshould be an associative array with string keys and mixed values. The return type now properly references the template parameterTinstead of a generic object, which significantly improves type safety for implementers.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/Sylius/Bundle/CoreBundle/Fixture/Factory/CatalogPromotionExampleFactory.php (1)
144-144: Fix PHPDoc annotation typoThere's a typo in the PHPDoc comment:
@retrunshould be@return.- /** @retrun iterable<string> */ + /** @return iterable<string> */src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductExampleFactory.php (1)
297-300: Fix typo in PHPDoc annotationThere's a typo in the PHPDoc annotation:
@retrunshould be@return./** * @param array<string, mixed> $productAttributes - * @retrun ProductAttributeValueInterface[] + * @return ProductAttributeValueInterface[] */
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (26)
src/Sylius/Bundle/CoreBundle/Fixture/AbstractResourceFixture.php(1 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/AbstractExampleFactory.php(1 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/AddressExampleFactory.php(4 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/AdminUserExampleFactory.php(3 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/CatalogPromotionActionExampleFactory.php(2 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/CatalogPromotionExampleFactory.php(4 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/CatalogPromotionScopeExampleFactory.php(1 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/ChannelExampleFactory.php(2 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/CustomerGroupExampleFactory.php(1 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/OrderExampleFactory.php(1 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/PaymentMethodExampleFactory.php(2 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductAssociationExampleFactory.php(1 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductAssociationTypeExampleFactory.php(2 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductAttributeExampleFactory.php(2 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductExampleFactory.php(15 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductOptionExampleFactory.php(2 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductReviewExampleFactory.php(3 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/PromotionActionExampleFactory.php(2 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/PromotionExampleFactory.php(2 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/PromotionRuleExampleFactory.php(1 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/ShippingCategoryExampleFactory.php(2 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/ShippingMethodExampleFactory.php(3 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/ShopUserExampleFactory.php(3 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/TaxCategoryExampleFactory.php(2 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/TaxRateExampleFactory.php(3 hunks)src/Sylius/Bundle/CoreBundle/Fixture/Factory/TaxonExampleFactory.php(6 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/Sylius/Bundle/CoreBundle/Fixture/Factory/AbstractExampleFactory.php
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Static checks / PHP 8.3, Symfony ^7.1
- GitHub Check: Static checks / PHP 8.2, Symfony ^6.4
🔇 Additional comments (78)
src/Sylius/Bundle/CoreBundle/Fixture/Factory/CustomerGroupExampleFactory.php (2)
24-24: Improved type safety with generic interface annotationThe PHPDoc annotation clearly specifies that this factory implements
ExampleFactoryInterface<CustomerGroupInterface>, which enhances type safety and makes it explicit what kind of objects this factory creates.
32-32: Enhanced immutability with readonly modifierMaking the
$customerGroupFactoryproperty readonly ensures it cannot be modified after initialization, which is a good practice for dependencies injected via the constructor.src/Sylius/Bundle/CoreBundle/Fixture/AbstractResourceFixture.php (1)
28-32: Improved type safety and immutability in AbstractResourceFixtureThe changes enhance this base class in two important ways:
- The PHPDoc annotation clearly specifies that
$exampleFactoryis anExampleFactoryInterface<object>, improving type safety.- The
readonlymodifiers on both constructor parameters enforce immutability, ensuring these dependencies cannot be modified after initialization.These improvements align with modern PHP best practices and provide better guarantees about the class's behavior.
src/Sylius/Bundle/CoreBundle/Fixture/Factory/TaxCategoryExampleFactory.php (3)
24-24: Improved type safety with generic interface annotationThe PHPDoc annotation clearly specifies that this factory implements
ExampleFactoryInterface<TaxCategoryInterface>, enhancing type safety by making it explicit what kind of objects this factory creates.
32-32: Enhanced immutability with readonly modifierMaking the
$taxCategoryFactoryproperty readonly ensures it cannot be modified after initialization, which is a good practice for dependencies injected via the constructor.
57-57: Removed unused parameter from closureGood cleanup by removing the unused
Optionsparameter from the closure that generates the default name. This simplifies the code without changing its functionality.src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductAttributeExampleFactory.php (2)
26-26: Improved type safety with generic interface annotationThe PHPDoc annotation clearly specifies that this factory implements
ExampleFactoryInterface<ProductAttributeInterface>, enhancing type safety and making it explicit what kind of objects this factory creates.
38-40: Enhanced immutability with readonly modifiersMaking all constructor-injected dependencies readonly ensures they cannot be modified after initialization:
$productAttributeFactory$localeRepository$attributeTypesThis is a good practice that enforces immutability and prevents accidental modifications of these dependencies.
src/Sylius/Bundle/CoreBundle/Fixture/Factory/CatalogPromotionScopeExampleFactory.php (2)
21-21: Clear type declaration improves code comprehension.Adding the PHPDoc annotation
@implements ExampleFactoryInterface<CatalogPromotionScopeInterface>provides explicit type information about what objects this factory creates. This enhances static analysis capabilities and improves IDE support.
27-27: Good use of readonly modifier for dependency immutability.Adding the
readonlymodifier to the injected dependency ensures the property cannot be modified after initialization, which is a good practice for constructor-injected services. This prevents accidental modification and makes the code more robust.src/Sylius/Bundle/CoreBundle/Fixture/Factory/CatalogPromotionActionExampleFactory.php (3)
23-23: Clear type declaration enhances static analysis.The PHPDoc annotation
@implements ExampleFactoryInterface<CatalogPromotionActionInterface>explicitly defines what object type this factory creates. This helps static analysis tools and improves developer experience through better IDE support.
29-29: Good use of readonly modifier for dependency immutability.Adding the
readonlymodifier to the injected dependency ensures the property cannot be modified after initialization, which is a good practice for constructor-injected services.
62-62: The code correctly accesses the amount from the channel configuration.This line properly uses
$channelConfiguration['amount']to access the amount value from the current iteration variable in the foreach loop, ensuring the correct data is multiplied by 100 for the fixed discount calculation.src/Sylius/Bundle/CoreBundle/Fixture/Factory/ChannelExampleFactory.php (2)
35-35: Type parameter declaration enhances code clarity.The PHPDoc annotation
@implements ExampleFactoryInterface<ChannelInterface>explicitly defines that this factory createsChannelInterfaceobjects. This improves static analysis and IDE support.
49-54: Consistent application of readonly modifier improves immutability.Adding the
readonlymodifier to all six injected dependencies ensures they cannot be modified after initialization. This is a good practice for maintaining immutability of service dependencies and prevents accidental modifications.src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductAssociationTypeExampleFactory.php (2)
26-26: Generic type declaration enhances static analysis support.The PHPDoc annotation
@implements ExampleFactoryInterface<ProductAssociationTypeInterface>explicitly defines the return type of this factory, improving static analysis and IDE support.
38-39: Good use of readonly modifier for dependency immutability.Adding the
readonlymodifier to both injected dependencies ensures they cannot be modified after initialization, following good practices for dependency immutability.src/Sylius/Bundle/CoreBundle/Fixture/Factory/OrderExampleFactory.php (2)
44-44: Great addition of generic type parameter!Adding the
@implements ExampleFactoryInterface<OrderInterface>annotation improves type safety by explicitly specifying that this factory createsOrderInterfaceobjects. This aligns well with the PR objectives of refining theExampleFactoryInterfacewith templated object types.
47-47: Good use of typed propertiesAdding explicit type declarations for the
$optionsResolverand$fakerproperties improves code clarity and type safety. This change is consistent with modern PHP best practices.Also applies to: 49-49
src/Sylius/Bundle/CoreBundle/Fixture/Factory/ShippingCategoryExampleFactory.php (3)
24-24: Great addition of generic type parameter!Adding the
@implements ExampleFactoryInterface<ShippingCategoryInterface>annotation improves type safety by explicitly specifying that this factory createsShippingCategoryInterfaceobjects.
32-34: Good use of readonly modifier for dependencyUsing the
readonlymodifier for the$shippingCategoryFactoryproperty enhances immutability, ensuring that the dependency cannot be modified after initialization. This is a good practice for constructor-injected dependencies.
58-59: Clean closure simplificationRemoving the unused
Options $optionsparameter from the closure simplifies the code without affecting functionality. Good cleanup!src/Sylius/Bundle/CoreBundle/Fixture/Factory/PromotionActionExampleFactory.php (3)
24-24: Great addition of generic type parameter!Adding the
@implements ExampleFactoryInterface<PromotionActionInterface>annotation improves type safety by explicitly specifying that this factory createsPromotionActionInterfaceobjects.
31-32: Good use of type annotation and readonly modifierAdding the detailed PHPDoc annotation for
$promotionActionFactoryalong with thereadonlymodifier enhances both type safety and immutability.
63-63:Details
✅ Verification successful
Potential inconsistency in variable usage
The line is using
$channelConfiguration['amount']for the calculation but assigning to$configuration[$channelCode]['amount']. Consider whether both places should consistently use$channelConfigurationfor clarity and to avoid potential bugs.
🏁 Script executed:
#!/bin/bash # Check how this code is used in the application rg --type php "PromotionActionExampleFactory" -A 10 -B 10Length of output: 11775
Clarification on the Variable Usage in PromotionActionExampleFactory
After reviewing the context and how the configuration arrays are populated, it appears that the current implementation is intentional. In the typical pattern used here, the code is iterating over a set of channel configurations—where each iteration provides a
$channelCodepaired with its corresponding$channelConfiguration. The line in question:$configuration[$channelCode]['amount'] = (int) ($channelConfiguration['amount'] * 100);correctly uses
$channelConfiguration['amount'](the raw input) to perform the calculation, while assigning the transformed value to the consolidated$configurationarray keyed by$channelCode. This separation of concerns is common (and intentional) when processing configuration data, and no inconsistency was found across similar factory classes in the codebase.No changes are required at this time.
src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductOptionExampleFactory.php (2)
27-27: Great addition of generic type parameter!Adding the
@implements ExampleFactoryInterface<ProductOptionInterface>annotation improves type safety by explicitly specifying that this factory createsProductOptionInterfaceobjects.
40-43: Good use of readonly modifiers for dependenciesUsing the
readonlymodifier for all constructor parameters enhances immutability, ensuring that these dependencies cannot be modified after initialization. This is a good practice that aligns with modern PHP development standards.src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductAssociationExampleFactory.php (2)
25-25: Good Type Clarity EnhancementAdding the
@implements ExampleFactoryInterface<ProductAssociationInterface>PHPDoc annotation improves type clarity for both static analysis tools and developers.
32-34: Good Immutability EnhancementMaking the dependency properties
readonlyis a positive change that enforces immutability, preventing accidental modifications after construction and making the code more robust.src/Sylius/Bundle/CoreBundle/Fixture/Factory/PromotionRuleExampleFactory.php (2)
24-24: Good Type Clarity EnhancementAdding the
@implements ExampleFactoryInterface<PromotionRuleInterface>PHPDoc annotation improves type clarity for static analysis tools and developers.
31-34: Good Immutability and Type Safety ImprovementsThe PHPDoc annotation for the
$promotionRuleFactoryparameter adds valuable type information, and making the propertyreadonlyenhances immutability. This change aligns with modern PHP best practices.src/Sylius/Bundle/CoreBundle/Fixture/Factory/TaxRateExampleFactory.php (3)
28-28: Good Type Clarity EnhancementAdding the
@implements ExampleFactoryInterface<TaxRateInterface>PHPDoc annotation improves type clarity for static analysis tools and developers.
41-43: Good Immutability EnhancementMaking the dependency properties
readonlyenforces immutability, preventing accidental modifications after construction and making the code more robust.
73-74: Good Code SimplificationRemoving the unused
Options $optionsparameter from the closure simplifies the code. Since the parameter wasn't being used in the function body, this is a positive cleanup.src/Sylius/Bundle/CoreBundle/Fixture/Factory/PaymentMethodExampleFactory.php (2)
29-30: Good Type Safety and Interface ImplementationAdding both the PHPDoc annotation
@implements ExampleFactoryInterface<PaymentMethodInterface>and explicitly implementing the interface in the class declaration enhances type safety and makes the relationship clearer.
40-42: Good Immutability EnhancementMaking the dependency properties
readonlyenforces immutability, preventing accidental modifications after construction and making the code more robust.src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductReviewExampleFactory.php (6)
20-22: Added improved type importsThese new imports enhance type safety by explicitly importing interfaces for customers, products, and product reviews.
31-31: Enhanced type safety with generic interface implementationGood addition of the PHPDoc annotation to explicitly specify that this factory creates
ProductReviewInterfaceobjects. This improves type safety and code clarity.
38-42: Improved type hints with genericsEnhanced PHPDoc annotations with generic type parameters for repository interfaces provide better type information for static analysis tools.
44-47: Added readonly property modifiersThe addition of the
readonlymodifier to constructor parameters enhances immutability by ensuring these dependencies cannot be modified after initialization.
76-77: Simplified closure by removing unused parameterGood refactoring to remove the unused
$optionsparameter from the closure, as it wasn't being used in the implementation.
83-83: Simplified closure by removing unused parameterSimilarly to the previous comment, this is a good clean-up of unused parameters.
src/Sylius/Bundle/CoreBundle/Fixture/Factory/ShopUserExampleFactory.php (3)
28-28: Enhanced type safety with generic interface implementationThe addition of the PHPDoc annotation explicitly specifies that this factory creates
ShopUserInterfaceobjects, improving type safety and code clarity.
41-43: Added readonly property modifiersThe addition of the
readonlymodifier to constructor parameters enhances immutability by ensuring these dependencies cannot be modified after initialization.
84-84:Details
✅ Verification successful
Verify the behavior change in
customer_groupoptionThe parameter
100has been removed fromLazyOption::randomOneOrNull(). This could potentially change the behavior of how customer groups are randomly selected.
🏁 Script executed:
#!/bin/bash # Check the implementation of LazyOption::randomOneOrNull to understand if removing the parameter changes the behavior # First, let's find the implementation of LazyOption class echo "Looking for LazyOption class implementation..." rg -l "LazyOption" --type php # Then, let's look at the randomOneOrNull method echo "Examining the randomOneOrNull method..." rg "randomOneOrNull\s*\(" --type php -A 15Length of output: 8458
Review Comment Verification – No Behavior Change Detected
After reviewing the implementation of
LazyOption::randomOneOrNull, we confirm that omitting the explicit100has no impact. The method’s signature defaults the$chanceOfRandomOneparameter to 100, so the behavior remains consistent.
- The default parameter in
LazyOption::randomOneOrNullensures a 100% chance, making the explicit100redundant.- No changes to the behavior of the
customer_groupoption are observed.src/Sylius/Bundle/CoreBundle/Fixture/Factory/AddressExampleFactory.php (4)
30-30: Enhanced type safety with generic interface implementationThe addition of the PHPDoc annotation explicitly specifies that this factory creates
AddressInterfaceobjects, improving type safety and code clarity.
43-45: Added readonly property modifiersThe addition of the
readonlymodifier to constructor parameters enhances immutability by ensuring these dependencies cannot be modified after initialization.
63-63: Simplified closure by removing unused parameterThe removal of the unused
Options $optionsparameter from the closure simplifies the code without affecting functionality, as the parameter wasn't used within the function body.
133-133: Improved type documentation for method parameterAdded a PHPDoc comment to properly document the type of the
$optionsparameter asarray<string, mixed>, enhancing code clarity and type safety.src/Sylius/Bundle/CoreBundle/Fixture/Factory/CatalogPromotionExampleFactory.php (4)
22-22: Added ChannelInterface importThis import improves type safety by explicitly importing the interface for channels.
31-31: Enhanced type safety with generic interface implementationThe addition of the PHPDoc annotation explicitly specifies that this factory creates
CatalogPromotionInterfaceobjects, improving type safety and code clarity.
41-43: Improved type hints with genericsEnhanced PHPDoc annotations with generic type parameters for repository and factory interfaces provide better type information for static analysis tools.
46-50: Added readonly property modifiersThe addition of the
readonlymodifier to constructor parameters enhances immutability by ensuring these dependencies cannot be modified after initialization.src/Sylius/Bundle/CoreBundle/Fixture/Factory/AdminUserExampleFactory.php (3)
27-27: Well-typed implementation of ExampleFactoryInterface.The new generic type implementation enhances type safety by explicitly declaring that this factory creates
AdminUserInterfaceobjects. This improves static analysis and IDE support.
39-44: Great improvement with readonly properties.Converting the constructor parameters to readonly properties enforces immutability and ensures these dependencies can't be modified after initialization. This promotes safer code by preventing accidental property modifications.
99-99: Improved type documentation for options parameter.Adding the array type annotation clarifies that the
$optionsparameter is an associative array with string keys and mixed values, enhancing code readability and type checking.src/Sylius/Bundle/CoreBundle/Fixture/Factory/PromotionExampleFactory.php (4)
21-21: Explicit import of ChannelInterface.Adding this import improves code clarity and readability, especially when working with generic type annotations.
33-33: Well-typed implementation of ExampleFactoryInterface.The generic type implementation enhances type safety by explicitly declaring that this factory creates
PromotionInterfaceobjects, improving static analysis and IDE support.
41-45: Enhanced type annotations for constructor parameters.The updated PHPDoc comments with generic type information provide better clarity about the expected types of the repository and factory interfaces, improving code documentation and type safety.
49-54: Great improvement with readonly properties.Converting the constructor parameters to readonly properties enforces immutability and ensures these dependencies can't be modified after initialization. This promotes safer code and follows modern PHP practices.
src/Sylius/Bundle/CoreBundle/Fixture/Factory/ShippingMethodExampleFactory.php (3)
33-33: Well-typed implementation of ExampleFactoryInterface.The generic type implementation enhances type safety by explicitly declaring that this factory creates
ShippingMethodInterfaceobjects, improving static analysis and IDE support.
48-54: Great improvement with readonly properties.Converting the constructor parameters to readonly properties enforces immutability and ensures these dependencies can't be modified after initialization. This promotes safer code and follows modern PHP practices.
101-101: Simplified closure signature.Removing the unused Options parameter from the closure simplifies the code and makes it more maintainable. This is a nice cleanup.
src/Sylius/Bundle/CoreBundle/Fixture/Factory/TaxonExampleFactory.php (6)
28-28: Well-typed implementation of ExampleFactoryInterface.The generic type implementation enhances type safety by explicitly declaring that this factory creates
TaxonInterfaceobjects, improving static analysis and IDE support.
37-37: Enhanced type annotation for taxonRepository.The updated PHPDoc comment with generic type information provides better clarity about the expected type of the repository, improving code documentation and type safety.
41-44: Great improvement with readonly properties.Converting the constructor parameters to readonly properties enforces immutability and ensures these dependencies can't be modified after initialization. This promotes safer code and follows modern PHP practices.
57-57: Improved type documentation for options parameters.Adding the array type annotations clarifies that the
$optionsparameters are associative arrays with string keys and mixed values, enhancing code readability and type checking.Also applies to: 93-93
109-109: Simplified closure signature.Removing the unused Options parameter from the closure simplifies the code and makes it more maintainable. This is a nice cleanup.
125-125: Improved return type documentation.Adding the return type annotation for the
getLocalesmethod clarifies that it returns an iterable of strings, enhancing code readability and type checking.src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductExampleFactory.php (9)
20-20: Good refactoring of import statementsUpdating the import to use
Sylius\Component\Attribute\Model\AttributeValueInterfaceinstead of the product-specific attribute interface aligns with the overall goal of making the code more generic and less tied to specific implementations.
49-49: Great addition of generic type annotationAdding
@implements ExampleFactoryInterface<ProductInterface>explicitly defines the contract that this factory fulfills, improving type safety and code clarity. This is directly aligned with the PR objective of refining theExampleFactoryInterfacewith templated object types.
71-86: Good use of readonly properties for constructor parametersThe addition of the
readonlymodifier to all constructor parameters is a good practice that enforces immutability, making the code more robust and less prone to unintended modifications. This is a PHP 8.1+ feature that helps prevent accidental property mutations after initialization.
118-123: Good simplification of callback functionsRemoving the
Options $optionsparameter from the callbacks for 'name' and 'description' simplifies the code since these functions don't depend on other options.Also applies to: 137-142
180-180: Good addition of PHPDoc type annotationsAdding specific type annotations for array parameters (
array<string, mixed>) and return values (iterable<string>) improves code documentation and type safety, making it easier for developers to understand expected input/output types.Also applies to: 194-194, 210-210, 253-253, 274-274, 287-287
324-324: Good type clarification for parameterUsing
mixedtype for the$valueparameter inconfigureProductAttributeValueaccurately reflects that this parameter can accept values of different types, improving type clarity.
330-330: Good consistent use of interface constantsReplacing references to
ProductAttributeValueInterface::STORAGE_*withAttributeValueInterface::STORAGE_*maintains consistency with the import changes and supports the move toward more generic interfaces.Also applies to: 346-358
343-343: Good return type clarificationSpecifying
mixedas the return type forgetRandomValueForProductAttributeaccurately reflects that this method can return values of different types depending on the attribute's storage type.
104-104:Details
✅ Verification successful
Verify changes to date generation
The
dateTimeBetweencall has been modified to remove the second parameter, which changes the date range. Please verify this change won't impact any dependent code that relies on specific date range behavior.
🏁 Script executed:
#!/bin/bash # Check for usages of dateTimeBetween in tests or similar code rg -A 2 -B 2 "dateTimeBetween.*-1 week" --type phpLength of output: 644
Final Review Comment: No Impact on Date Range Behavior
The change in
ProductExampleFactory.phpnow uses a single-parameter call todateTimeBetween('-1 week'), which by default sets the upper bound to "now." Our verification with the grep search revealed that this is the only usage ofdateTimeBetweenwith a "-1 week" argument, and there are no dependent tests or code that rely on an explicitly provided second parameter. As long as the underlying Faker implementation defaults to "now" (which is expected), the behavior remains unchanged.
d7b4890 to
0d06966
Compare
58e4d13 to
dd118ae
Compare
dd118ae to
a296544
Compare
a296544 to
dc8b6c0
Compare
We have already introduced templating in Factories and Fixtures.
Summary by CodeRabbit
Refactor
Bug Fixes
Documentation
Chores
composer.jsonfiles to manage compatibility withapi-platform/jsonldpackage versions.CONFLICTS.mddocument to outline specific conflicts related to package dependencies.