diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml
index afb4e2b0..5e127b8e 100644
--- a/.github/workflows/recipe.yaml
+++ b/.github/workflows/recipe.yaml
@@ -9,46 +9,54 @@ jobs:
recipe:
- name: Flex recipe (PHP ${{ matrix.php }}, Sylius ${{ matrix.sylius }})
-
runs-on: ubuntu-latest
+
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1', '8.2']
- sylius: ['~1.11.0', '~1.12.0']
- include:
- - php: '8.1'
- sylius: '~1.12.0'
- sylius_paypal: '~1.5.0'
- - php: '8.2'
- sylius: '~1.12.0'
- sylius_paypal: '~1.5.0'
-
+ sylius: ["~1.11.0", "~1.12.0", "~1.13.0"]
+ exclude:
+ - php: '8.2'
+ sylius: '~1.11.0'
+ - php: '8.0'
+ sylius: '~1.12.0'
+ - php: '8.0'
+ sylius: '~1.13.0'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
+ extensions: gd, intl, json
+ ini-values: date.timezone=UTC
+ tools: symfony-cli
- name: Set project php-version
run: |
- echo "${{ matrix.php }}" > .php-version
+ echo ${{ matrix.php }} > .php-version
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
path: plugin
- - run: mkdir -p /home/runner/{.composer/cache,.config/composer}
+ - name: Determine composer cache directory
+ id: composer-cache-directory
+ working-directory: plugin
+ run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
- - uses: actions/cache@v1
+ - name: Cache dependencies installed with composer
+ uses: actions/cache@v3
id: cache-composer
with:
- path: /home/runner/.composer/cache
- key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ github.sha }}
+ path: ${{ steps.composer-cache-directory.outputs.directory }}
+ key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ hashFiles('**/composer.json') }}
restore-keys: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-
+ - name: Ensure that composer cache directory exists
+ run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }}
+
- name: Composer Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}
@@ -62,14 +70,6 @@ jobs:
run: |
composer require --no-install --no-scripts --no-progress sylius/sylius="${{ matrix.sylius }}"
- # Fix Paypal 1.5 on Sylius 1.12 and PHP 8.1
- - name: Make sure to install the required version of Sylius Paypal Plugin
- if: ${{ matrix.sylius_paypal }}
- working-directory: ./sylius
- run: |
- composer require --no-install --no-scripts --no-progress sylius/paypal-plugin="${{ matrix.sylius_paypal }}" # @see https://github.com/Sylius/PayPalPlugin/issues/295
-
-
- name: Setup some requirements
working-directory: ./sylius
run: |
@@ -79,8 +79,10 @@ jobs:
composer config --no-plugins --unset platform.php
composer config --no-plugins extra.symfony.docker false
composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]'
+ composer config repositories.plugin '{"type": "path", "url": "../plugin/"}'
- name: Require plugin & install all dependencies
working-directory: ./sylius
run: |
+ composer require --no-progress --no-interaction nikic/php-parser="^4.0"
composer require monsieurbiz/sylius-search-plugin="*@dev"
diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml
index 184a4043..c100cfa1 100644
--- a/.github/workflows/security.yaml
+++ b/.github/workflows/security.yaml
@@ -3,48 +3,51 @@ name: Security
on:
push:
pull_request:
- schedule:
- - cron: '0 0 * * 0'
jobs:
security:
- name: Security check (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
- php: [ '8.0', '8.1', '8.2' ]
+ php: ['8.1', '8.2']
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
+ extensions: gd, intl, json
- name: Set project php-version
run: |
echo "${{ matrix.php }}" > .php-version
- - uses: actions/cache@v1
+ - name: Determine composer cache directory
+ id: composer-cache-directory
+ run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
+
+ - name: Cache dependencies installed with composer
+ uses: actions/cache@v3
id: cache-composer
with:
- path: /home/runner/.composer/cache
+ path: ${{ steps.composer-cache-directory.outputs.directory }}
key: composer2-php:${{ matrix.php }}-${{ github.sha }}
restore-keys: composer2-php:${{ matrix.php }}-
- - run: mkdir -p /home/runner/{.composer/cache,.config/composer}
+ - name: Ensure that composer cache directory exists
+ run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }}
- name: Composer Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}
- - uses: actions/checkout@v2
-
- name: Install PHP dependencies
run: composer update --prefer-dist
- - uses: symfonycorp/security-checker-action@v3
+ - uses: symfonycorp/security-checker-action@v4
+
diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index 9f1c9a9c..877ce6a6 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -8,13 +8,13 @@ on:
jobs:
php:
- name: Quality tests (PHP ${{ matrix.php }})
+
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
- php: [ '8.0', '8.1', '8.2' ]
+ php: ['8.1', '8.2']
env:
SYMFONY_ARGS: --no-tls
@@ -25,30 +25,33 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
- node-version: '16'
-
+ node-version: '14'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
+ extensions: gd, intl, json
+ ini-values: date.timezone=UTC
+ tools: symfony-cli
- name: Set project php-version
run: |
echo "${{ matrix.php }}" > .php-version
- - name: Install symfony CLI
- run: |
- curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash
- sudo apt install symfony-cli
+ - name: Determine composer cache directory
+ id: composer-cache-directory
+ run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
- - uses: actions/cache@v1
+ - name: Cache dependencies installed with composer
+ uses: actions/cache@v3
id: cache-composer
with:
- path: /home/runner/.composer/cache
+ path: ${{ steps.composer-cache-directory.outputs.directory }}
key: composer2-php:${{ matrix.php }}-${{ github.sha }}
restore-keys: composer2-php:${{ matrix.php }}-
- - run: mkdir -p /home/runner/{.composer/cache,.config/composer}
+ - name: Ensure that composer cache directory exists
+ run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }}
- name: Composer Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index a0b260d9..4a342573 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -49,10 +49,8 @@
'binary_operator_spaces' => true,
'blank_line_after_opening_tag' => true,
'blank_line_after_namespace' => true,
+ 'blank_lines_before_namespace' => true,
'blank_line_before_statement' => true,
- 'braces' => [
- 'allow_single_line_closure' => true,
- ],
'cast_spaces' => true,
'class_attributes_separation' => true,
'class_definition' => [
@@ -62,7 +60,7 @@
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'comment_to_phpdoc' => true,
- 'compact_nullable_typehint' => true,
+ 'compact_nullable_type_declaration' => true,
'concat_space' => [
'spacing' => 'one',
],
@@ -88,8 +86,12 @@
'fully_qualified_strict_types' => true,
'function_declaration' => true,
'function_to_constant' => true,
- 'function_typehint_space' => true,
'general_phpdoc_tag_rename' => true,
+ 'global_namespace_import' => [
+ 'import_classes' => true,
+ 'import_constants' => false,
+ 'import_functions' => false,
+ ],
'header_comment' => [
'header' => $header,
'location' => 'after_open',
@@ -110,6 +112,7 @@
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'method_argument_space' => true,
+ 'modernize_strpos' => false,
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => [
@@ -117,7 +120,7 @@
],
'native_constant_invocation' => true,
'native_function_casing' => true,
- 'new_with_braces' => true,
+ 'new_with_parentheses' => true,
'no_alias_functions' => true,
'no_alternative_syntax' => true,
'no_blank_lines_after_class_opening' => true,
@@ -156,27 +159,27 @@
'no_short_bool_cast' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
- 'no_spaces_inside_parenthesis' => true,
+ 'spaces_inside_parentheses' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
],
'no_unset_cast' => true,
'no_unneeded_control_parentheses' => true,
- 'no_unneeded_curly_braces' => true,
+ 'no_unneeded_braces' => true,
'no_unneeded_final_method' => true,
'no_unset_on_property' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
- 'no_trailing_comma_in_list_call' => true,
- 'no_trailing_comma_in_singleline_array' => true,
+ 'no_trailing_comma_in_singleline' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'non_printable_character' => true,
'normalize_index_brace' => true,
+ 'nullable_type_declaration_for_default_null_value' => false,
'object_operator_without_whitespace' => true,
'ordered_imports' => [
'imports_order' => [
@@ -211,7 +214,9 @@
'phpdoc_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
- 'phpdoc_separation' => true,
+ 'phpdoc_separation' => ['groups' => [
+ ['ORM\\*'], ['Assert\\*'],
+ ]],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_tag_type' => true,
'phpdoc_to_comment' => false,
@@ -231,7 +236,6 @@
'self_accessor' => true,
'short_scalar_cast' => true,
'single_blank_line_at_eof' => true,
- 'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
@@ -248,6 +252,7 @@
'elements' => ['arrays'],
],
'trim_array_spaces' => true,
+ 'type_declaration_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => [
diff --git a/.php-version.dist b/.php-version.dist
index b8eb0263..2983cad0 100644
--- a/.php-version.dist
+++ b/.php-version.dist
@@ -1 +1 @@
-8.1
+8.2
diff --git a/Makefile b/Makefile
index 82231675..3e29f074 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,7 @@
.DEFAULT_GOAL := help
SHELL=/bin/bash
APP_DIR=tests/Application
-SYLIUS_VERSION=1.12.0
-SYLIUS_PAYPAL_VERSION=1.5.0
+SYLIUS_VERSION=1.13.0
SYMFONY=cd ${APP_DIR} && symfony
COMPOSER=symfony composer
CONSOLE=${SYMFONY} console
@@ -26,8 +25,9 @@ down: server.stop docker.down ## Down the project (removes docker containers, st
reset: ## Stop docker and remove dependencies
${MAKE} docker.down || true
+ rm -rf ${APP_DIR}/node_modules ${APP_DIR}/yarn.lock
rm -rf ${APP_DIR}
- rm -rf vendor composer.lock yarn.lock node_modules
+ rm -rf vendor composer.lock
.PHONY: reset
dependencies: composer.lock node_modules ## Setup the dependencies
@@ -66,27 +66,28 @@ ${APP_DIR}:
(${COMPOSER} create-project --no-interaction --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard="~${SYLIUS_VERSION}" ${APP_DIR})
setup_application:
+ rm -f ${APP_DIR}/yarn.lock
(cd ${APP_DIR} && ${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}')
(cd ${APP_DIR} && ${COMPOSER} config extra.symfony.allow-contrib true)
(cd ${APP_DIR} && ${COMPOSER} config minimum-stability dev)
(cd ${APP_DIR} && ${COMPOSER} config --no-plugins allow-plugins true)
+ (cd ${APP_DIR} && ${COMPOSER} config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]')
(cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress sylius/sylius="~${SYLIUS_VERSION}") # Make sure to install the required version of sylius because the sylius-standard has a soft constraint
- (cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress sylius/paypal-plugin="~${SYLIUS_PAYPAL_VERSION}") # @see https://github.com/Sylius/PayPalPlugin/issues/295
- @if [ ${SYLIUS_VERSION} == '1.11.0' ]; then\
- (cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress php-http/message-factory)\
- fi
- $(MAKE) ${APP_DIR}/.php-version ${APP_DIR}/php.ini
+ $(MAKE) ${APP_DIR}/.php-version
+ $(MAKE) ${APP_DIR}/php.ini
(cd ${APP_DIR} && ${COMPOSER} install --no-interaction)
$(MAKE) apply_dist
+ (cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress nikic/php-parser="^4.0") # Required by jane-php/automapper
(cd ${APP_DIR} && ${COMPOSER} require --no-progress --no-interaction monsieurbiz/${PLUGIN_NAME}="*@dev")
git restore dist/docker-compose.override.yaml # Restore dist file to prevent modification by flex recipes (symfony/mailer)
rm -rf ${APP_DIR}/var/cache
+
${APP_DIR}/docker-compose.yaml:
rm -f ${APP_DIR}/docker-compose.yml
rm -f ${APP_DIR}/docker-compose.yaml
- rm -f ${APP_DIR}/compose.yml
- rm -f ${APP_DIR}/compose.override.dist.yml
+ rm -f ${APP_DIR}/compose.yml # Remove Sylius file about Docker
+ rm -f ${APP_DIR}/compose.override.dist.yml # Remove Sylius file about Docker
ln -s ../../docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml
.PHONY: ${APP_DIR}/docker-compose.yaml
@@ -141,7 +142,7 @@ test.container: ## Lint the symfony container
${CONSOLE} lint:container
test.yaml: ## Lint the symfony Yaml files
- ${CONSOLE} lint:yaml --parse-tags ../../src/Resources/config
+ ${CONSOLE} lint:yaml ../../src/Resources/config --parse-tags
test.schema: ## Validate MySQL Schema
${CONSOLE} doctrine:schema:validate
diff --git a/README.md b/README.md
index de69883a..c6367753 100644
--- a/README.md
+++ b/README.md
@@ -3,17 +3,35 @@
Search
[![Search Plugin license](https://img.shields.io/github/license/monsieurbiz/SyliusSearchPlugin?public)](https://github.com/monsieurbiz/SyliusSearchPlugin/blob/master/LICENSE.txt)
-[![Recipe](https://github.com/monsieurbiz/SyliusSearchPlugin/actions/workflows/recipe.yaml/badge.svg?branch=master&event=push)](https://github.com/monsieurbiz/SyliusSearchPlugin/actions/workflows/recipe.yaml)
-[![Tests](https://github.com/monsieurbiz/SyliusSearchPlugin/actions/workflows/tests.yaml/badge.svg?branch=master&event=push)](https://github.com/monsieurbiz/SyliusSearchPlugin/actions/workflows/tests.yaml)
-[![Security](https://github.com/monsieurbiz/SyliusSearchPlugin/actions/workflows/security.yaml/badge.svg?branch=master&event=push)](https://github.com/monsieurbiz/SyliusSearchPlugin/actions/workflows/security.yaml)
+[![Tests Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusSearchPlugin/tests.yaml?branch=master&logo=github)](https://github.com/monsieurbiz/SyliusCmsPagePlugin/actions?query=workflow%3ATests)
+[![Recipe Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusSearchPlugin/recipe.yaml?branch=master&label=recipes&logo=github)](https://github.com/monsieurbiz/SyliusCmsPagePlugin/actions?query=workflow%3ASecurity)
+[![Security Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusSearchPlugin/security.yaml?branch=master&label=security&logo=github)](https://github.com/monsieurbiz/SyliusCmsPagePlugin/actions?query=workflow%3ASecurity)
+
A search plugin for Sylius using [Elastically](https://github.com/jolicode/elastically) and [Jane](https://github.com/janephp/janephp).
+## Compatibility
+
+| Sylius Version | PHP Version |
+|---|---|
+| 1.11 | 8.0 - 8.1 |
+| 1.12 | 8.1 - 8.2 |
+| 1.13 | 8.1 - 8.2 |
+
## Installation
-Require the plugin :
+If you want to use our recipes, you can configure your composer.json by running:
+
+```bash
+composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]'
```
-composer require monsieurbiz/sylius-search-plugin="^2"
+
+This is the last version using `jane-php/automapper`, which requires `nikic/php-parser="^4.0"`.
+The next version will use `jolicode/automapper`, which is compatible with `nikic/php-parser="^5.0"`.
+
+```bash
+composer require --no-progress --no-interaction nikic/php-parser="^4.0"
+composer require monsieurbiz/sylius-search-plugin
```
If you are using Symfony Flex, the recipe will automatically do some actions.
@@ -84,6 +102,8 @@ use Sylius\Component\Product\Model\ProductAttribute as BaseProductAttribute;
* @ORM\Entity
* @ORM\Table(name="sylius_product_attribute")
*/
+#[ORM\Entity]
+#[ORM\Table(name: 'sylius_product_attribute')]
-class ProductAttribute extends BaseProductAttribute
+class ProductAttribute extends BaseProductAttribute implements SearchableInterface
{
diff --git a/composer.json b/composer.json
index a8125fac..398efe2e 100644
--- a/composer.json
+++ b/composer.json
@@ -5,49 +5,23 @@
"description": "A search plugin using Elasticsearch for Sylius.",
"license": "MIT",
"require": {
- "php": "~7.4|~8.0",
"babdev/pagerfanta-bundle": "^2.5 || ^3.0",
"jacquesbh/eater": "^2.0",
"jane-php/automapper-bundle": "^7.1",
"jolicode/elastically": "^1.4.0",
- "monsieurbiz/sylius-settings-plugin": "^1.0",
- "sylius/sylius": ">=1.9 <1.13",
+ "monsieurbiz/sylius-settings-plugin": "^1.2",
+ "php": "^8.0",
+ "sylius/sylius": ">=1.11 <1.14",
"symfony/messenger": "^4.4 || ^5.2 || ^6.0"
},
"require-dev": {
- "behat/behat": "^3.6.1",
- "behat/mink-selenium2-driver": "^1.4",
- "dmore/behat-chrome-extension": "^1.3",
- "dmore/chrome-mink-driver": "^2.7",
- "doctrine/data-fixtures": "^1.4",
- "ergebnis/composer-normalize": "^2.5",
- "friends-of-behat/mink": "^1.8",
- "friends-of-behat/mink-browserkit-driver": "^1.4",
- "friends-of-behat/mink-extension": "^2.4",
- "friends-of-behat/page-object-extension": "^0.3",
- "friends-of-behat/symfony-extension": "^2.1",
- "friends-of-behat/variadic-extension": "^1.3",
- "hwi/oauth-bundle": "^1.1",
- "lchrusciel/api-test-case": "^5.0",
- "matthiasnoback/symfony-config-test": "^4.2",
- "matthiasnoback/symfony-dependency-injection-test": "^4.1",
- "mikey179/vfsstream": "^1.6",
- "mockery/mockery": "^1.4",
- "pamil/prophecy-common": "^0.1",
- "phpspec/phpspec": "^6.1 || ^7.2",
- "phpstan/phpstan": "^0.12.57",
- "phpstan/phpstan-doctrine": "^0.12.19",
- "phpstan/phpstan-webmozart-assert": "^0.12.7",
- "phpunit/phpunit": "^8.5",
- "psalm/plugin-mockery": "^0.3",
- "psr/event-dispatcher": "^1.0",
- "sylius-labs/coding-standard": "^3.1",
- "symfony/browser-kit": "^4.4 || ^5.2 || ^6.0",
- "symfony/debug-bundle": "^4.4 || ^5.2 || ^6.0",
- "symfony/dotenv": "^4.4 || ^5.2 || ^6.0",
- "symfony/flex": "^1.7 || ^2.2.2",
- "symfony/web-profiler-bundle": "^4.4 || ^5.2 || ^6.0",
- "phpmd/phpmd": "@stable"
+ "friendsofphp/php-cs-fixer": "^3.16",
+ "phpspec/phpspec": "^7.0",
+ "phpstan/phpstan": "^1.8.4",
+ "phpstan/phpstan-doctrine": "^1.3.2",
+ "phpstan/phpstan-webmozart-assert": "^1.1",
+ "phpunit/phpunit": "^10.5",
+ "phpmd/phpmd": "^2.15"
},
"prefer-stable": true,
"autoload": {
@@ -62,31 +36,26 @@
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"phpcs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --using-cache=no",
- "jane-generate": "jane generate --config-file=src/Resources/config/jane/jane-configuration.php",
"phpstan": "phpstan analyse -c phpstan.neon src/",
"phpmd": "phpmd --exclude Migrations/* src/ ansi phpmd.xml",
"phpunit": "phpunit",
"phpspec": "phpspec run"
},
"extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev"
+ },
"symfony": {
- "require": "^4.4",
"docker": false,
- "endpoint": [
- "https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master",
- "flex://defaults"
- ]
- },
- "branch-alias": {
- "dev-master": "2.0-dev"
+ "endpoint": ["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master", "flex://defaults"]
}
},
"config": {
"allow-plugins": {
- "dealerdirect/phpcodesniffer-composer-installer": true,
"symfony/thanks": true,
- "ergebnis/composer-normalize": true,
"symfony/flex": true,
+ "dealerdirect/phpcodesniffer-composer-installer": true,
+ "ergebnis/composer-normalize": true,
"php-http/discovery": true
}
}
diff --git a/dist/.env.local b/dist/.env.local
index dd3f4a37..7860bf2c 100644
--- a/dist/.env.local
+++ b/dist/.env.local
@@ -2,3 +2,4 @@ MONSIEURBIZ_SEARCHPLUGIN_MESSENGER_TRANSPORT_DSN=doctrine://default
MONSIEURBIZ_SEARCHPLUGIN_ES_HOST=${ELASTICSEARCH_HOST:-localhost}
MONSIEURBIZ_SEARCHPLUGIN_ES_PORT=${ELASTICSEARCH_PORT:-9200}
MONSIEURBIZ_SEARCHPLUGIN_ES_URL=http://${MONSIEURBIZ_SEARCHPLUGIN_ES_HOST}:${MONSIEURBIZ_SEARCHPLUGIN_ES_PORT}/
+SYLIUS_FIXTURES_HOSTNAME=${SYMFONY_DEFAULT_ROUTE_HOST:-localhost}
diff --git a/dist/src/Entity/Product/ProductAttribute.php b/dist/src/Entity/Product/ProductAttribute.php
index eaff27e7..1377d7cb 100644
--- a/dist/src/Entity/Product/ProductAttribute.php
+++ b/dist/src/Entity/Product/ProductAttribute.php
@@ -23,6 +23,8 @@
* @ORM\Entity
* @ORM\Table(name="sylius_product_attribute")
*/
+#[ORM\Entity]
+#[ORM\Table(name: 'sylius_product_attribute')]
class ProductAttribute extends BaseProductAttribute implements SearchableInterface
{
use SearchableTrait;
diff --git a/dist/src/Entity/Product/ProductOption.php b/dist/src/Entity/Product/ProductOption.php
index 2adc02e8..67d53a57 100644
--- a/dist/src/Entity/Product/ProductOption.php
+++ b/dist/src/Entity/Product/ProductOption.php
@@ -23,6 +23,8 @@
* @ORM\Entity
* @ORM\Table(name="sylius_product_option")
*/
+#[ORM\Entity]
+#[ORM\Table(name: 'sylius_product_option')]
class ProductOption extends BaseProductOption implements SearchableInterface
{
use SearchableTrait;
diff --git a/dist/src/Search/Automapper/TaxonMapperConfiguration.php b/dist/src/Search/Automapper/TaxonMapperConfiguration.php
index a9647679..1ef28fd0 100644
--- a/dist/src/Search/Automapper/TaxonMapperConfiguration.php
+++ b/dist/src/Search/Automapper/TaxonMapperConfiguration.php
@@ -113,9 +113,9 @@ private function getRealTaxonEntity(TaxonInterface $taxon): TaxonInterface
{
if ($taxon instanceof Proxy) {
// Clear the entity manager to detach the proxy object
- $this->entityManager->clear(\get_class($taxon));
+ $this->entityManager->clear($taxon::class);
// Retrieve the original class name
- $entityClassName = ClassUtils::getRealClass(\get_class($taxon));
+ $entityClassName = ClassUtils::getRealClass($taxon::class);
// Find the object in repository from the ID
/** @var ?TaxonInterface $taxon */
$taxon = $this->entityManager->find($entityClassName, $taxon->getId());
diff --git a/generated/Normalizer/ChannelDTONormalizer.php b/generated/Normalizer/ChannelDTONormalizer.php
index c5b96b76..2ede3929 100644
--- a/generated/Normalizer/ChannelDTONormalizer.php
+++ b/generated/Normalizer/ChannelDTONormalizer.php
@@ -25,9 +25,7 @@
class ChannelDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use CheckArray;
-
use DenormalizerAwareTrait;
-
use NormalizerAwareTrait;
public function supportsDenormalization($data, $type, $format = null)
diff --git a/generated/Normalizer/ImageDTONormalizer.php b/generated/Normalizer/ImageDTONormalizer.php
index 6b2acde5..910779c0 100644
--- a/generated/Normalizer/ImageDTONormalizer.php
+++ b/generated/Normalizer/ImageDTONormalizer.php
@@ -25,9 +25,7 @@
class ImageDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use CheckArray;
-
use DenormalizerAwareTrait;
-
use NormalizerAwareTrait;
public function supportsDenormalization($data, $type, $format = null)
diff --git a/generated/Normalizer/JaneObjectNormalizer.php b/generated/Normalizer/JaneObjectNormalizer.php
index 48f7047c..e9ce3c27 100644
--- a/generated/Normalizer/JaneObjectNormalizer.php
+++ b/generated/Normalizer/JaneObjectNormalizer.php
@@ -24,9 +24,7 @@
class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use CheckArray;
-
use DenormalizerAwareTrait;
-
use NormalizerAwareTrait;
protected $normalizers = ['MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ImageDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ImageDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ChannelDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ChannelDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ProductTaxonDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ProductTaxonDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\TaxonDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\TaxonDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ProductAttributeDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ProductAttributeDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\PricingDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\PricingDTONormalizer', '\\Jane\\Component\\JsonSchemaRuntime\\Reference' => '\\MonsieurBiz\\SyliusSearchPlugin\\Generated\\Runtime\\Normalizer\\ReferenceNormalizer'];
@@ -40,12 +38,12 @@ public function supportsDenormalization($data, $type, $format = null)
public function supportsNormalization($data, $format = null)
{
- return \is_object($data) && \array_key_exists(\get_class($data), $this->normalizers);
+ return \is_object($data) && \array_key_exists($data::class, $this->normalizers);
}
public function normalize($object, $format = null, array $context = [])
{
- $normalizerClass = $this->normalizers[\get_class($object)];
+ $normalizerClass = $this->normalizers[$object::class];
$normalizer = $this->getNormalizer($normalizerClass);
return $normalizer->normalize($object, $format, $context);
diff --git a/generated/Normalizer/PricingDTONormalizer.php b/generated/Normalizer/PricingDTONormalizer.php
index b556b93b..69183914 100644
--- a/generated/Normalizer/PricingDTONormalizer.php
+++ b/generated/Normalizer/PricingDTONormalizer.php
@@ -25,9 +25,7 @@
class PricingDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use CheckArray;
-
use DenormalizerAwareTrait;
-
use NormalizerAwareTrait;
public function supportsDenormalization($data, $type, $format = null)
diff --git a/generated/Normalizer/ProductAttributeDTONormalizer.php b/generated/Normalizer/ProductAttributeDTONormalizer.php
index 7936b408..f101084a 100644
--- a/generated/Normalizer/ProductAttributeDTONormalizer.php
+++ b/generated/Normalizer/ProductAttributeDTONormalizer.php
@@ -25,9 +25,7 @@
class ProductAttributeDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use CheckArray;
-
use DenormalizerAwareTrait;
-
use NormalizerAwareTrait;
public function supportsDenormalization($data, $type, $format = null)
diff --git a/generated/Normalizer/ProductTaxonDTONormalizer.php b/generated/Normalizer/ProductTaxonDTONormalizer.php
index c9831949..2201b2ea 100644
--- a/generated/Normalizer/ProductTaxonDTONormalizer.php
+++ b/generated/Normalizer/ProductTaxonDTONormalizer.php
@@ -25,9 +25,7 @@
class ProductTaxonDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use CheckArray;
-
use DenormalizerAwareTrait;
-
use NormalizerAwareTrait;
public function supportsDenormalization($data, $type, $format = null)
diff --git a/generated/Normalizer/TaxonDTONormalizer.php b/generated/Normalizer/TaxonDTONormalizer.php
index c7ac195c..95e88f37 100644
--- a/generated/Normalizer/TaxonDTONormalizer.php
+++ b/generated/Normalizer/TaxonDTONormalizer.php
@@ -25,9 +25,7 @@
class TaxonDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use CheckArray;
-
use DenormalizerAwareTrait;
-
use NormalizerAwareTrait;
public function supportsDenormalization($data, $type, $format = null)
diff --git a/phpstan.neon b/phpstan.neon
index 39be1cd4..00dcac7c 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -3,10 +3,7 @@ parameters:
paths:
- %rootDir%/src/
- checkMissingIterableValueType: false
- checkGenericClassInNonGenericObjectType: false
-
- excludes_analyse:
+ excludePaths:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'
- 'src/DependencyInjection/MonsieurBizSyliusSearchExtension.php'
@@ -16,3 +13,7 @@ parameters:
# Generated files
- 'generated/**/*'
+
+ ignoreErrors:
+ - identifier: missingType.generics
+ - identifier: missingType.iterableValue
diff --git a/src/AutoMapper/ProductAttributeValueConfiguration.php b/src/AutoMapper/ProductAttributeValueConfiguration.php
index e9030893..546be708 100644
--- a/src/AutoMapper/ProductAttributeValueConfiguration.php
+++ b/src/AutoMapper/ProductAttributeValueConfiguration.php
@@ -22,6 +22,7 @@
use Psr\Log\NullLogger;
use RuntimeException;
use Sylius\Component\Product\Model\ProductAttributeValueInterface;
+use Traversable;
final class ProductAttributeValueConfiguration implements MapperConfigurationInterface, LoggerAwareInterface
{
@@ -38,7 +39,7 @@ public function __construct(ConfigurationInterface $configuration, iterable $pro
{
$this->logger = new NullLogger();
$this->configuration = $configuration;
- $this->productAttributeValueReaders = $productAttributeValueReaders instanceof \Traversable
+ $this->productAttributeValueReaders = $productAttributeValueReaders instanceof Traversable
? iterator_to_array($productAttributeValueReaders)
: $productAttributeValueReaders;
}
diff --git a/src/AutoMapper/ProductAttributeValueReader/DateTimeReader.php b/src/AutoMapper/ProductAttributeValueReader/DateTimeReader.php
index bb6e6786..70540f73 100644
--- a/src/AutoMapper/ProductAttributeValueReader/DateTimeReader.php
+++ b/src/AutoMapper/ProductAttributeValueReader/DateTimeReader.php
@@ -13,6 +13,7 @@
namespace MonsieurBiz\SyliusSearchPlugin\AutoMapper\ProductAttributeValueReader;
+use DateTime;
use Sylius\Component\Product\Model\ProductAttributeValueInterface;
class DateTimeReader implements ReaderInterface
@@ -26,7 +27,7 @@ public function getValue(ProductAttributeValueInterface $productAttribute)
}
$productAttributeValue = $productAttribute->getValue();
- if ($productAttributeValue instanceof \DateTime) {
+ if ($productAttributeValue instanceof DateTime) {
$productAttributeValue = $productAttributeValue->format($this->defaultFormat);
}
diff --git a/src/AutoMapper/ProductMapperConfiguration.php b/src/AutoMapper/ProductMapperConfiguration.php
index 67c7544e..2a71064f 100644
--- a/src/AutoMapper/ProductMapperConfiguration.php
+++ b/src/AutoMapper/ProductMapperConfiguration.php
@@ -130,6 +130,7 @@ public function process(MapperGeneratorMetadataInterface $metadata): void
});
$metadata->forMember('channels', function (ProductInterface $product): array {
+ /** @phpstan-ignore-next-line */
return array_map(function (ChannelInterface $channel) {
return $this->autoMapper->map($channel, $this->configuration->getTargetClass('channel'));
}, $product->getChannels()->toArray());
diff --git a/src/Checker/ElasticsearchChecker.php b/src/Checker/ElasticsearchChecker.php
index 2e46dd7d..94a2d3a0 100644
--- a/src/Checker/ElasticsearchChecker.php
+++ b/src/Checker/ElasticsearchChecker.php
@@ -13,6 +13,7 @@
namespace MonsieurBiz\SyliusSearchPlugin\Checker;
+use Exception;
use JoliCode\Elastically\Factory;
class ElasticsearchChecker implements ElasticsearchCheckerInterface
@@ -34,7 +35,7 @@ public function check(): bool
// Check client response
try {
$client->getStatus()->getResponse();
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->isAvailable = false;
return $this->isAvailable;
diff --git a/src/Command/SearchCommand.php b/src/Command/SearchCommand.php
index aa026d72..acdce0d3 100644
--- a/src/Command/SearchCommand.php
+++ b/src/Command/SearchCommand.php
@@ -13,7 +13,6 @@
namespace MonsieurBiz\SyliusSearchPlugin\Command;
-use Elastica\Exception\Connection\HttpException;
use MonsieurBiz\SyliusSearchPlugin\Model\Documentable\DocumentableInterface;
use MonsieurBiz\SyliusSearchPlugin\Model\Product\ProductDTO;
use MonsieurBiz\SyliusSearchPlugin\Search\Request\RequestConfiguration;
@@ -85,13 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->channelContext
);
- try {
- $result = $this->search->search($requestConfiguration);
- } catch (HttpException $exception) {
- $io->error('Error with the HTTP request: ' . $exception->getMessage());
-
- return Command::FAILURE;
- }
+ $result = $this->search->search($requestConfiguration);
$io->title('Search result for: ' . $query);
$io->section('Nb results: ' . $result->count());
diff --git a/src/Controller/SearchController.php b/src/Controller/SearchController.php
index 9cf4de25..b592d177 100644
--- a/src/Controller/SearchController.php
+++ b/src/Controller/SearchController.php
@@ -98,7 +98,7 @@ public function searchAction(
*/
public function postAction(Request $request): RedirectResponse
{
- $query = (array) $request->request->all()['monsieurbiz_searchplugin_search'] ?? [];
+ $query = (array) ($request->request->all()['monsieurbiz_searchplugin_search'] ?? []);
$query = $query['query'] ?? '';
// With Apache a URL with a encoded slash (%2F) is provoking a 404 error on the server level
@@ -143,13 +143,15 @@ public function taxonAction(
string $documentType = 'monsieurbiz_product'
): Response {
$documentable = $this->getDocumentable($documentType);
+ /** @var array $syliusAttribute */
+ $syliusAttribute = $request->attributes->get('_sylius', []);
$requestConfiguration = new RequestConfiguration(
$request,
RequestInterface::TAXON_TYPE,
$documentable,
$this->searchSettings,
$this->channelContext,
- new Parameters($this->parametersParser->parseRequestValues($request->attributes->get('_sylius', []), $request))
+ new Parameters($this->parametersParser->parseRequestValues($syliusAttribute, $request))
);
$result = $this->search->search($requestConfiguration);
diff --git a/src/DependencyInjection/DocumentableRegistryPass.php b/src/DependencyInjection/DocumentableRegistryPass.php
index 39f866ca..dac74c00 100644
--- a/src/DependencyInjection/DocumentableRegistryPass.php
+++ b/src/DependencyInjection/DocumentableRegistryPass.php
@@ -46,7 +46,7 @@ public function process(ContainerBuilder $container): void
*/
private function validateDocumentableResource(string $class): void
{
- $interfaces = (array) (class_implements($class) ?? []);
+ $interfaces = (array) class_implements($class);
if (!\in_array(DocumentableInterface::class, $interfaces, true)) {
throw new InvalidArgumentException(sprintf('Class "%s" must implement "%s" to be registered as a Documentable.', $class, DocumentableInterface::class));
@@ -55,7 +55,7 @@ private function validateDocumentableResource(string $class): void
private function isPrefixedDocumentableClass(string $class): bool
{
- $interfaces = (array) (class_implements($class) ?? []);
+ $interfaces = (array) class_implements($class);
return \in_array(PrefixedDocumentableInterface::class, $interfaces, true);
}
@@ -66,6 +66,7 @@ private function addDocumentableServices(ContainerBuilder $container, array $doc
$searchSettings = [];
if ($container->hasParameter('monsieurbiz.settings.config.plugins')) {
+ /** @var array $searchSettings */
$searchSettings = $container->getParameter('monsieurbiz.settings.config.plugins');
}
diff --git a/src/Fixture/Factory/SearchableFixtureFactory.php b/src/Fixture/Factory/SearchableFixtureFactory.php
index 45f7e8e3..c54eb42f 100644
--- a/src/Fixture/Factory/SearchableFixtureFactory.php
+++ b/src/Fixture/Factory/SearchableFixtureFactory.php
@@ -78,9 +78,9 @@ public function create(array $options = []): SearchableInterface
{
$options = $this->optionsResolver->resolve($options);
$object = $this->getSearchableObject($options);
- $object->setFilterable(((bool) $options['filterable']) ?? false);
- $object->setSearchable(((bool) $options['searchable']) ?? false);
- $object->setSearchWeight(((int) $options['search_weight']) ?? 1);
+ $object->setFilterable((bool) ($options['filterable'] ?? false));
+ $object->setSearchable((bool) ($options['searchable'] ?? false));
+ $object->setSearchWeight((int) ($options['search_weight'] ?? 1));
return $object;
}
diff --git a/src/Form/Type/Settings/SettingsSearchType.php b/src/Form/Type/Settings/SettingsSearchType.php
index f8784303..aef25690 100644
--- a/src/Form/Type/Settings/SettingsSearchType.php
+++ b/src/Form/Type/Settings/SettingsSearchType.php
@@ -41,8 +41,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => 'monsieurbiz_searchplugin.admin.setting_form.instant_search_enabled_' . $documentable->getIndexCode(),
]
);
+ /** @var array $optionsData */
+ $optionsData = $options['data'] ?? [];
$subOptions = [];
- $subOptions['data'] = $options['data']['limits__' . $documentable->getIndexCode()] ?? [];
+ $subOptions['data'] = $optionsData['limits__' . $documentable->getIndexCode()] ?? [];
$subOptions['documentable'] = $documentable;
$this->addWithDefaultCheckbox(
$builder,
diff --git a/src/Index/Indexer.php b/src/Index/Indexer.php
index 7e731a6b..03f070c7 100644
--- a/src/Index/Indexer.php
+++ b/src/Index/Indexer.php
@@ -187,6 +187,7 @@ private function indexDocumentable(OutputInterface $output, DocumentableInterfac
$indexer = $this->clientFactory->getIndexer($documentable, $locale);
foreach ($documentable->getDatasource()->getItems($documentable->getSourceClass()) as $item) {
+ /** @var object $item */
$item = $this->getRealEntity($item);
if (null !== $locale && $item instanceof TranslatableInterface) {
$item->setCurrentLocale($locale);
@@ -221,9 +222,10 @@ private function getRealEntity($entity)
}
// Clear the entity manager to detach the proxy object
- $this->entityManager->clear(\get_class($entity)); /** @phpstan-ignore-line */
+ $this->entityManager->clear($entity::class); /** @phpstan-ignore-line */
// Retrieve the original class name
- $entityClassName = $this->entityManager->getClassMetadata(\get_class($entity))->rootEntityName;
+ $entityClassName = $this->entityManager->getClassMetadata($entity::class)->rootEntityName;
+
// Find the object in repository from the ID
return $this->entityManager->find($entityClassName, $entity->getId());
}
diff --git a/src/Mapping/YamlWithLocaleProvider.php b/src/Mapping/YamlWithLocaleProvider.php
index feba5cb8..1a4e9550 100644
--- a/src/Mapping/YamlWithLocaleProvider.php
+++ b/src/Mapping/YamlWithLocaleProvider.php
@@ -81,7 +81,9 @@ private function appendMapping(string $configurationDirectory, array $mapping, s
$fileName = $context['filename'] ?? ($indexName . '_mapping.yaml');
$mappingFilePath = $configurationDirectory . \DIRECTORY_SEPARATOR . $fileName;
- $mapping = array_merge_recursive($mapping, $this->parser->parseFile($mappingFilePath));
+ /** @var array $parsedMapping */
+ $parsedMapping = $this->parser->parseFile($mappingFilePath) ?? [];
+ $mapping = array_merge_recursive($mapping, $parsedMapping);
} catch (ParseException $exception) {
// the mapping yaml file does not exist.
}
@@ -107,6 +109,7 @@ private function appendLocaleAnalyzers(string $configurationDirectory, array $ma
private function appendAnalyzers(string $analyzerFilePath, array $mapping): array
{
try {
+ /** @var array $analyzer */
$analyzer = $this->parser->parseFile($analyzerFilePath) ?? [];
$mapping['settings']['analysis'] = array_merge_recursive($mapping['settings']['analysis'] ?? [], $analyzer);
} catch (ParseException $exception) {
diff --git a/src/Message/ProductReindexFromTaxon.php b/src/Message/ProductReindexFromTaxon.php
index 7b2af22f..0d1de880 100644
--- a/src/Message/ProductReindexFromTaxon.php
+++ b/src/Message/ProductReindexFromTaxon.php
@@ -15,7 +15,7 @@
class ProductReindexFromTaxon
{
- //todo rename to ProductReindexFromTaxonId
+ // todo rename to ProductReindexFromTaxonId
private int $taxonId;
diff --git a/src/MessageHandler/ProductReindexFromTaxonHandler.php b/src/MessageHandler/ProductReindexFromTaxonHandler.php
index a2a3f636..82b1a74c 100644
--- a/src/MessageHandler/ProductReindexFromTaxonHandler.php
+++ b/src/MessageHandler/ProductReindexFromTaxonHandler.php
@@ -46,11 +46,13 @@ public function __invoke(ProductReindexFromTaxon $message): void
if (!$this->productRepository instanceof EntityRepository) {
return;
}
+
+ /** @var array $products */
$products = $this->productRepository->createQueryBuilder('o')
->innerJoin('o.productTaxons', 'productTaxon')
->andWhere('productTaxon.taxon = :taxonId')
->setParameter('taxonId', $message->getTaxonId())->getQuery()->getResult()
- ;
+ ;
$this->indexer->indexByDocuments(
$documentable,
diff --git a/src/MessageHandler/ProductToDeleteFromIdsHandler.php b/src/MessageHandler/ProductToDeleteFromIdsHandler.php
index 6ef5b06d..746d58a7 100644
--- a/src/MessageHandler/ProductToDeleteFromIdsHandler.php
+++ b/src/MessageHandler/ProductToDeleteFromIdsHandler.php
@@ -16,24 +16,19 @@
use MonsieurBiz\SyliusSearchPlugin\Index\IndexerInterface;
use MonsieurBiz\SyliusSearchPlugin\Message\ProductToDeleteFromIds;
use MonsieurBiz\SyliusSearchPlugin\Model\Documentable\DocumentableInterface;
-use Sylius\Component\Core\Repository\ProductRepositoryInterface;
use Sylius\Component\Registry\ServiceRegistryInterface;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
class ProductToDeleteFromIdsHandler implements MessageHandlerInterface
{
- private ProductRepositoryInterface $productRepository;
-
private IndexerInterface $indexer;
private ServiceRegistryInterface $documentableRegistry;
public function __construct(
- ProductRepositoryInterface $productRepository,
IndexerInterface $indexer,
ServiceRegistryInterface $documentableRegistry
) {
- $this->productRepository = $productRepository;
$this->indexer = $indexer;
$this->documentableRegistry = $documentableRegistry;
}
diff --git a/src/Model/Documentable/Documentable.php b/src/Model/Documentable/Documentable.php
index 43fccfff..cf865803 100644
--- a/src/Model/Documentable/Documentable.php
+++ b/src/Model/Documentable/Documentable.php
@@ -18,7 +18,6 @@
class Documentable implements PrefixedDocumentableInterface
{
use DocumentableDatasourceTrait;
-
use DocumentableMappingProviderTrait;
private string $indexCode;
@@ -67,7 +66,7 @@ public function getTargetClass(): string
public function isTranslatable(): bool
{
- $interface = (array) (class_implements($this->getSourceClass()) ?? []);
+ $interface = (array) class_implements($this->getSourceClass());
return \in_array(TranslatableInterface::class, $interface, true);
}
diff --git a/src/Model/Product/VariantDTO.php b/src/Model/Product/VariantDTO.php
index 9231f3a0..c973ec63 100644
--- a/src/Model/Product/VariantDTO.php
+++ b/src/Model/Product/VariantDTO.php
@@ -19,6 +19,7 @@ final class VariantDTO extends Eater
{
public function getCode(): ?string
{
+ /** @phpstan-ignore-next-line */
return $this->getData('code');
}
diff --git a/src/Normalizer/Product/ProductDTONormalizer.php b/src/Normalizer/Product/ProductDTONormalizer.php
index 394f5569..dcb053cd 100644
--- a/src/Normalizer/Product/ProductDTONormalizer.php
+++ b/src/Normalizer/Product/ProductDTONormalizer.php
@@ -28,10 +28,11 @@
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
+/** @TODO remove ObjectNormalizer extends before Symfony 7.0 */
+/** @phpstan-ignore-next-line */
final class ProductDTONormalizer extends ObjectNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use DenormalizerAwareTrait;
-
use NormalizerAwareTrait;
private Configuration $automapperConfiguration;
@@ -69,13 +70,13 @@ public function denormalize($data, string $type, string $format = null, array $c
/** @var ProductDTO $object */
$object = parent::denormalize($data, $type, $format, $context);
- if (\array_key_exists('main_taxon', $data) && null !== $data['main_taxon']) {
+ if (\is_array($data) && \array_key_exists('main_taxon', $data) && null !== $data['main_taxon']) {
$taxonDTOClass = $this->automapperConfiguration->getTargetClass('taxon');
$object->setData('main_taxon', $this->denormalizer->denormalize($data['main_taxon'], $taxonDTOClass, 'json', $context));
unset($data['main_taxon']);
}
- if (\array_key_exists('product_taxons', $data) && null !== $data['product_taxons']) {
+ if (\is_array($data) && \array_key_exists('product_taxons', $data) && null !== $data['product_taxons']) {
$values = [];
$productTaxonDTOClass = $this->automapperConfiguration->getTargetClass('product_taxon');
foreach ($data['product_taxons'] as $value) {
@@ -85,7 +86,7 @@ public function denormalize($data, string $type, string $format = null, array $c
unset($data['product_taxons']);
}
- if (\array_key_exists('images', $data) && null !== $data['images']) {
+ if (\is_array($data) && \array_key_exists('images', $data) && null !== $data['images']) {
$values = [];
$imageDTOClass = $this->automapperConfiguration->getTargetClass('image');
foreach ($data['images'] as $value) {
@@ -95,7 +96,7 @@ public function denormalize($data, string $type, string $format = null, array $c
unset($data['product_taxons']);
}
- if (\array_key_exists('channels', $data) && null !== $data['channels']) {
+ if (\is_array($data) && \array_key_exists('channels', $data) && null !== $data['channels']) {
$values = [];
$channelDTOClass = $this->automapperConfiguration->getTargetClass('channel');
foreach ($data['channels'] as $value) {
@@ -105,7 +106,7 @@ public function denormalize($data, string $type, string $format = null, array $c
unset($data['channels']);
}
- if (\array_key_exists('attributes', $data) && null !== $data['attributes']) {
+ if (\is_array($data) && \array_key_exists('attributes', $data) && null !== $data['attributes']) {
$values = [];
$productAttributeDTOClass = $this->automapperConfiguration->getTargetClass('product_attribute');
foreach ($data['attributes'] as $key => $value) {
@@ -115,7 +116,7 @@ public function denormalize($data, string $type, string $format = null, array $c
unset($data['channels']);
}
- if (\array_key_exists('prices', $data) && null !== $data['prices']) {
+ if (\is_array($data) && \array_key_exists('prices', $data) && null !== $data['prices']) {
$values = [];
$pricingDTOClass = $this->automapperConfiguration->getTargetClass('pricing');
foreach ($data['prices'] as $key => $value) {
diff --git a/src/Repository/ProductAttributeRepository.php b/src/Repository/ProductAttributeRepository.php
index 814bbabb..498f0797 100644
--- a/src/Repository/ProductAttributeRepository.php
+++ b/src/Repository/ProductAttributeRepository.php
@@ -26,12 +26,13 @@ public function __construct(EntityRepository $attributeRepository)
public function findIsSearchableOrFilterable(): array
{
+ /** @phpstan-ignore-next-line */
return $this->attributeRepository->createQueryBuilder('o')
->innerJoin('o.translations', 'translation')
->andWhere('o.searchable = true')
->orWhere('o.filterable = true')
->getQuery()
->getResult()
- ;
+ ;
}
}
diff --git a/src/Repository/ProductOptionRepository.php b/src/Repository/ProductOptionRepository.php
index 07aa25e5..79d98a7c 100644
--- a/src/Repository/ProductOptionRepository.php
+++ b/src/Repository/ProductOptionRepository.php
@@ -26,12 +26,13 @@ public function __construct(EntityRepository $productOptionRepository)
public function findIsSearchableOrFilterable(): array
{
+ /** @phpstan-ignore-next-line */
return $this->productOptionRepository->createQueryBuilder('o')
->innerJoin('o.translations', 'translation')
->andWhere('o.searchable = true')
->orWhere('o.filterable = true')
->getQuery()
->getResult()
- ;
+ ;
}
}
diff --git a/src/Resources/public/entrypoints.json b/src/Resources/public/entrypoints.json
index c587a109..8ff7f653 100644
--- a/src/Resources/public/entrypoints.json
+++ b/src/Resources/public/entrypoints.json
@@ -2,7 +2,7 @@
"entrypoints": {
"monsieurbiz-search": {
"js": [
- "/bundles/monsieurbizsyliussearchplugin/js/monsieurbiz-search.bd704c68.js"
+ "/bundles/monsieurbizsyliussearchplugin/js/monsieurbiz-search.eb2121b2.js"
]
}
}
diff --git a/src/Resources/public/js/monsieurbiz-search.bd704c68.js b/src/Resources/public/js/monsieurbiz-search.bd704c68.js
deleted file mode 100644
index 57c17717..00000000
--- a/src/Resources/public/js/monsieurbiz-search.bd704c68.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/bundles/monsieurbizsyliussearchplugin/",n(n.s="ng4s")}({"2mad":function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},ng4s:function(e,t,n){(function(e){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,n){for(var r=0;r=t){var o=new XMLHttpRequest;o.onload=function(){200===this.status&&(r.innerHTML=this.responseText,r.style.display="block")},o.open("POST",n),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),o.send(new URLSearchParams({query:e}).toString())}}}])&&n(t.prototype,r),o&&n(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}(),document.addEventListener("DOMContentLoaded",(function(){new MonsieurBizInstantSearch(monsieurbizSearchPlugin.instantUrl,monsieurbizSearchPlugin.searchInputSelector,monsieurbizSearchPlugin.resultClosestSelector,monsieurbizSearchPlugin.resultFindSelector,monsieurbizSearchPlugin.keyUpTimeOut,monsieurbizSearchPlugin.minQueryLength)}))}).call(this,n("2mad"))}});
\ No newline at end of file
diff --git a/src/Resources/public/js/monsieurbiz-search.eb2121b2.js b/src/Resources/public/js/monsieurbiz-search.eb2121b2.js
new file mode 100644
index 00000000..4607142f
--- /dev/null
+++ b/src/Resources/public/js/monsieurbiz-search.eb2121b2.js
@@ -0,0 +1 @@
+!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/bundles/monsieurbizsyliussearchplugin/",n(n.s="ng4s")}({"2mad":function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},ng4s:function(e,t,n){(function(e){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var n=0;n=t){var o=new XMLHttpRequest;o.onload=function(){200===this.status&&(r.innerHTML=this.responseText,r.style.display="block")},o.open("POST",n),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),o.send(new URLSearchParams({query:e}).toString())}}}])&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}(),document.addEventListener("DOMContentLoaded",(function(){new MonsieurBizInstantSearch(monsieurbizSearchPlugin.instantUrl,monsieurbizSearchPlugin.searchInputSelector,monsieurbizSearchPlugin.resultClosestSelector,monsieurbizSearchPlugin.resultFindSelector,monsieurbizSearchPlugin.keyUpTimeOut,monsieurbizSearchPlugin.minQueryLength)}))}).call(this,n("2mad"))}});
\ No newline at end of file
diff --git a/src/Resources/public/manifest.json b/src/Resources/public/manifest.json
index 140b0bbb..e5530873 100644
--- a/src/Resources/public/manifest.json
+++ b/src/Resources/public/manifest.json
@@ -1,3 +1,3 @@
{
- "bundles/monsieurbizsyliussearchplugin/monsieurbiz-search.js": "/bundles/monsieurbizsyliussearchplugin/js/monsieurbiz-search.bd704c68.js"
+ "bundles/monsieurbizsyliussearchplugin/monsieurbiz-search.js": "/bundles/monsieurbizsyliussearchplugin/js/monsieurbiz-search.eb2121b2.js"
}
\ No newline at end of file
diff --git a/src/Search/Request/Aggregation/MainTaxonAggregation.php b/src/Search/Request/Aggregation/MainTaxonAggregation.php
index c8750d97..1ea903b7 100644
--- a/src/Search/Request/Aggregation/MainTaxonAggregation.php
+++ b/src/Search/Request/Aggregation/MainTaxonAggregation.php
@@ -54,7 +54,7 @@ public function build($aggregation, array $filters)
)
)
)
- ;
+ ;
}
/**
diff --git a/src/Search/Request/Aggregation/PriceAggregation.php b/src/Search/Request/Aggregation/PriceAggregation.php
index 4df477a9..4bd38c80 100644
--- a/src/Search/Request/Aggregation/PriceAggregation.php
+++ b/src/Search/Request/Aggregation/PriceAggregation.php
@@ -63,7 +63,7 @@ public function build($aggregation, array $filters)
)
)
)
- ;
+ ;
}
/**
diff --git a/src/Search/Request/Aggregation/ProductAttributesAggregation.php b/src/Search/Request/Aggregation/ProductAttributesAggregation.php
index 68be0354..6c87d4da 100644
--- a/src/Search/Request/Aggregation/ProductAttributesAggregation.php
+++ b/src/Search/Request/Aggregation/ProductAttributesAggregation.php
@@ -29,7 +29,7 @@ public function __construct()
/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*
- * @param mixed $aggregation
+ * @param array $aggregation
*/
public function build($aggregation, array $filters)
{
@@ -40,7 +40,10 @@ public function build($aggregation, array $filters)
$qb = new QueryBuilder();
$currentFilters = array_filter($filters, function (AbstractQuery $filter): bool {
- return !$filter->hasParam('path') || false === strpos($filter->getParam('path'), 'attributes.');
+ /** @var string $path */
+ $path = $filter->hasParam('path') ? $filter->getParam('path') : '';
+
+ return !$filter->hasParam('path') || false === strpos($path, 'attributes.');
});
$filterQuery = $qb->query()->bool();
diff --git a/src/Search/Request/Aggregation/ProductOptionAggregation.php b/src/Search/Request/Aggregation/ProductOptionAggregation.php
index 70684f12..ecf6a011 100644
--- a/src/Search/Request/Aggregation/ProductOptionAggregation.php
+++ b/src/Search/Request/Aggregation/ProductOptionAggregation.php
@@ -42,10 +42,13 @@ public function build($aggregation, array $filters)
$qb = new QueryBuilder();
$filters = array_filter($filters, function (AbstractQuery $filter) use ($aggregation): bool {
+ /** @var string $path */
+ $path = $filter->hasParam('path') ? $filter->getParam('path') : '';
+
return !$filter->hasParam('path') || (
- false !== strpos($filter->getParam('path'), 'options.')
- && 'options.' . $aggregation->getCode() . '.values' !== $filter->getParam('path')
- );
+ false !== strpos($path, 'options.')
+ && 'options.' . $aggregation->getCode() . '.values' !== $path
+ );
});
$filterQuery = $qb->query()->bool();
diff --git a/src/Search/Request/Aggregation/ProductOptionsAggregation.php b/src/Search/Request/Aggregation/ProductOptionsAggregation.php
index fed8f293..360b6462 100644
--- a/src/Search/Request/Aggregation/ProductOptionsAggregation.php
+++ b/src/Search/Request/Aggregation/ProductOptionsAggregation.php
@@ -29,7 +29,7 @@ public function __construct(ProductOptionAggregation $productOptionAggregationBu
/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*
- * @param mixed $aggregation
+ * @param array $aggregation
*/
public function build($aggregation, array $filters)
{
@@ -39,7 +39,10 @@ public function build($aggregation, array $filters)
$qb = new QueryBuilder();
$currentFilters = array_filter($filters, function (AbstractQuery $filter): bool {
- return !$filter->hasParam('path') || false === strpos($filter->getParam('path'), 'options.');
+ /** @var string $path */
+ $path = $filter->hasParam('path') ? $filter->getParam('path') : '';
+
+ return !$filter->hasParam('path') || false === strpos($path, 'options.');
});
$filterQuery = $qb->query()->bool();
foreach ($currentFilters as $filter) {
diff --git a/src/Search/Request/Aggregation/TaxonsAggregation.php b/src/Search/Request/Aggregation/TaxonsAggregation.php
index 79acc0b9..85d12177 100644
--- a/src/Search/Request/Aggregation/TaxonsAggregation.php
+++ b/src/Search/Request/Aggregation/TaxonsAggregation.php
@@ -61,7 +61,7 @@ public function build($aggregation, array $filters)
)
)
)
- ;
+ ;
}
/**
diff --git a/src/Search/Request/ProductRequest/Search.php b/src/Search/Request/ProductRequest/Search.php
index 2cffc8d8..d89b38be 100644
--- a/src/Search/Request/ProductRequest/Search.php
+++ b/src/Search/Request/ProductRequest/Search.php
@@ -54,6 +54,8 @@ public function __construct(
protected function addAggregations(Query $query, BoolQuery $postFilter): void
{
+ /** @var array $mustParam */
+ $mustParam = $postFilter->hasParam('must') ? $postFilter->getParam('must') : [];
$aggregations = $this->aggregationBuilder->buildAggregations(
[
'main_taxon',
@@ -61,7 +63,7 @@ protected function addAggregations(Query $query, BoolQuery $postFilter): void
$this->productAttributeRepository->findIsSearchableOrFilterable(),
$this->productOptionRepository->findIsSearchableOrFilterable(),
],
- $postFilter->hasParam('must') ? $postFilter->getParam('must') : []
+ $mustParam
);
foreach ($aggregations as $aggregation) {
diff --git a/src/Search/Request/ProductRequest/Taxon.php b/src/Search/Request/ProductRequest/Taxon.php
index b495e537..7cfa0590 100644
--- a/src/Search/Request/ProductRequest/Taxon.php
+++ b/src/Search/Request/ProductRequest/Taxon.php
@@ -63,6 +63,8 @@ protected function addAggregations(Query $query, Query\BoolQuery $postFilter): v
if (null === $this->configuration) {
throw new RuntimeException('Missing request configuration');
}
+ /** @var array $mustParam */
+ $mustParam = $postFilter->hasParam('must') ? $postFilter->getParam('must') : [];
$aggregations = $this->aggregationBuilder->buildAggregations(
[
['taxons' => $this->configuration->getTaxon()],
@@ -70,7 +72,7 @@ protected function addAggregations(Query $query, Query\BoolQuery $postFilter): v
$this->productAttributeRepository->findIsSearchableOrFilterable(),
$this->productOptionRepository->findIsSearchableOrFilterable(),
],
- $postFilter->hasParam('must') ? $postFilter->getParam('must') : []
+ $mustParam
);
foreach ($aggregations as $aggregation) {
diff --git a/src/Search/Request/RequestConfiguration.php b/src/Search/Request/RequestConfiguration.php
index 50e89ba0..5622cf5f 100644
--- a/src/Search/Request/RequestConfiguration.php
+++ b/src/Search/Request/RequestConfiguration.php
@@ -56,6 +56,7 @@ public function __construct(
public function getQueryText(): string
{
+ /** @phpstan-ignore-next-line */
return trim(urldecode($this->request->get('query', '')));
}
@@ -71,16 +72,19 @@ public function getAppliedFilters(string $type = null): array
public function getSorting(): array
{
+ /** @phpstan-ignore-next-line */
return $this->request->get('sorting', []);
}
public function getPage(): int
{
+ /** @phpstan-ignore-next-line */
return (int) $this->request->get('page', 1);
}
public function getLimit(): int
{
+ /** @phpstan-ignore-next-line */
$limit = (int) $this->request->get('limit', self::FALLBACK_LIMIT);
$availableLimits = $this->getAvailableLimits();
@@ -93,6 +97,7 @@ public function getLimit(): int
public function getAvailableLimits(): array
{
+ /** @var array $configLimits */
$configLimits = $this->searchSettings->getCurrentValue(
$this->channelContext->getChannel(),
null,
@@ -122,6 +127,7 @@ public function getTaxon(): TaxonInterface
throw ObjectNotInstanceOfClassException::fromClassName(TaxonInterface::class);
}
+ /** @phpstan-ignore-next-line */
return $this->parameters->get('taxon');
}
diff --git a/src/Search/Response.php b/src/Search/Response.php
index 399b7fdc..e8751d1b 100644
--- a/src/Search/Response.php
+++ b/src/Search/Response.php
@@ -69,6 +69,7 @@ public function getFilters(): array
public function getPaginator(): Pagerfanta
{
if (null === $this->paginator) {
+ /** @phpstan-ignore-next-line */
$this->paginator = new Pagerfanta($this->adapter);
$this->paginator->setMaxPerPage($this->requestConfiguration->getLimit());
$this->paginator->setCurrentPage($this->requestConfiguration->getPage());
diff --git a/src/Twig/Extension/RenderSearchForm.php b/src/Twig/Extension/RenderSearchForm.php
index 9f2c8a3e..8c3da877 100644
--- a/src/Twig/Extension/RenderSearchForm.php
+++ b/src/Twig/Extension/RenderSearchForm.php
@@ -59,6 +59,7 @@ public function createForm(?string $template = null): Markup
$request = $this->requestStack->getCurrentRequest();
$template = $template ?? '@MonsieurBizSyliusSearchPlugin/Search/_form.html.twig';
+ /** @var string $query */
$query = null !== $request ? $request->get('query', '') : '';
return new Markup($this->templatingEngine->render($template, [