-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Bugfix/fix autocomplete in admin to be case insensitive #18572
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
base: 2.1
Are you sure you want to change the base?
Bugfix/fix autocomplete in admin to be case insensitive #18572
Conversation
WalkthroughReplaces Behat docblock step annotations with PHP 8 attributes, adds explicit-code taxon creation helpers, implements admin parent-taxon autocomplete search (new Behat steps + form element), and makes autocomplete matching case-insensitive in the admin TranslatableAutocompleteType. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Tester
participant Behat as ManagingTaxonsContext
participant Form as TaxonFormElement
participant Backend as Autocomplete Backend (TranslatableAutocompleteType / Controller)
participant Storage as SharedStorage
Tester->>Behat: iSearchForParentTaxon("searchTerm")
Behat->>Form: searchParentTaxon("searchTerm")
Form->>Backend: autocomplete request (query -> LOWER(:query))
Backend-->>Form: matches array
Form-->>Behat: results array
Behat->>Storage: store 'autocompleteSearchResults'
Tester->>Behat: iShouldSeeInTheFoundResults("Expected Taxon")
Behat->>Storage: read 'autocompleteSearchResults'
Behat-->>Tester: assert presence / fail
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❗ Preview Environment deployment failed on BunnyshellSee: Environment Details | Pipeline Logs Check https://github.com/Sylius/Sylius/actions/runs/19735782019 for details. Available commands:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/Sylius/Behat/Element/Admin/Taxon/FormElement.php (1)
145-156: Add trailing comma for consistency with coding guidelines.The implementation is correct and follows existing patterns. However, per the coding guidelines, trailing commas should be used in multi-line argument lists.
$searchResults = $this->autocompleteHelper->search( $this->getDriver(), $this->getElement('parent')->getXpath(), - $searchTerm + $searchTerm, );features/admin/taxonomy/managing_taxons/ui/case_insensitive_parent_search.feature (1)
17-19: Step keyword mismatch with annotation.The step definition in
ManagingTaxonsContext.phpuses@Givenannotation (line 235), but here it's used withAndfollowing aWhen. While Behat allows this flexibility, consider changing the annotation to@Whenfor semantic consistency, as this is an action step rather than a setup step.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
features/admin/taxonomy/managing_taxons/ui/case_insensitive_parent_search.feature(1 hunks)src/Sylius/Behat/Context/Setup/TaxonomyContext.php(8 hunks)src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php(3 hunks)src/Sylius/Behat/Element/Admin/Taxon/FormElement.php(1 hunks)src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php(1 hunks)src/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.php(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.feature
📄 CodeRabbit inference engine (AGENTS.md)
Use Behat for behavior-driven scenarios
Files:
features/admin/taxonomy/managing_taxons/ui/case_insensitive_parent_search.feature
**/*.php
📄 CodeRabbit inference engine (AGENTS.md)
**/*.php: Declarestrict_types=1in all PHP files
Add type declarations for all properties, arguments, and return values in PHP
Usefinalfor all classes, except entities and repositories in PHP
Usereadonlyfor immutable services and value objects in PHP
UsecamelCasefor variables and method names in PHP
UseSCREAMING_SNAKE_CASEfor constants in PHP
Use fast returns instead of nesting logic unnecessarily in PHP
Use trailing commas in multi-line arrays and argument lists in PHP
Order array keys alphabetically where applicable in PHP
Use PHPDoc only when necessary (e.g.,@var Collection<ProductInterface>) in PHP
Group class elements in this order: constants, properties, constructor, public methods, protected methods, private methods in PHP
Group getter and setter methods for the same properties together in PHP
Suffix interfaces with Interface and traits with Trait in PHP
Sortuseimports alphabetically and group by type (classes, functions, constants) in PHP
Use modern PHP 8.2+ syntax and features
Do not use deprecated features from PHP, Symfony, or Sylius
Ensure compatibility with Symfony and PHP versions defined incomposer.json
Files:
src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.phpsrc/Sylius/Behat/Element/Admin/Taxon/FormElement.phpsrc/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.phpsrc/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.phpsrc/Sylius/Behat/Context/Setup/TaxonomyContext.php
**/*.{php,yml,yaml,xml,twig}
📄 CodeRabbit inference engine (AGENTS.md)
Use 4 spaces for indentation in all files (PHP, YAML, XML, Twig, etc.)
Files:
src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.phpsrc/Sylius/Behat/Element/Admin/Taxon/FormElement.phpsrc/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.phpsrc/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.phpsrc/Sylius/Behat/Context/Setup/TaxonomyContext.php
**/*.{php,twig}
📄 CodeRabbit inference engine (AGENTS.md)
Follow secure coding practices to prevent XSS, CSRF, injections, auth bypasses, etc.
Files:
src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.phpsrc/Sylius/Behat/Element/Admin/Taxon/FormElement.phpsrc/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.phpsrc/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.phpsrc/Sylius/Behat/Context/Setup/TaxonomyContext.php
🧬 Code graph analysis (3)
src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php (1)
src/Sylius/Behat/Element/Admin/Taxon/FormElement.php (1)
searchParentTaxon(145-156)
src/Sylius/Behat/Element/Admin/Taxon/FormElement.php (2)
src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php (1)
searchParentTaxon(49-49)src/Sylius/Behat/Service/DriverHelper.php (2)
DriverHelper(22-62)waitForPageToLoad(34-39)
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (2)
src/Sylius/Behat/Element/Admin/Taxon/FormElement.php (1)
searchParentTaxon(145-156)src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php (1)
searchParentTaxon(49-49)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: End-to-end tests (MySQL) / JS with Chromedriver, PHP 8.5, Symfony ^7.3 (test_cached), MySQL 8.4, Twig ^3.3
- GitHub Check: End-to-end tests (MySQL) / JS with Panther, PHP 8.3, Symfony ^6.4 (test_cached), MySQL 8.0, Twig ^3.3
- GitHub Check: End-to-end tests (MySQL) / JS with Panther, PHP 8.5, Symfony ^7.3 (test_cached), MySQL 8.4, Twig ^3.3
- GitHub Check: End-to-end tests (MySQL) / Non-JS, PHP 8.3, Symfony ^6.4 (test_cached), MySQL 8.0, Twig ^3.3
- GitHub Check: End-to-end tests (MySQL) / JS with Chromedriver, PHP 8.3, Symfony ^6.4 (test_cached), MySQL 8.0, Twig ^3.3
- GitHub Check: End-to-end tests (MySQL) / Non-JS, PHP 8.5, Symfony ^7.3 (test_cached), MySQL 8.4, Twig ^3.3
🔇 Additional comments (6)
src/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.php (1)
115-115: Case-insensitive LIKE implementation looks correct.The approach of applying
LOWER()to both field and query ensures case-insensitive matching. One consideration: usingLOWER()on indexed columns may prevent index utilization on some database engines, potentially impacting performance for large datasets.For consistency with the expression builder pattern, consider using:
- yield $expr->like((string) $expr->lower($field), 'LOWER(:query)'); + yield $expr->like($expr->lower($field), $expr->lower(':query'));However, the current string-based
'LOWER(:query)'approach is functionally equivalent and acceptable.src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php (1)
48-49: LGTM!Clean interface addition that follows the existing patterns. The method signature with
stringparameter andarrayreturn type is appropriate for the autocomplete search functionality.features/admin/taxonomy/managing_taxons/ui/case_insensitive_parent_search.feature (1)
1-49: Good test coverage for case-insensitive search scenarios.The feature file provides comprehensive coverage of the case-insensitive search functionality:
- Code searches: uppercase, lowercase, mixed case variations
- Name searches: with different case inputs
- Partial match verification
The scenarios are well-structured and clearly document the expected behavior.
src/Sylius/Behat/Context/Setup/TaxonomyContext.php (3)
43-47: Good modernization to PHP 8 attributes.Clean migration from docblock annotations to PHP 8
#[Given(...)]attributes, improving code readability and IDE support.
55-59: LGTM!The new step definition follows the existing patterns and properly delegates to the new
createTaxonWithCodehelper. This enables test scenarios to create taxons with specific codes for case-sensitivity testing.
153-162: LGTM!The helper method correctly mirrors
createTaxon()but accepts an explicit code parameter instead of generating one. Good code reuse pattern.
| /** | ||
| * @Given /^I search for parent taxon "([^"]*)"$/ | ||
| */ | ||
| public function iSearchForParentTaxon(string $searchTerm) | ||
| { | ||
| $this->sharedStorage->set('autocompleteSearchResults', $this->formElement->searchParentTaxon($searchTerm)); | ||
|
|
||
| return $this->formElement->searchParentTaxon($searchTerm); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate method call and missing return type.
Two issues here:
searchParentTaxon()is called twice - inefficient and could cause timing issues in UI tests.- Missing return type declaration per coding guidelines.
- The
@Givenannotation doesn't match the semantic intent (this is an action, not setup).
/**
- * @Given /^I search for parent taxon "([^"]*)"$/
+ * @When /^I search for parent taxon "([^"]*)"$/
*/
- public function iSearchForParentTaxon(string $searchTerm)
+ public function iSearchForParentTaxon(string $searchTerm): array
{
- $this->sharedStorage->set('autocompleteSearchResults', $this->formElement->searchParentTaxon($searchTerm));
+ $results = $this->formElement->searchParentTaxon($searchTerm);
+ $this->sharedStorage->set('autocompleteSearchResults', $results);
- return $this->formElement->searchParentTaxon($searchTerm);
+ return $results;
}🤖 Prompt for AI Agents
In src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php around lines 234
to 242, the method calls searchParentTaxon() twice and lacks a return type and
uses an incorrect @Given annotation; fix by calling searchParentTaxon() once
into a local variable, set that value into sharedStorage, return the same
variable, add the appropriate return type declaration (e.g. : array or the
actual type returned by searchParentTaxon), and change the annotation from
@Given to @When to reflect an action rather than setup.
a910376 to
a8e54a1
Compare
There was a problem hiding this 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
♻️ Duplicate comments (1)
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (1)
234-240: Semantic annotation issue: use@Wheninstead of@Given.The annotation
@Givendoesn't match the semantic intent. "I search for parent taxon" describes an action the user performs, not a precondition or setup state. Per BDD conventions, this should be@When.Additionally, for consistency with
TaxonomyContext.phpand modern PHP 8.2+ syntax, consider using the PHP 8 attribute#[When('...')]instead of docblock annotations.Apply this diff to fix the semantic issue:
/** - * @Given /^I search for parent taxon "([^"]*)"$/ + * @When /^I search for parent taxon "([^"]*)"$/ */ public function iSearchForParentTaxon(string $searchTerm): voidOr modernize to PHP 8 attributes:
- /** - * @Given /^I search for parent taxon "([^"]*)"$/ - */ + #[When('/^I search for parent taxon "([^"]*)"$/')] public function iSearchForParentTaxon(string $searchTerm): void
🧹 Nitpick comments (1)
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (1)
17-17: Unused import tied to annotation style inconsistency.The
use Behat\Step\When;import is unused because the code still uses docblock annotations (@Given,@When) instead of PHP 8 attributes (#[When(...)]).For consistency with
TaxonomyContext.php(which uses PHP 8 attributes throughout) and the coding guideline to "use modern PHP 8.2+ syntax and features," consider converting the new step definitions to use PHP 8 attributes.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
features/admin/taxonomy/managing_taxons/ui/case_insensitive_parent_search.feature(1 hunks)src/Sylius/Behat/Context/Setup/TaxonomyContext.php(8 hunks)src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php(3 hunks)src/Sylius/Behat/Element/Admin/Taxon/FormElement.php(1 hunks)src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php(1 hunks)src/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.php(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- src/Sylius/Behat/Element/Admin/Taxon/FormElement.php
- features/admin/taxonomy/managing_taxons/ui/case_insensitive_parent_search.feature
- src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php
- src/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.php
🧰 Additional context used
📓 Path-based instructions (3)
**/*.php
📄 CodeRabbit inference engine (AGENTS.md)
**/*.php: Declarestrict_types=1in all PHP files
Add type declarations for all properties, arguments, and return values in PHP
Usefinalfor all classes, except entities and repositories in PHP
Usereadonlyfor immutable services and value objects in PHP
UsecamelCasefor variables and method names in PHP
UseSCREAMING_SNAKE_CASEfor constants in PHP
Use fast returns instead of nesting logic unnecessarily in PHP
Use trailing commas in multi-line arrays and argument lists in PHP
Order array keys alphabetically where applicable in PHP
Use PHPDoc only when necessary (e.g.,@var Collection<ProductInterface>) in PHP
Group class elements in this order: constants, properties, constructor, public methods, protected methods, private methods in PHP
Group getter and setter methods for the same properties together in PHP
Suffix interfaces with Interface and traits with Trait in PHP
Sortuseimports alphabetically and group by type (classes, functions, constants) in PHP
Use modern PHP 8.2+ syntax and features
Do not use deprecated features from PHP, Symfony, or Sylius
Ensure compatibility with Symfony and PHP versions defined incomposer.json
Files:
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.phpsrc/Sylius/Behat/Context/Setup/TaxonomyContext.php
**/*.{php,yml,yaml,xml,twig}
📄 CodeRabbit inference engine (AGENTS.md)
Use 4 spaces for indentation in all files (PHP, YAML, XML, Twig, etc.)
Files:
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.phpsrc/Sylius/Behat/Context/Setup/TaxonomyContext.php
**/*.{php,twig}
📄 CodeRabbit inference engine (AGENTS.md)
Follow secure coding practices to prevent XSS, CSRF, injections, auth bypasses, etc.
Files:
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.phpsrc/Sylius/Behat/Context/Setup/TaxonomyContext.php
🧬 Code graph analysis (1)
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (2)
src/Sylius/Behat/Element/Admin/Taxon/FormElement.php (1)
searchParentTaxon(145-156)src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php (1)
searchParentTaxon(49-49)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Static checks / PHP 8.3, Symfony ^6.4
🔇 Additional comments (4)
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (1)
500-514: LGTM!The assertion logic is well-implemented with:
- Proper retrieval from shared storage
- Clear assertion using
in_array()with strict comparison- Helpful error message for debugging
src/Sylius/Behat/Context/Setup/TaxonomyContext.php (3)
43-47: Excellent modernization with PHP 8 attributes.The consistent conversion from docblock annotations to PHP 8 attributes (
#[Given(...)]) improves code maintainability and aligns with modern PHP 8.2+ syntax requirements.Also applies to: 61-61, 72-72, 95-95, 112-115, 126-126, 134-134
55-59: LGTM! Well-structured explicit code support.The new step definition and helper method are correctly implemented:
- Proper return types (
: void,: TaxonInterface)- Clean separation of concerns (public step delegates to private helper)
- Explicit code assignment without auto-generation as intended
Also applies to: 153-162
173-173: Good addition of return type declaration.Adding the
: TaxonInterfacereturn type improves type safety and aligns with the coding guideline to "add type declarations for all properties, arguments, and return values."
d9809d8 to
a6f578a
Compare
a6f578a to
2b06c6e
Compare
There was a problem hiding this 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
🧹 Nitpick comments (3)
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (1)
498-521: Optionally assert and document autocomplete results type before iterating.
$autocompleteSearchResultsis assumed to be an array from shared storage; asserting that improves failure messages if the search step wasn’t executed or returns an unexpected value.You could tighten this with:
public function iShouldSeeInTheFoundResults(string $taxonName): void { - $autocompleteSearchResults = $this->sharedStorage->get('autocompleteSearchResults'); + $autocompleteSearchResults = $this->sharedStorage->get('autocompleteSearchResults'); + + Assert::isArray($autocompleteSearchResults); $found = false; foreach ($autocompleteSearchResults as $result) { if (str_contains($result, $taxonName)) { $found = true;Optionally, add a PHPDoc like
/** @var string[] $autocompleteSearchResults */if you want static analysis to know the element type.src/Sylius/Behat/Context/Setup/TaxonomyContext.php (2)
61-93: While migrating to attributes, consider adding missing scalar parameter and return types.Since you’re already touching these step definitions, it’s a good time to align them with the “all params/returns typed” rule; this remains a style/maintainability improvement, not a functional bug.
In particular:
theStoreHasTaxonomyNamedInAndIn(...)has untyped parameters and no return type.theTaxonHasAnImageWithType(...)lacks scalar types for$imagePathand$imageType, and also no return type.For example:
- #[Given('/^the store has taxonomy named "([^"]+)" in ("[^"]+" locale) and "([^"]+)" in ("[^"]+" locale)$/')] - public function theStoreHasTaxonomyNamedInAndIn($firstName, $firstLocale, $secondName, $secondLocale) + #[Given('/^the store has taxonomy named "([^"]+)" in ("[^"]+" locale) and "([^"]+)" in ("[^"]+" locale)$/')] + public function theStoreHasTaxonomyNamedInAndIn( + string $firstName, + string $firstLocale, + string $secondName, + string $secondLocale, + ): void { $translationMap = [ $firstLocale => $firstName, $secondLocale => $secondName, ]; @@ - #[Given('/^the ("[^"]+" taxon)(?:| also) has an image "([^"]+)" with "([^"]+)" type$/')] - public function theTaxonHasAnImageWithType(TaxonInterface $taxon, $imagePath, $imageType) + #[Given('/^the ("[^"]+" taxon)(?:| also) has an image "([^"]+)" with "([^"]+)" type$/')] + public function theTaxonHasAnImageWithType(TaxonInterface $taxon, string $imagePath, string $imageType): void {This keeps Behat’s step matching intact while improving static analysis and readability.
Also applies to: 95-140
153-162: New taxon helpers are consistent; optionally document the multilingual names map.
createTaxonWithCode(string $name, string $code): TaxonInterfaceand the updatedcreateTaxonInManyLanguages(array $names): TaxonInterfaceare consistent withcreateTaxon()and correctly typed.If you want to make
createTaxonInManyLanguages’s expectations clearer to static analysers and future readers (that$namesis keyed by locale codes and must contain'en_US'), you could add a brief PHPDoc:/** * @param array<string,string> $names keyed by locale code, must include 'en_US' */ private function createTaxonInManyLanguages(array $names): TaxonInterfaceNot required for functionality, but it makes the contract explicit.
Also applies to: 173-189
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
features/admin/taxonomy/managing_taxons/ui/case_insensitive_parent_search.feature(1 hunks)src/Sylius/Behat/Context/Setup/TaxonomyContext.php(8 hunks)src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php(3 hunks)src/Sylius/Behat/Element/Admin/Taxon/FormElement.php(1 hunks)src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php(1 hunks)src/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.php(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- src/Sylius/Behat/Element/Admin/Taxon/FormElement.php
- features/admin/taxonomy/managing_taxons/ui/case_insensitive_parent_search.feature
- src/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.php
🧰 Additional context used
📓 Path-based instructions (3)
**/*.php
📄 CodeRabbit inference engine (AGENTS.md)
**/*.php: Declarestrict_types=1in all PHP files
Add type declarations for all properties, arguments, and return values in PHP
Usefinalfor all classes, except entities and repositories in PHP
Usereadonlyfor immutable services and value objects in PHP
UsecamelCasefor variables and method names in PHP
UseSCREAMING_SNAKE_CASEfor constants in PHP
Use fast returns instead of nesting logic unnecessarily in PHP
Use trailing commas in multi-line arrays and argument lists in PHP
Order array keys alphabetically where applicable in PHP
Use PHPDoc only when necessary (e.g.,@var Collection<ProductInterface>) in PHP
Group class elements in this order: constants, properties, constructor, public methods, protected methods, private methods in PHP
Group getter and setter methods for the same properties together in PHP
Suffix interfaces with Interface and traits with Trait in PHP
Sortuseimports alphabetically and group by type (classes, functions, constants) in PHP
Use modern PHP 8.2+ syntax and features
Do not use deprecated features from PHP, Symfony, or Sylius
Ensure compatibility with Symfony and PHP versions defined incomposer.json
Files:
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.phpsrc/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.phpsrc/Sylius/Behat/Context/Setup/TaxonomyContext.php
**/*.{php,yml,yaml,xml,twig}
📄 CodeRabbit inference engine (AGENTS.md)
Use 4 spaces for indentation in all files (PHP, YAML, XML, Twig, etc.)
Files:
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.phpsrc/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.phpsrc/Sylius/Behat/Context/Setup/TaxonomyContext.php
**/*.{php,twig}
📄 CodeRabbit inference engine (AGENTS.md)
Follow secure coding practices to prevent XSS, CSRF, injections, auth bypasses, etc.
Files:
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.phpsrc/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.phpsrc/Sylius/Behat/Context/Setup/TaxonomyContext.php
🧬 Code graph analysis (2)
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (2)
src/Sylius/Behat/Element/Admin/Taxon/FormElement.php (1)
searchParentTaxon(145-156)src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php (1)
searchParentTaxon(49-49)
src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php (1)
src/Sylius/Behat/Element/Admin/Taxon/FormElement.php (1)
searchParentTaxon(145-156)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Static checks / PHP 8.3, Symfony ^6.4
- GitHub Check: Static checks / PHP 8.5, Symfony ^7.3
🔇 Additional comments (2)
src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php (1)
48-49: New interface method is correctly typed and consistent.
searchParentTaxon(string $searchTerm): arrayaligns with the concreteFormElement::searchParentTaxonimplementation and follows the project’s typing rules (typed argument + array return).src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (1)
16-18: Attribute-basedWhenstep for parent taxon search looks good.Importing
Behat\Step\Whenand using#[When(...)]withiSearchForParentTaxon(string $searchTerm): voidis consistent with the newFormElementInterface::searchParentTaxon()API and removes the previous redundant double call.Also applies to: 234-238
| use Behat\Step\Given; | ||
| use Doctrine\Persistence\ObjectManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Add parameter and return types to storeClassifiesItsProductsAs.
This method currently violates the “types everywhere” guideline by omitting both the variadic parameter type and the return type.
You can keep Behat compatibility and satisfy the guideline with:
- #[Given('the store has :firstTaxonName taxonomy')]
- #[Given('the store classifies its products as :firstTaxonName')]
- #[Given('the store classifies its products as :firstTaxonName and :secondTaxonName')]
- #[Given('the store classifies its products as :firstTaxonName, :secondTaxonName and :thirdTaxonName')]
- #[Given('the store classifies its products as :firstTaxonName, :secondTaxonName, :thirdTaxonName and :fourthTaxonName')]
- public function storeClassifiesItsProductsAs(...$taxonsNames)
+ #[Given('the store has :firstTaxonName taxonomy')]
+ #[Given('the store classifies its products as :firstTaxonName')]
+ #[Given('the store classifies its products as :firstTaxonName and :secondTaxonName')]
+ #[Given('the store classifies its products as :firstTaxonName, :secondTaxonName and :thirdTaxonName')]
+ #[Given('the store classifies its products as :firstTaxonName, :secondTaxonName, :thirdTaxonName and :fourthTaxonName')]
+ public function storeClassifiesItsProductsAs(string ...$taxonsNames): void
{
foreach ($taxonsNames as $taxonName) {
$this->taxonRepository->add($this->createTaxon($taxonName));
}
}The new storeClassifiesItsProductsAsWithCode() helper is already correctly typed and looks good.
Also applies to: 43-59
🤖 Prompt for AI Agents
In src/Sylius/Behat/Context/Setup/TaxonomyContext.php around lines 17-18 (and
also for the method spanning lines 43-59), the method
storeClassifiesItsProductsAs is missing its variadic parameter type and a return
type; update its signature to declare the variadic parameter type (e.g. string
...$categoryNames) and an explicit return type (void) so it conforms to the
"types everywhere" guideline while staying Behat-compatible; ensure any callers
still match and adjust docblocks if present.
This is a continuation of pull request #18477
Summary by CodeRabbit
Bug Fixes
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.