diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a12f95e..a1a290f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,21 +17,17 @@ env: jobs: tests: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest - name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}" + name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}, Sylius ${{ matrix.sylius }}" strategy: fail-fast: false matrix: - php: [7.4, 7.3] + php: [8.1, 8.2, 8.3] node: [10.x] mysql: [5.7, 8.0] - - exclude: - - # PHP 7.3 does not support "caching_sha2_password" authentication plugin which is a default one in MySQL 8.0 - php: 7.3 - mysql: 8.0 + sylius: [1.13.*, 1.14.*] env: APP_ENV: test @@ -39,7 +35,7 @@ jobs: steps: - - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP @@ -52,7 +48,7 @@ jobs: - name: Setup Node - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: "${{ matrix.node }}" @@ -79,10 +75,6 @@ jobs: name: Run Chrome Headless run: google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 & - - - name: Run webserver - run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon) - - name: Get Composer cache directory id: composer-cache @@ -90,13 +82,17 @@ jobs: - name: Cache Composer - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }} restore-keys: | ${{ runner.os }}-php-${{ matrix.php }}-composer- + - + name: Require Sylius version + run: composer require sylius/sylius:"${{ matrix.sylius }}" --no-update + - name: Install PHP dependencies run: composer install --no-interaction @@ -108,57 +104,21 @@ jobs: - name: Cache Yarn - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.yarn-cache.outputs.dir }} key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }} restore-keys: | ${{ runner.os }}-node-${{ matrix.node }}-yarn- - - - name: Install JS dependencies - run: (cd tests/Application && yarn install) - - - - name: Prepare test application database - run: | - (cd tests/Application && bin/console doctrine:database:create -vvv) - (cd tests/Application && bin/console doctrine:schema:create -vvv) - - - - name: Prepare test application assets - run: | - (cd tests/Application && bin/console assets:install public -vvv) - (cd tests/Application && yarn build) - - - - name: Prepare test application cache - run: (cd tests/Application && bin/console cache:warmup -vvv) - - - - name: Load fixtures in test application - run: (cd tests/Application && bin/console sylius:fixtures:load -n) - - name: Validate composer.json run: composer validate --ansi --strict - - name: Validate database schema - run: (cd tests/Application && bin/console doctrine:schema:validate) - - - - name: Run php-cs-fixer + name: Run php-cs-fixer run: vendor/bin/php-cs-fixer fix --verbose --diff --dry-run - name: Run PHPStan run: vendor/bin/phpstan analyse -c phpstan.neon -l max src/ - - - - name: Run PHPSpec - run: vendor/bin/phpspec run --ansi -f progress --no-interaction - - - - name: Run PHPUnit - run: vendor/bin/phpunit --colors=always diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 7472207..7d1f0a2 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: include: - - php-version: '7.4' + - php-version: '8.2' dependency-versions: 'highest' php-extensions: 'ctype, iconv, mysql, imagick' tools: 'composer:v2' @@ -38,7 +38,7 @@ jobs: steps: - name: Checkout project - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install and configure PHP uses: shivammathur/setup-php@v2 @@ -49,7 +49,7 @@ jobs: coverage: none - name: Install composer dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v3 with: dependency-versions: ${{matrix.dependency-versions}} diff --git a/.gitignore b/.gitignore index 3be0f03..c2108dd 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ .idea .php_cs.cache +.php-cs-fixer.cache diff --git a/composer.json b/composer.json index 17b9120..c5230ef 100644 --- a/composer.json +++ b/composer.json @@ -5,17 +5,17 @@ "description": "Producer for synchronization products with sulu.", "license": "MIT", "require": { - "php": "^7.3|^8.0", + "php": "^8.1", - "sylius/sylius": "^1.8", - "symfony/messenger": "^4.4|^5.0", - "symfony/config": "^4.4|^5.0", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/http-kernel": "^4.4|^5.0", - "symfony/serializer": "^4.4|^5.0" + "sylius/sylius": "1.13.* || 1.14.*", + "symfony/messenger": "^5.4 || ^6.4", + "symfony/config": "^5.4 || ^6.4", + "symfony/dependency-injection": "^5.4 || ^6.4", + "symfony/http-kernel": "^5.4 || ^6.4", + "symfony/serializer": "^5.4 || ^6.4" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.15", + "friendsofphp/php-cs-fixer": "^2.15 || ^3.0", "phpstan/phpstan": "^1.0", "phpstan/phpstan-doctrine": "^1.0", "phpstan/phpstan-phpunit": "^1.0", @@ -23,14 +23,12 @@ "phpstan/phpstan-webmozart-assert": "^1.0", "jangregor/phpstan-prophecy": "^1.0", "thecodingmachine/phpstan-strict-rules": "^1.0", - "phpunit/phpunit": "^8.2", - "symfony/browser-kit": "^4.4 || ^5.0", - "symfony/dotenv": "^4.4 || ^5.0", + "phpunit/phpunit": "^9.5", + "symfony/browser-kit": "^5.4 || ^6.4", + "symfony/dotenv": "^5.4 || ^6.4", "phpstan/extension-installer": "^1.0", - "sensiolabs/security-checker": "^6.0", - "symfony/intl": "^4.4 || ^5.0", - "symfony/web-profiler-bundle": "^4.4 || ^5.0", - "symfony/web-server-bundle": "^4.4 || ^5.0" + "symfony/intl": "^5.4 || ^6.4", + "symfony/web-profiler-bundle": "^5.4 || ^6.4" }, "autoload": { "psr-4": { @@ -40,7 +38,10 @@ } }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "phpstan/extension-installer": false + } }, "scripts": { "post-install-cmd": [ diff --git a/phpstan.neon b/phpstan.neon index bcc2338..e33e675 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,7 +5,6 @@ parameters: parallel: processTimeout: 300.0 reportUnmatchedIgnoredErrors: false - checkMissingIterableValueType: false excludePaths: - %currentWorkingDirectory%/DependencyInjection/Configuration.php @@ -14,3 +13,8 @@ parameters: ignoreErrors: - '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./' + - '/Call to an undefined method Sylius\\Component\\User\\Model\\UserInterface\:\:isAccountNonExpired\(\)\./' + - '/Call to an undefined method Sylius\\Component\\User\\Model\\UserInterface\:\:isAccountNonLocked\(\)\./' + - '/Call to an undefined method Sylius\\Component\\User\\Model\\UserInterface\:\:isCredentialsNonExpired\(\)\./' + - + identifier: missingType.iterableValue diff --git a/src/Command/BaseSynchronizeCommand.php b/src/Command/BaseSynchronizeCommand.php index 455cd41..c038439 100644 --- a/src/Command/BaseSynchronizeCommand.php +++ b/src/Command/BaseSynchronizeCommand.php @@ -20,7 +20,7 @@ abstract class BaseSynchronizeCommand extends Command { - const BULK_SIZE = 50; + public const BULK_SIZE = 50; /** * @var EntityManagerInterface diff --git a/src/Command/SynchronizeProductVariantsCommand.php b/src/Command/SynchronizeProductVariantsCommand.php index 2cfd214..585621c 100644 --- a/src/Command/SynchronizeProductVariantsCommand.php +++ b/src/Command/SynchronizeProductVariantsCommand.php @@ -23,31 +23,13 @@ class SynchronizeProductVariantsCommand extends BaseSynchronizeCommand { - /** - * @var EntityManagerInterface - */ - private $entityManager; - - /** - * @var ProductVariantMessageProducerInterface - */ - private $productVariantMessageProducer; - - /** - * @var ProductVariantRepositoryInterface - */ - private $productVariantRepository; - + /** @param ProductVariantRepositoryInterface $productVariantRepository */ public function __construct( - EntityManagerInterface $entityManager, - ProductVariantMessageProducerInterface $productVariantMessageProducer, - ProductVariantRepositoryInterface $productVariantRepository + private EntityManagerInterface $entityManager, + private ProductVariantMessageProducerInterface $productVariantMessageProducer, + private ProductVariantRepositoryInterface $productVariantRepository, ) { parent::__construct($entityManager); - - $this->entityManager = $entityManager; - $this->productVariantMessageProducer = $productVariantMessageProducer; - $this->productVariantRepository = $productVariantRepository; } protected function configure(): void diff --git a/src/Command/SynchronizeProductsCommand.php b/src/Command/SynchronizeProductsCommand.php index 6d96c42..8c0b0f3 100644 --- a/src/Command/SynchronizeProductsCommand.php +++ b/src/Command/SynchronizeProductsCommand.php @@ -23,31 +23,13 @@ class SynchronizeProductsCommand extends BaseSynchronizeCommand { - /** - * @var EntityManagerInterface - */ - private $entityManager; - - /** - * @var ProductMessageProducerInterface - */ - private $productMessageProducer; - - /** - * @var ProductRepositoryInterface - */ - private $productRepository; - + /** @param ProductRepositoryInterface $productRepository */ public function __construct( - EntityManagerInterface $entityManager, - ProductMessageProducerInterface $productMessageProducer, - ProductRepositoryInterface $productRepository + private EntityManagerInterface $entityManager, + private ProductMessageProducerInterface $productMessageProducer, + private ProductRepositoryInterface $productRepository, ) { parent::__construct($entityManager); - - $this->entityManager = $entityManager; - $this->productMessageProducer = $productMessageProducer; - $this->productRepository = $productRepository; } protected function configure(): void diff --git a/src/Command/SynchronizeTaxonCommand.php b/src/Command/SynchronizeTaxonCommand.php index 8b396a0..318bf77 100644 --- a/src/Command/SynchronizeTaxonCommand.php +++ b/src/Command/SynchronizeTaxonCommand.php @@ -22,31 +22,13 @@ class SynchronizeTaxonCommand extends BaseSynchronizeCommand { - /** - * @var EntityManagerInterface - */ - private $entityManager; - - /** - * @var TaxonMessageProducerInterface - */ - private $taxonMessageProducer; - - /** - * @var TaxonRepositoryInterface - */ - private $taxonRepository; - + /** @param TaxonRepositoryInterface $taxonRepository */ public function __construct( - EntityManagerInterface $entityManager, - TaxonMessageProducerInterface $taxonMessageProducer, - TaxonRepositoryInterface $taxonRepository + private EntityManagerInterface $entityManager, + private TaxonMessageProducerInterface $taxonMessageProducer, + private TaxonRepositoryInterface $taxonRepository, ) { parent::__construct($entityManager); - - $this->entityManager = $entityManager; - $this->taxonMessageProducer = $taxonMessageProducer; - $this->taxonRepository = $taxonRepository; } protected function configure(): void diff --git a/src/Producer/ProductMessageProducer.php b/src/Producer/ProductMessageProducer.php index dc713f1..df452db 100644 --- a/src/Producer/ProductMessageProducer.php +++ b/src/Producer/ProductMessageProducer.php @@ -33,7 +33,7 @@ class ProductMessageProducer implements ProductMessageProducerInterface public function __construct( ProductSerializerInterface $productSerializer, - MessageBusInterface $messageBus + MessageBusInterface $messageBus, ) { $this->productSerializer = $productSerializer; $this->messageBus = $messageBus;