🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@michalkaczmarek-bitbag
Copy link
Contributor

@michalkaczmarek-bitbag michalkaczmarek-bitbag commented Nov 25, 2025

This is a continuation of pull request #18477

Q A
Branch? 2.1
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets #18384
License MIT

Summary by CodeRabbit

  • Bug Fixes

    • Parent taxon autocomplete search is now case-insensitive for more reliable results.
  • New Features

    • Admin taxon form returns richer autocomplete results for parent selection.
    • Added UI actions to search and verify parent taxon results.
    • Support for creating taxons with explicit codes where needed.
  • Tests

    • New BDD tests covering case-insensitive parent taxon autocomplete and related scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@probot-autolabeler probot-autolabeler bot added the Admin AdminBundle related issues and PRs. label Nov 25, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

Walkthrough

Replaces 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

Cohort / File(s) Change Summary
Behat Setup Context
src/Sylius/Behat/Context/Setup/TaxonomyContext.php
Converted docblock step definitions to PHP 8 attributes (#[Given(...)]); added storeClassifiesItsProductsAsWithCode(string $taxonName, string $taxonCode): void; added private createTaxonWithCode(string $name, string $code): TaxonInterface; added return type to createTaxonInManyLanguages(array $names): TaxonInterface; added use Behat\Step\Given.
Behat UI Admin Context
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php
Added steps iSearchForParentTaxon(string $searchTerm): void (performs autocomplete search and stores results) and iShouldSeeInTheFoundResults(string $taxonName): void (asserts presence in stored autocomplete results); added use Behat\Step\When.
Behat Taxon Form Element
src/Sylius/Behat/Element/Admin/Taxon/FormElement.php, src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php
Added searchParentTaxon(string $searchTerm): array to interface and implementation; method waits for page, triggers parent autocomplete, and returns reindexed results or empty array.
Autocomplete Form Type
src/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.php
Changed search comparison to use LOWER() on fields and LOWER(:query) parameter for case-insensitive matching in autocomplete query construction.
Feature Spec
features/admin/taxonomy/managing_taxons/ui/case_insensitive_parent_search.feature
Added BDD feature verifying case-insensitive admin parent-taxons autocomplete (background setup, scenario outline for case variations, and a multi-result scenario).

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect TranslatableAutocompleteType LOWER() usage for SQL compatibility and potential performance effects.
  • Verify Behat attribute-based step discovery works with project Behat/PHP version and that existing docblock steps were fully migrated.
  • Check searchParentTaxon() return shapes and null/empty handling; ensure ManagingTaxonsContext assertions cover empty results and partial matches.
  • Review new taxon creation with explicit code for uniqueness and any side effects in fixtures.

Poem

🐰 I hopped through steps and lowered the case,
I nudged taxon codes into their place.
Autocomplete now hears my call,
finding matches—big or small.
Hooray — a rabbit's testing race! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.39% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Bugfix/fix autocomplete in admin to be case insensitive' clearly and accurately summarizes the main change: fixing autocomplete search to be case-insensitive in the admin UI.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Nov 25, 2025

❗ Preview Environment deployment failed on Bunnyshell

See: Environment Details | Pipeline Logs

Check https://github.com/Sylius/Sylius/actions/runs/19735782019 for details.

Available commands:

  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

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: 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.php uses @Given annotation (line 235), but here it's used with And following a When. While Behat allows this flexibility, consider changing the annotation to @When for semantic consistency, as this is an action step rather than a setup step.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3711798 and a910376.

📒 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: Declare strict_types=1 in all PHP files
Add type declarations for all properties, arguments, and return values in PHP
Use final for all classes, except entities and repositories in PHP
Use readonly for immutable services and value objects in PHP
Use camelCase for variables and method names in PHP
Use SCREAMING_SNAKE_CASE for 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
Sort use imports 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 in composer.json

Files:

  • src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php
  • src/Sylius/Behat/Element/Admin/Taxon/FormElement.php
  • src/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.php
  • src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php
  • src/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.php
  • src/Sylius/Behat/Element/Admin/Taxon/FormElement.php
  • src/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.php
  • src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php
  • src/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.php
  • src/Sylius/Behat/Element/Admin/Taxon/FormElement.php
  • src/Sylius/Bundle/AdminBundle/Form/Type/TranslatableAutocompleteType.php
  • src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php
  • src/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: using LOWER() 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 string parameter and array return 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 createTaxonWithCode helper. 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.

Comment on lines 234 to 240
/**
* @Given /^I search for parent taxon "([^"]*)"$/
*/
public function iSearchForParentTaxon(string $searchTerm)
{
$this->sharedStorage->set('autocompleteSearchResults', $this->formElement->searchParentTaxon($searchTerm));

return $this->formElement->searchParentTaxon($searchTerm);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Duplicate method call and missing return type.

Two issues here:

  1. searchParentTaxon() is called twice - inefficient and could cause timing issues in UI tests.
  2. Missing return type declaration per coding guidelines.
  3. The @Given annotation 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.

@Rafikooo Rafikooo linked an issue Nov 25, 2025 that may be closed by this pull request
@michalkaczmarek-bitbag michalkaczmarek-bitbag force-pushed the bugfix/fix-autocomplete-in-admin-to-be-case-insensitive branch from a910376 to a8e54a1 Compare November 26, 2025 18:03
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

♻️ Duplicate comments (1)
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (1)

234-240: Semantic annotation issue: use @When instead of @Given.

The annotation @Given doesn'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.php and 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): void

Or 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

📥 Commits

Reviewing files that changed from the base of the PR and between a910376 and a8e54a1.

📒 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: Declare strict_types=1 in all PHP files
Add type declarations for all properties, arguments, and return values in PHP
Use final for all classes, except entities and repositories in PHP
Use readonly for immutable services and value objects in PHP
Use camelCase for variables and method names in PHP
Use SCREAMING_SNAKE_CASE for 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
Sort use imports 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 in composer.json

Files:

  • src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php
  • src/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.php
  • src/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.php
  • src/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 : TaxonInterface return type improves type safety and aligns with the coding guideline to "add type declarations for all properties, arguments, and return values."

@michalkaczmarek-bitbag michalkaczmarek-bitbag force-pushed the bugfix/fix-autocomplete-in-admin-to-be-case-insensitive branch 2 times, most recently from d9809d8 to a6f578a Compare November 27, 2025 11:59
@michalkaczmarek-bitbag michalkaczmarek-bitbag force-pushed the bugfix/fix-autocomplete-in-admin-to-be-case-insensitive branch from a6f578a to 2b06c6e Compare November 27, 2025 12:08
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

🧹 Nitpick comments (3)
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (1)

498-521: Optionally assert and document autocomplete results type before iterating.

$autocompleteSearchResults is 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 $imagePath and $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): TaxonInterface and the updated createTaxonInManyLanguages(array $names): TaxonInterface are consistent with createTaxon() and correctly typed.

If you want to make createTaxonInManyLanguages’s expectations clearer to static analysers and future readers (that $names is 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): TaxonInterface

Not 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

📥 Commits

Reviewing files that changed from the base of the PR and between a6f578a and 2b06c6e.

📒 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: Declare strict_types=1 in all PHP files
Add type declarations for all properties, arguments, and return values in PHP
Use final for all classes, except entities and repositories in PHP
Use readonly for immutable services and value objects in PHP
Use camelCase for variables and method names in PHP
Use SCREAMING_SNAKE_CASE for 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
Sort use imports 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 in composer.json

Files:

  • src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php
  • src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php
  • src/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.php
  • src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php
  • src/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.php
  • src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php
  • src/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): array aligns with the concrete FormElement::searchParentTaxon implementation and follows the project’s typing rules (typed argument + array return).

src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (1)

16-18: Attribute-based When step for parent taxon search looks good.

Importing Behat\Step\When and using #[When(...)] with iSearchForParentTaxon(string $searchTerm): void is consistent with the new FormElementInterface::searchParentTaxon() API and removes the previous redundant double call.

Also applies to: 234-238

Comment on lines +17 to 18
use Behat\Step\Given;
use Doctrine\Persistence\ObjectManager;
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin AdminBundle related issues and PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Making autocomplete case-insensitive on Postgres

2 participants