diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml index bb28afe..fbaadcb 100644 --- a/.github/workflows/recipe.yaml +++ b/.github/workflows/recipe.yaml @@ -1,81 +1,87 @@ name: Flex Recipe on: - push: - branches: [ master ] - pull_request: + push: + branches: [ master ] + pull_request: 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'] - sylius: [ "~1.11.0", "~1.12.0"] - - steps: - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: gd, intl, json - ini-values: date.timezone=UTC - - - name: Set project php-version - run: | - echo ${{ matrix.php }} > .php-version - - - uses: actions/checkout@v3 - with: - path: plugin - - - name: Determine composer cache directory - id: composer-cache-directory - working-directory: plugin - run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT - - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - id: cache-composer - with: - 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 }} - - - name: Create Sylius-Standard project without install - run: | - composer create-project --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard sylius "${{ matrix.sylius }}" - - # Because the sylius-standard has a soft constraint - - name: Make sure to install the required version of Sylius - working-directory: ./sylius - run: | - composer require --no-install --no-scripts --no-progress sylius/sylius="${{ matrix.sylius }}" - - - name: Setup some requirements - working-directory: ./sylius - run: | - composer config --no-plugins allow-plugins true - composer config --no-plugins extra.symfony.allow-contrib true - composer config --no-plugins secure-http false - 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 monsieurbiz/sylius-contact-request-plugin="*@dev" + + recipe: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: ['8.0', '8.1', '8.2'] + 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 + + - uses: actions/checkout@v3 + with: + path: plugin + + - name: Determine composer cache directory + id: composer-cache-directory + working-directory: plugin + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies installed with composer + uses: actions/cache@v3 + id: cache-composer + with: + 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 }} + + - name: Create Sylius-Standard project without install + run: | + composer create-project --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard sylius "${{ matrix.sylius }}" + + # Because the sylius-standard has a soft constraint + - name: Make sure to install the required version of Sylius + working-directory: ./sylius + run: | + composer require --no-install --no-scripts --no-progress sylius/sylius="${{ matrix.sylius }}" + + - name: Setup some requirements + working-directory: ./sylius + run: | + composer config --no-plugins allow-plugins true + composer config --no-plugins extra.symfony.allow-contrib true + composer config --no-plugins secure-http false + 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 monsieurbiz/sylius-contact-request-plugin="*@dev" diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index afeeae8..c100cfa 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -1,54 +1,53 @@ name: Security on: - push: - pull_request: + push: + pull_request: jobs: - - security: - - name: Security check (PHP ${{ matrix.php }}) - - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - php: ['8.0', '8.1'] - - steps: - - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - ini-values: date.timezone=UTC - - - name: Set project php-version - run: | - echo ${{ matrix.php }} > .php-version - - - 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: ${{ steps.composer-cache-directory.outputs.directory }} - key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} - restore-keys: composer2-php:${{ matrix.php }}- - - - 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 }} - - - name: Install PHP dependencies - run: composer update --prefer-dist - - - uses: symfonycorp/security-checker-action@v4 + + security: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: ['8.1', '8.2'] + + steps: + - 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 + + - 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: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-${{ github.sha }} + restore-keys: composer2-php:${{ matrix.php }}- + + - 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 }} + + - name: Install PHP dependencies + run: composer update --prefer-dist + + - uses: symfonycorp/security-checker-action@v4 + diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c99f631..877ce6a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,82 +1,79 @@ name: Tests on: - push: - branches: [ master ] - pull_request: + push: + branches: [ master ] + pull_request: jobs: - - php: - - name: Quality tests (PHP ${{ matrix.php }}) - - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - php: ['8.0'] - - env: - SYMFONY_ARGS: --no-tls - COMPOSER_ARGS: --prefer-dist - DOCKER_INTERACTIVE_ARGS: -t - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: '16' - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - ini-values: date.timezone=UTC - - - 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 - - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - id: cache-composer - with: - path: ${{ steps.composer-cache-directory.outputs.directory }} - key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} - restore-keys: composer2-php:${{ matrix.php }}- - - - 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 }} - - - run: make install - - - run: make test.composer - - - run: make test.phpcs - - - run: make test.phpstan - - - run: make test.phpmd - - - run: make test.yaml - - - run: make test.twig - - - run: make test.schema - - - run: make test.container + + php: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: ['8.1', '8.2'] + + env: + SYMFONY_ARGS: --no-tls + COMPOSER_ARGS: --prefer-dist + DOCKER_INTERACTIVE_ARGS: -t + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + 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: 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: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-${{ github.sha }} + restore-keys: composer2-php:${{ matrix.php }}- + + - 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 }} + + - run: make install + + - run: make test.composer + + - run: make test.phpcs + + - run: make test.phpunit + + - run: make test.phpstan + + - run: make test.phpmd + + - run: make test.phpspec + + - run: make test.yaml + + - run: make test.twig + + - run: make test.schema + + - run: make test.container diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index a624ca0..4b4e4e9 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -13,7 +13,9 @@ $header = <<<'HEADER' This file is part of Monsieur Biz' Contact Request plugin for Sylius. + (c) Monsieur Biz + For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code. HEADER; @@ -47,6 +49,7 @@ '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, 'cast_spaces' => true, 'class_attributes_separation' => true, @@ -57,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', ], @@ -83,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', @@ -105,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' => [ @@ -112,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, @@ -151,14 +159,14 @@ '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, @@ -171,6 +179,7 @@ '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' => [ @@ -205,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, @@ -241,6 +252,7 @@ 'elements' => ['arrays'], ], 'trim_array_spaces' => true, + 'type_declaration_spaces' => true, 'unary_operator_spaces' => true, 'visibility_required' => [ 'elements' => [ @@ -250,7 +262,7 @@ ], ], 'void_return' => true, - 'whitespace_after_comma_in_array' => true, // already set in symfony + 'whitespace_after_comma_in_array' => true, // alerady in symfony set ]) ->setFinder($finder) ; diff --git a/.php-version.dist b/.php-version.dist index b293f64..2983cad 100644 --- a/.php-version.dist +++ b/.php-version.dist @@ -1 +1 @@ -8.0 \ No newline at end of file +8.2 diff --git a/Makefile b/Makefile index b4a6ed2..26e2d8e 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,16 @@ .DEFAULT_GOAL := help SHELL=/bin/bash APP_DIR=tests/Application -SYLIUS_VERSION=1.12.0 +SYLIUS_VERSION=1.13.0 SYMFONY=cd ${APP_DIR} && symfony COMPOSER=symfony composer CONSOLE=${SYMFONY} console export COMPOSE_PROJECT_NAME=contact-request +export MIGRATIONS_NAMESPACE=MonsieurBiz\\SyliusContactRequestPlugin\\Migrations +export USER_UID=$(shell id -u) PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin -COMPOSE=docker-compose +COMPOSE=docker compose YARN=yarn -DOCTRINE_MIGRATIONS_NAMESPACE=MonsieurBiz\SyliusContactRequestPlugin\Migrations -DOCTRINE_ORM_CONFLICT_VERSION=">= 2.15.2" ### ### DEVELOPMENT @@ -73,21 +73,20 @@ setup_application: (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"]') -ifdef DOCTRINE_ORM_CONFLICT_VERSION - (cd ${APP_DIR} && cat composer.json | jq --indent 4 '.conflict += {"doctrine/orm": ${DOCTRINE_ORM_CONFLICT_VERSION}}' > composer.json.tmp && mv composer.json.tmp composer.json) -endif (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 $(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-progress monsieurbiz/${PLUGIN_NAME}="*@dev") + (cd ${APP_DIR} && ${COMPOSER} require --no-progress --no-interaction monsieurbiz/${PLUGIN_NAME}="*@dev") 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 # 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 @@ -112,7 +111,7 @@ apply_dist: ### TESTS ### ¯¯¯¯¯ -test.all: test.composer test.phpstan test.phpmd test.phpcs test.yaml test.schema test.twig test.container ## Run all tests in once +test.all: test.composer test.phpstan test.phpmd test.phpunit test.phpspec test.phpcs test.yaml test.schema test.twig test.container ## Run all tests in once test.composer: ## Validate composer.json ${COMPOSER} validate --strict @@ -123,6 +122,12 @@ test.phpstan: ## Run PHPStan test.phpmd: ## Run PHPMD ${COMPOSER} phpmd +test.phpunit: ## Run PHPUnit + ${COMPOSER} phpunit + +test.phpspec: ## Run PHPSpec + ${COMPOSER} phpspec + test.phpcs: ## Run PHP CS Fixer in dry-run ${COMPOSER} run -- phpcs --dry-run -v @@ -133,7 +138,7 @@ test.container: ## Lint the symfony container ${CONSOLE} lint:container test.yaml: ## Lint the symfony Yaml files - ${CONSOLE} lint:yaml ../../recipes ../../src/Resources/config + ${CONSOLE} lint:yaml ../../src/Resources/config --parse-tags test.schema: ## Validate MySQL Schema ${CONSOLE} doctrine:schema:validate @@ -141,12 +146,6 @@ test.schema: ## Validate MySQL Schema test.twig: ## Validate Twig templates ${CONSOLE} lint:twig --no-debug templates/ ../../src/Resources/views/ -### -### SYLIUS -### ¯¯ -doctrine.migration.diff: - ${CONSOLE} doctrine:migrations:diff --namespace="${DOCTRINE_MIGRATIONS_NAMESPACE}" -.PHONY: doctrine.migration.diff ### ### SYLIUS ### ¯¯¯¯¯¯ @@ -170,6 +169,9 @@ sylius.assets: ## Install all assets with symlinks messenger.setup: ## Setup Messenger transports ${CONSOLE} messenger:setup-transports +doctrine.diff: ## Doctrine diff + ${CONSOLE} doctrine:migration:diff --namespace="${MIGRATIONS_NAMESPACE}" + ### ### PLATFORM ### ¯¯¯¯¯¯¯¯ diff --git a/README.md b/README.md index 4248f60..701a750 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,31 @@

Contact Request for Sylius

-[![Contact Request Plugin license](https://img.shields.io/github/license/monsieurbiz/SyliusContactRequestPlugin?public)](https://github.com/monsieurbiz/SyliusContactRequestPlugin/blob/master/LICENSE) -[![Tests Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusContactRequestPlugin/tests.yml?branch=master&logo=github)](https://github.com/monsieurbiz/SyliusContactRequestPlugin/actions?query=workflow%3ATests) -[![Security Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusContactRequestPlugin/security.yml?branch=master&label=security&logo=github)](https://github.com/monsieurbiz/SyliusContactRequestPlugin/actions?query=workflow%3ASecurity) +[![Contact Request Plugin license](https://img.shields.io/github/license/monsieurbiz/SyliusContactRequestPlugin?public)](https://github.com/monsieurbiz/SyliusContactRequestPlugin/blob/master/LICENSE.txt) +[![Tests Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusContactRequestPlugin/tests.yaml?branch=master&logo=github)](https://github.com/monsieurbiz/SyliusContactRequestPlugin/actions?query=workflow%3ATests) +[![Recipe Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusContactRequestPlugin/recipe.yaml?branch=master&label=recipes&logo=github)](https://github.com/monsieurbiz/SyliusContactRequestPlugin/actions?query=workflow%3ASecurity) +[![Security Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusContactRequestPlugin/security.yaml?branch=master&label=security&logo=github)](https://github.com/monsieurbiz/SyliusContactRequestPlugin/actions?query=workflow%3ASecurity) This plugin saves contact requests made on the native form into the database allowing us to see them in the back-office of Sylius. ![Demo of the Contact Request](docs/images/demo1.png) ![Demo of the Contact Request](docs/images/demo2.png) +## Compatibility + +| Sylius Version | PHP Version | +|---|---| +| 1.11 | 8.0 - 8.1 | +| 1.12 | 8.1 - 8.2 | +| 1.13 | 8.1 - 8.2 | + ## Installation -Install the plugin via composer: +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"]' +``` ```bash composer require monsieurbiz/sylius-contact-request-plugin @@ -38,10 +51,18 @@ return [ ]; ``` -Copy the plugin configuration files in your `config` folder: +Create a new file `config/packages/monsieurbiz_sylius_contact_request.yaml` and add the following configuration: -```bash -cp -Rv vendor/monsieurbiz/sylius-contact-request-plugin/recipes/1.0/config/ config +```yaml +imports: + - { resource: "@MonsieurBizSyliusContactRequestPlugin/Resources/config/config.yaml" } +``` + +Create a new file `config/routes/monsieurbiz_sylius_contact_request.yaml` and add the following configuration: + +```yaml +imports: + resource: '@MonsieurBizSyliusContactRequestPlugin/Resources/config/routes.yaml' ``` ## Contributing diff --git a/composer.json b/composer.json index 47d1bda..13f24e1 100644 --- a/composer.json +++ b/composer.json @@ -6,37 +6,16 @@ "license": "MIT", "require": { "php": "^8.0", - "sylius/sylius": ">=1.11 <1.13" + "sylius/sylius": ">=1.11 <1.14" }, "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", - "friends-of-behat/mink": "^1.8", - "friends-of-behat/mink-browserkit-driver": "^1.4", - "friends-of-behat/mink-debug-extension": "^2.0.0", - "friends-of-behat/mink-extension": "^2.4", - "friends-of-behat/page-object-extension": "^0.3", - "friends-of-behat/suite-settings-extension": "^1.0", - "friends-of-behat/symfony-extension": "^2.1", - "friends-of-behat/variadic-extension": "^1.3", - "phpspec/phpspec": "^7.2", - "phpstan/phpstan": "^1.8.1", - "phpstan/phpstan-doctrine": "1.3.37", - "phpstan/phpstan-strict-rules": "^1.3.0", - "phpstan/phpstan-webmozart-assert": "^1.2.0", - "phpunit/phpunit": "^9.5", - "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "sylius-labs/coding-standard": "^4.2", - "symfony/browser-kit": "^5.4 || ^6.0", - "symfony/debug-bundle": "^5.4 || ^6.0", - "symfony/dotenv": "^5.4 || ^6.0", - "symfony/flex": "^2.2.2", - "symfony/intl": "^5.4 || ^6.0", - "symfony/web-profiler-bundle": "^5.4 || ^6.0", - "phpmd/phpmd": "^2.13", - "friendsofphp/php-cs-fixer": "^3.16" + "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": { @@ -49,32 +28,28 @@ "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" }, - "phpcs": "php-cs-fixer fix --using-cache=no", + "phpcs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --using-cache=no", "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": "1.1-dev" + }, "symfony": { "docker": false, - "endpoint": [ - "https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master", - "flex://defaults" - ] - }, - "branch-alias": { - "dev-master": "1.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, - "php-http/discovery": false, - "phpstan/extension-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "ergebnis/composer-normalize": true, + "php-http/discovery": true } } } diff --git a/dist/.env.local b/dist/.env.local new file mode 100644 index 0000000..6c1a99e --- /dev/null +++ b/dist/.env.local @@ -0,0 +1 @@ +SYLIUS_FIXTURES_HOSTNAME=${SYMFONY_DEFAULT_ROUTE_HOST:-localhost} diff --git a/dist/.gitkeep b/dist/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/phpstan.neon b/phpstan.neon index 742ddb7..942036d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,18 +1,15 @@ -includes: - - vendor/phpstan/phpstan-doctrine/extension.neon - - vendor/phpstan/phpstan-webmozart-assert/extension.neon - parameters: - level: max + level: 8 paths: - %rootDir%/src/ - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false - excludePaths: # Makes PHPStan crash - 'src/DependencyInjection/MonsieurBizSyliusContactRequestExtension.php' # Test dependencies - 'tests/Application/**/*' + + ignoreErrors: + - identifier: missingType.generics + - identifier: missingType.iterableValue diff --git a/recipes/1.0-dev b/recipes/1.0-dev deleted file mode 100644 index 9f8e9b6..0000000 --- a/recipes/1.0-dev +++ /dev/null @@ -1 +0,0 @@ -1.0 \ No newline at end of file diff --git a/recipes/1.0/config/manifest.json b/recipes/1.0/config/manifest.json deleted file mode 100644 index 84cf3a9..0000000 --- a/recipes/1.0/config/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bundles": { - "MonsieurBiz\\SyliusContactRequestPlugin\\MonsieurBizSyliusContactRequestPlugin": [ - "all" - ] - }, - "copy-from-recipe": { - "config/": "%CONFIG_DIR%/" - } -} diff --git a/recipes/1.0/config/packages/monsieurbiz_sylius_contact_request_plugin.yaml b/recipes/1.0/config/packages/monsieurbiz_sylius_contact_request_plugin.yaml deleted file mode 100644 index 06f6e05..0000000 --- a/recipes/1.0/config/packages/monsieurbiz_sylius_contact_request_plugin.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@MonsieurBizSyliusContactRequestPlugin/Resources/config/config.yaml" } diff --git a/recipes/1.0/config/routes/monsieurbiz_sylius_contact_request_plugin.yaml b/recipes/1.0/config/routes/monsieurbiz_sylius_contact_request_plugin.yaml deleted file mode 100644 index bcc8f0a..0000000 --- a/recipes/1.0/config/routes/monsieurbiz_sylius_contact_request_plugin.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - resource: '@MonsieurBizSyliusContactRequestPlugin/Resources/config/routes.yaml' diff --git a/src/DependencyInjection/MonsieurBizSyliusContactRequestExtension.php b/src/DependencyInjection/MonsieurBizSyliusContactRequestExtension.php index 8ef9672..325fdc7 100644 --- a/src/DependencyInjection/MonsieurBizSyliusContactRequestExtension.php +++ b/src/DependencyInjection/MonsieurBizSyliusContactRequestExtension.php @@ -2,7 +2,9 @@ /* * This file is part of Monsieur Biz' Contact Request plugin for Sylius. + * * (c) Monsieur Biz + * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ diff --git a/src/EmailManager/DecorateContactEmailManager.php b/src/EmailManager/DecorateContactEmailManager.php index 239715e..e26d07b 100644 --- a/src/EmailManager/DecorateContactEmailManager.php +++ b/src/EmailManager/DecorateContactEmailManager.php @@ -2,7 +2,9 @@ /* * This file is part of Monsieur Biz' Contact Request plugin for Sylius. + * * (c) Monsieur Biz + * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ diff --git a/src/Entity/ContactRequest.php b/src/Entity/ContactRequest.php index b314d78..01843f0 100644 --- a/src/Entity/ContactRequest.php +++ b/src/Entity/ContactRequest.php @@ -2,7 +2,9 @@ /* * This file is part of Monsieur Biz' Contact Request plugin for Sylius. + * * (c) Monsieur Biz + * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ @@ -11,6 +13,7 @@ namespace MonsieurBiz\SyliusContactRequestPlugin\Entity; +use DateTimeInterface; use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Resource\Model\TimestampableTrait; @@ -27,12 +30,12 @@ class ContactRequest implements ContactRequestInterface private ?ChannelInterface $channel; /** - * @var \DateTimeInterface|null + * @var DateTimeInterface|null */ protected $createdAt; /** - * @var \DateTimeInterface|null + * @var DateTimeInterface|null */ protected $updatedAt; @@ -71,22 +74,22 @@ public function setChannel(?ChannelInterface $channel): void $this->channel = $channel; } - public function getCreatedAt(): ?\DateTimeInterface + public function getCreatedAt(): ?DateTimeInterface { return $this->createdAt; } - public function setCreatedAt(?\DateTimeInterface $createdAt): void + public function setCreatedAt(?DateTimeInterface $createdAt): void { $this->createdAt = $createdAt; } - public function getUpdatedAt(): ?\DateTimeInterface + public function getUpdatedAt(): ?DateTimeInterface { return $this->updatedAt; } - public function setUpdatedAt(?\DateTimeInterface $updatedAt): void + public function setUpdatedAt(?DateTimeInterface $updatedAt): void { $this->updatedAt = $updatedAt; } diff --git a/src/Entity/ContactRequestInterface.php b/src/Entity/ContactRequestInterface.php index 59de30f..d2881d8 100644 --- a/src/Entity/ContactRequestInterface.php +++ b/src/Entity/ContactRequestInterface.php @@ -2,7 +2,9 @@ /* * This file is part of Monsieur Biz' Contact Request plugin for Sylius. + * * (c) Monsieur Biz + * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ @@ -11,6 +13,7 @@ namespace MonsieurBiz\SyliusContactRequestPlugin\Entity; +use DateTimeInterface; use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TimestampableInterface; @@ -31,11 +34,11 @@ public function getChannel(): ?ChannelInterface; public function setChannel(?ChannelInterface $channel): void; - public function getCreatedAt(): ?\DateTimeInterface; + public function getCreatedAt(): ?DateTimeInterface; - public function setCreatedAt(?\DateTimeInterface $createdAt): void; + public function setCreatedAt(?DateTimeInterface $createdAt): void; - public function getUpdatedAt(): ?\DateTimeInterface; + public function getUpdatedAt(): ?DateTimeInterface; - public function setUpdatedAt(?\DateTimeInterface $updatedAt): void; + public function setUpdatedAt(?DateTimeInterface $updatedAt): void; } diff --git a/src/Factory/ContactRequestFactory.php b/src/Factory/ContactRequestFactory.php index 5fdda12..e683554 100644 --- a/src/Factory/ContactRequestFactory.php +++ b/src/Factory/ContactRequestFactory.php @@ -2,7 +2,9 @@ /* * This file is part of Monsieur Biz' Contact Request plugin for Sylius. + * * (c) Monsieur Biz + * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ diff --git a/src/Factory/ContactRequestFactoryInterface.php b/src/Factory/ContactRequestFactoryInterface.php index c1b500c..55bb339 100644 --- a/src/Factory/ContactRequestFactoryInterface.php +++ b/src/Factory/ContactRequestFactoryInterface.php @@ -2,7 +2,9 @@ /* * This file is part of Monsieur Biz' Contact Request plugin for Sylius. + * * (c) Monsieur Biz + * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ diff --git a/src/Menu/AdminMenuListener.php b/src/Menu/AdminMenuListener.php index 3471ecb..a12cf77 100644 --- a/src/Menu/AdminMenuListener.php +++ b/src/Menu/AdminMenuListener.php @@ -2,7 +2,9 @@ /* * This file is part of Monsieur Biz' Contact Request plugin for Sylius. + * * (c) Monsieur Biz + * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ diff --git a/src/Migrations/Version20230623133601.php b/src/Migrations/Version20230623133601.php index 882a8ba..1aaf535 100644 --- a/src/Migrations/Version20230623133601.php +++ b/src/Migrations/Version20230623133601.php @@ -2,7 +2,9 @@ /* * This file is part of Monsieur Biz' Contact Request plugin for Sylius. + * * (c) Monsieur Biz + * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ diff --git a/src/MonsieurBizSyliusContactRequestPlugin.php b/src/MonsieurBizSyliusContactRequestPlugin.php index 949d18c..3665849 100644 --- a/src/MonsieurBizSyliusContactRequestPlugin.php +++ b/src/MonsieurBizSyliusContactRequestPlugin.php @@ -2,7 +2,9 @@ /* * This file is part of Monsieur Biz' Contact Request plugin for Sylius. + * * (c) Monsieur Biz + * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ @@ -11,6 +13,7 @@ namespace MonsieurBiz\SyliusContactRequestPlugin; +use LogicException; use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -22,7 +25,7 @@ final class MonsieurBizSyliusContactRequestPlugin extends Bundle /** * Returns the plugin's container extension. * - * @throws \LogicException + * @throws LogicException * * @return ExtensionInterface|null The container extension */ diff --git a/tests/Behat/DemoContext.php b/tests/Behat/DemoContext.php index 63b6421..6e39262 100644 --- a/tests/Behat/DemoContext.php +++ b/tests/Behat/DemoContext.php @@ -2,7 +2,9 @@ /* * This file is part of Monsieur Biz' Contact Request plugin for Sylius. + * * (c) Monsieur Biz + * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ @@ -12,6 +14,7 @@ namespace App\Tests\Behat; use Behat\Behat\Context\Context; +use RuntimeException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\KernelInterface; @@ -49,7 +52,7 @@ public function aDemoScenarioSendsARequestTo(string $path): void public function theResponseShouldBeReceived(): void { if (null === $this->response) { - throw new \RuntimeException('No response received'); + throw new RuntimeException('No response received'); } } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index b175818..2ee5cb0 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,9 @@ /* * This file is part of Monsieur Biz' Contact Request plugin for Sylius. + * * (c) Monsieur Biz + * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */