From 3384d30d04ae6789c46fe08548d5b2d6bdb8607b Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 9 Dec 2020 13:34:21 +0100 Subject: [PATCH 01/55] Allow for Symfony ^4.4 || ^5.2 --- composer.json | 76 +++++++++---------- .../Bundle/AddressingBundle/composer.json | 12 +-- .../Bundle/AdminApiBundle/composer.json | 8 +- src/Sylius/Bundle/AdminBundle/composer.json | 4 +- src/Sylius/Bundle/ApiBundle/composer.json | 2 +- .../Bundle/AttributeBundle/composer.json | 8 +- src/Sylius/Bundle/ChannelBundle/composer.json | 8 +- src/Sylius/Bundle/CoreBundle/composer.json | 10 +-- .../Bundle/CurrencyBundle/composer.json | 12 +-- .../Bundle/CustomerBundle/composer.json | 8 +- .../Bundle/InventoryBundle/composer.json | 10 +-- src/Sylius/Bundle/LocaleBundle/composer.json | 8 +- src/Sylius/Bundle/MoneyBundle/composer.json | 12 +-- src/Sylius/Bundle/OrderBundle/composer.json | 10 +-- src/Sylius/Bundle/PaymentBundle/composer.json | 6 +- src/Sylius/Bundle/PayumBundle/composer.json | 2 +- src/Sylius/Bundle/ProductBundle/composer.json | 10 +-- .../Bundle/PromotionBundle/composer.json | 10 +-- src/Sylius/Bundle/ReviewBundle/composer.json | 12 +-- .../Bundle/ShippingBundle/composer.json | 10 +-- src/Sylius/Bundle/ShopBundle/composer.json | 6 +- .../Bundle/TaxationBundle/composer.json | 8 +- .../Bundle/TaxonomyBundle/composer.json | 4 +- src/Sylius/Bundle/UiBundle/composer.json | 14 ++-- src/Sylius/Bundle/UserBundle/composer.json | 6 +- src/Sylius/Component/Addressing/composer.json | 2 +- src/Sylius/Component/Attribute/composer.json | 2 +- src/Sylius/Component/Channel/composer.json | 4 +- src/Sylius/Component/Core/composer.json | 4 +- src/Sylius/Component/Currency/composer.json | 2 +- src/Sylius/Component/Locale/composer.json | 2 +- src/Sylius/Component/Shipping/composer.json | 2 +- src/Sylius/Component/User/composer.json | 2 +- symfony.lock | 15 ++-- 34 files changed, 157 insertions(+), 154 deletions(-) diff --git a/composer.json b/composer.json index bd00148700..ee9ced3c7b 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "behat/transliterator": "^1.3", "doctrine/collections": "^1.6", "doctrine/doctrine-bundle": "^1.12 || ^2.0", - "doctrine/doctrine-migrations-bundle": "^3.0", + "doctrine/doctrine-migrations-bundle": "^3.0.1", "doctrine/inflector": "^1.4 || ^2.0", "doctrine/migrations": "^3.0", "doctrine/orm": "^2.7", @@ -53,7 +53,7 @@ "sonata-project/block-bundle": "^4.2", "stof/doctrine-extensions-bundle": "^1.4", "swiftmailer/swiftmailer": "^6.2", - "sylius-labs/association-hydrator": "^1.1", + "sylius-labs/association-hydrator": "^1.1.2", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3", "sylius/fixtures-bundle": "^1.6.1", "sylius/grid": "^1.8", @@ -64,45 +64,45 @@ "sylius/resource": "^1.7", "sylius/resource-bundle": "^1.7", "sylius/theme-bundle": "^2.1", - "symfony/asset": "^4.4", - "symfony/config": "^4.4", - "symfony/console": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/doctrine-bridge": "^4.4", - "symfony/event-dispatcher": "^4.4", - "symfony/expression-language": "^4.4", - "symfony/filesystem": "^4.4", - "symfony/finder": "^4.4", - "symfony/form": "^4.4", - "symfony/framework-bundle": "^4.4", - "symfony/http-foundation": "^4.4", - "symfony/http-kernel": "^4.4", - "symfony/intl": "^4.4", - "symfony/messenger": "^4.4", + "symfony/asset": "^4.4 || ^5.2", + "symfony/config": "^4.4 || ^5.2", + "symfony/console": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/doctrine-bridge": "^4.4 || ^5.2", + "symfony/event-dispatcher": "^4.4 || ^5.2", + "symfony/expression-language": "^4.4 || ^5.2", + "symfony/filesystem": "^4.4 || ^5.2", + "symfony/finder": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2", + "symfony/framework-bundle": "^4.4 || ^5.2", + "symfony/http-foundation": "^4.4 || ^5.2", + "symfony/http-kernel": "^4.4 || ^5.2", + "symfony/intl": "^4.4 || ^5.2", + "symfony/messenger": "^4.4 || ^5.2", "symfony/monolog-bundle": "^3.5", - "symfony/options-resolver": "^4.4", + "symfony/options-resolver": "^4.4 || ^5.2", "symfony/polyfill-iconv": "^1.17", "symfony/polyfill-intl-icu": "^1.17", "symfony/polyfill-mbstring": "^1.17", "symfony/polyfill-php80": "^1.17", - "symfony/process": "^4.4", - "symfony/property-access": "^4.4", - "symfony/property-info": "^4.4", - "symfony/proxy-manager-bridge": "^4.4", - "symfony/routing": "^4.4", - "symfony/security-bundle": "^4.4", - "symfony/security-core": "^4.4", - "symfony/security-csrf": "^4.4", - "symfony/security-guard": "^4.4", - "symfony/security-http": "^4.4", - "symfony/serializer": "^4.4", + "symfony/process": "^4.4 || ^5.2", + "symfony/property-access": "^4.4 || ^5.2", + "symfony/property-info": "^4.4 || ^5.2", + "symfony/proxy-manager-bridge": "^4.4 || ^5.2", + "symfony/routing": "^4.4 || ^5.2", + "symfony/security-bundle": "^4.4 || ^5.2", + "symfony/security-core": "^4.4 || ^5.2", + "symfony/security-csrf": "^4.4 || ^5.2", + "symfony/security-guard": "^4.4 || ^5.2", + "symfony/security-http": "^4.4 || ^5.2", + "symfony/serializer": "^4.4 || ^5.2", "symfony/swiftmailer-bundle": "^3.4", - "symfony/templating": "^4.4", + "symfony/templating": "^4.4 || ^5.2", "symfony/thanks": "^1.2", - "symfony/translation": "^4.4", - "symfony/twig-bundle": "^4.4", - "symfony/validator": "^4.4", - "symfony/yaml": "^4.4", + "symfony/translation": "^4.4 || ^5.2", + "symfony/twig-bundle": "^4.4 || ^5.2", + "symfony/validator": "^4.4 || ^5.2", + "symfony/yaml": "^4.4 || ^5.2", "twig/intl-extra": "^2.12", "twig/twig": "^2.12", "webmozart/assert": "^1.9", @@ -187,11 +187,11 @@ "sspooky13/yaml-standards": "^5.1", "stripe/stripe-php": "^6.43", "sylius-labs/coding-standard": "^3.1", - "symfony/browser-kit": "^4.4", - "symfony/debug-bundle": "^4.4", - "symfony/dotenv": "^4.4", + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/debug-bundle": "^4.4 || ^5.2", + "symfony/dotenv": "^4.4 || ^5.2", "symfony/flex": "^1.7", - "symfony/web-profiler-bundle": "^4.4", + "symfony/web-profiler-bundle": "^4.4 || ^5.2", "symplify/package-builder": "^8.0 <8.3", "vimeo/psalm": "4.4.1" }, diff --git a/src/Sylius/Bundle/AddressingBundle/composer.json b/src/Sylius/Bundle/AddressingBundle/composer.json index 251f15740c..c2f212a0d0 100644 --- a/src/Sylius/Bundle/AddressingBundle/composer.json +++ b/src/Sylius/Bundle/AddressingBundle/composer.json @@ -30,8 +30,8 @@ "stof/doctrine-extensions-bundle": "^1.4", "sylius/addressing": "^1.6", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4", - "symfony/intl": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2", + "symfony/intl": "^4.4 || ^5.2" }, "conflict": { "twig/twig": "^1.0 || ^3.0" @@ -41,10 +41,10 @@ "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4", - "symfony/validator": "^4.4" + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2", + "symfony/validator": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/AdminApiBundle/composer.json b/src/Sylius/Bundle/AdminApiBundle/composer.json index 44c81ad141..75ecfc1433 100644 --- a/src/Sylius/Bundle/AdminApiBundle/composer.json +++ b/src/Sylius/Bundle/AdminApiBundle/composer.json @@ -27,9 +27,9 @@ "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3", "sylius/core-bundle": "^1.6", - "symfony/form": "^4.4", - "symfony/framework-bundle": "^4.4", - "symfony/validator": "^4.4" + "symfony/form": "^4.4 || ^5.2", + "symfony/framework-bundle": "^4.4 || ^5.2", + "symfony/validator": "^4.4 || ^5.2" }, "require-dev": { "doctrine/doctrine-bundle": "^1.12 || ^2.0", @@ -38,7 +38,7 @@ "matthiasnoback/symfony-dependency-injection-test": "^4.2", "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", - "symfony/dependency-injection": "^4.4", + "symfony/dependency-injection": "^4.4 || ^5.2", "twig/twig": "^2.12" }, "config": { diff --git a/src/Sylius/Bundle/AdminBundle/composer.json b/src/Sylius/Bundle/AdminBundle/composer.json index bc7d34a26f..b7048755eb 100644 --- a/src/Sylius/Bundle/AdminBundle/composer.json +++ b/src/Sylius/Bundle/AdminBundle/composer.json @@ -33,14 +33,14 @@ "php": "^7.3", "sylius/core-bundle": "^1.6", "sylius/ui-bundle": "^1.6", - "symfony/framework-bundle": "^4.4", + "symfony/framework-bundle": "^4.4 || ^5.2", "twig/intl-extra": "^2.12", "twig/twig": "^2.12" }, "require-dev": { "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", - "symfony/dependency-injection": "^4.4" + "symfony/dependency-injection": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/ApiBundle/composer.json b/src/Sylius/Bundle/ApiBundle/composer.json index 559cc0f098..8045baeca4 100644 --- a/src/Sylius/Bundle/ApiBundle/composer.json +++ b/src/Sylius/Bundle/ApiBundle/composer.json @@ -26,7 +26,7 @@ "php": "^7.3", "api-platform/core": "^2.5", "sylius/core-bundle": "^1.7", - "symfony/messenger": "^4.4" + "symfony/messenger": "^4.4 || ^5.2" }, "require-dev": { "matthiasnoback/symfony-config-test": "^4.2", diff --git a/src/Sylius/Bundle/AttributeBundle/composer.json b/src/Sylius/Bundle/AttributeBundle/composer.json index 9936beeb26..94d95af091 100644 --- a/src/Sylius/Bundle/AttributeBundle/composer.json +++ b/src/Sylius/Bundle/AttributeBundle/composer.json @@ -31,15 +31,15 @@ "stof/doctrine-extensions-bundle": "^1.4", "sylius/attribute": "^1.6", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2" }, "require-dev": { "doctrine/orm": "^2.7", "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4" + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/ChannelBundle/composer.json b/src/Sylius/Bundle/ChannelBundle/composer.json index 4478dfc729..258c6fba69 100644 --- a/src/Sylius/Bundle/ChannelBundle/composer.json +++ b/src/Sylius/Bundle/ChannelBundle/composer.json @@ -28,7 +28,7 @@ "php": "^7.3", "sylius/channel": "^1.6", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2" }, "require-dev": { "doctrine/orm": "^2.7", @@ -36,9 +36,9 @@ "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4", + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2", "twig/twig": "^2.12" }, "config": { diff --git a/src/Sylius/Bundle/CoreBundle/composer.json b/src/Sylius/Bundle/CoreBundle/composer.json index ae187644e5..fd4984cd24 100644 --- a/src/Sylius/Bundle/CoreBundle/composer.json +++ b/src/Sylius/Bundle/CoreBundle/composer.json @@ -62,11 +62,11 @@ "sylius/theme-bundle": "^2.1", "sylius/ui-bundle": "^1.6", "sylius/user-bundle": "^1.6", - "symfony/framework-bundle": "^4.4", - "symfony/intl": "^4.4", - "symfony/messenger": "^4.4", + "symfony/framework-bundle": "^4.4 || ^5.2", + "symfony/intl": "^4.4 || ^5.2", + "symfony/messenger": "^4.4 || ^5.2", "symfony/swiftmailer-bundle": "^3.4", - "symfony/templating": "^4.4", + "symfony/templating": "^4.4 || ^5.2", "winzou/state-machine-bundle": "^0.5" }, "require-dev": { @@ -76,7 +76,7 @@ "matthiasnoback/symfony-dependency-injection-test": "^4.2", "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", - "symfony/dependency-injection": "^4.4" + "symfony/dependency-injection": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/CurrencyBundle/composer.json b/src/Sylius/Bundle/CurrencyBundle/composer.json index 44d71f2013..47871215ff 100644 --- a/src/Sylius/Bundle/CurrencyBundle/composer.json +++ b/src/Sylius/Bundle/CurrencyBundle/composer.json @@ -28,9 +28,9 @@ "php": "^7.3", "sylius/currency": "^1.6", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4", - "symfony/intl": "^4.4", - "symfony/templating": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2", + "symfony/intl": "^4.4 || ^5.2", + "symfony/templating": "^4.4 || ^5.2" }, "conflict": { "twig/twig": "^1.0" @@ -40,9 +40,9 @@ "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4", + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2", "twig/twig": "^2.12" }, "config": { diff --git a/src/Sylius/Bundle/CustomerBundle/composer.json b/src/Sylius/Bundle/CustomerBundle/composer.json index bfadef92eb..e24851b7f6 100644 --- a/src/Sylius/Bundle/CustomerBundle/composer.json +++ b/src/Sylius/Bundle/CustomerBundle/composer.json @@ -40,7 +40,7 @@ "egulias/email-validator": "^2.1", "sylius/customer": "^1.6", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4", + "symfony/framework-bundle": "^4.4 || ^5.2", "webmozart/assert": "^1.8" }, "conflict": { @@ -50,9 +50,9 @@ "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4" + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/InventoryBundle/composer.json b/src/Sylius/Bundle/InventoryBundle/composer.json index 4879030a73..ab7a1de053 100644 --- a/src/Sylius/Bundle/InventoryBundle/composer.json +++ b/src/Sylius/Bundle/InventoryBundle/composer.json @@ -29,9 +29,9 @@ "php": "^7.3", "sylius/inventory": "^1.6", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4", - "symfony/templating": "^4.4", - "symfony/validator": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2", + "symfony/templating": "^4.4 || ^5.2", + "symfony/validator": "^4.4 || ^5.2" }, "conflict": { "twig/twig": "^1.0" @@ -41,8 +41,8 @@ "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", "twig/twig": "^2.12" }, "config": { diff --git a/src/Sylius/Bundle/LocaleBundle/composer.json b/src/Sylius/Bundle/LocaleBundle/composer.json index 480a4dea6b..ac9de64cb7 100644 --- a/src/Sylius/Bundle/LocaleBundle/composer.json +++ b/src/Sylius/Bundle/LocaleBundle/composer.json @@ -29,8 +29,8 @@ "php": "^7.3", "sylius/locale": "^1.6", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4", - "symfony/templating": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2", + "symfony/templating": "^4.4 || ^5.2" }, "conflict": { "twig/twig": "^1.0" @@ -41,8 +41,8 @@ "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", "twig/twig": "^2.12" }, "config": { diff --git a/src/Sylius/Bundle/MoneyBundle/composer.json b/src/Sylius/Bundle/MoneyBundle/composer.json index 98bc46457f..583de72cb2 100644 --- a/src/Sylius/Bundle/MoneyBundle/composer.json +++ b/src/Sylius/Bundle/MoneyBundle/composer.json @@ -27,9 +27,9 @@ "require": { "php": "^7.3", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4", - "symfony/intl": "^4.4", - "symfony/templating": "^4.4", + "symfony/framework-bundle": "^4.4 || ^5.2", + "symfony/intl": "^4.4 || ^5.2", + "symfony/templating": "^4.4 || ^5.2", "webmozart/assert": "^1.8" }, "conflict": { @@ -41,9 +41,9 @@ "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", "sylius/currency-bundle": "^1.6", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4", + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2", "twig/twig": "^2.12" }, "config": { diff --git a/src/Sylius/Bundle/OrderBundle/composer.json b/src/Sylius/Bundle/OrderBundle/composer.json index 4a385cfe4e..ffe0a538e4 100644 --- a/src/Sylius/Bundle/OrderBundle/composer.json +++ b/src/Sylius/Bundle/OrderBundle/composer.json @@ -32,8 +32,8 @@ "sylius/money-bundle": "^1.6", "sylius/order": "^1.6", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4", - "symfony/templating": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2", + "symfony/templating": "^4.4 || ^5.2" }, "conflict": { "twig/twig": "^1.0 || ^3.0" @@ -43,9 +43,9 @@ "matthiasnoback/symfony-dependency-injection-test": "^4.1", "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", - "symfony/browser-kit": "^4.4", - "symfony/form": "^4.4", - "symfony/validator": "^4.4" + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2", + "symfony/validator": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/PaymentBundle/composer.json b/src/Sylius/Bundle/PaymentBundle/composer.json index 307b7ba538..f90bc4565e 100644 --- a/src/Sylius/Bundle/PaymentBundle/composer.json +++ b/src/Sylius/Bundle/PaymentBundle/composer.json @@ -29,7 +29,7 @@ "php": "^7.3", "sylius/payment": "^1.6", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2" }, "conflict": { "twig/twig": "^3.0" @@ -41,8 +41,8 @@ "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", "sylius/locale-bundle": "^1.6", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4" + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/PayumBundle/composer.json b/src/Sylius/Bundle/PayumBundle/composer.json index 6f25c83a93..b1c344f4b0 100644 --- a/src/Sylius/Bundle/PayumBundle/composer.json +++ b/src/Sylius/Bundle/PayumBundle/composer.json @@ -40,7 +40,7 @@ }, "require-dev": { "phpspec/phpspec": "^7.0", - "symfony/dependency-injection": "^4.4" + "symfony/dependency-injection": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/ProductBundle/composer.json b/src/Sylius/Bundle/ProductBundle/composer.json index e1e0aa04c6..4e8ff7c914 100644 --- a/src/Sylius/Bundle/ProductBundle/composer.json +++ b/src/Sylius/Bundle/ProductBundle/composer.json @@ -32,17 +32,17 @@ "sylius/locale-bundle": "^1.6", "sylius/product": "^1.6", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2" }, "require-dev": { "doctrine/orm": "^2.7", "mockery/mockery": "^1.4", "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4", - "symfony/validator": "^4.4" + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2", + "symfony/validator": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/PromotionBundle/composer.json b/src/Sylius/Bundle/PromotionBundle/composer.json index 57f2ac162d..bd4209a41e 100644 --- a/src/Sylius/Bundle/PromotionBundle/composer.json +++ b/src/Sylius/Bundle/PromotionBundle/composer.json @@ -33,7 +33,7 @@ "sylius/promotion": "^1.6", "sylius/registry": "^1.5", "sylius/resource-bundle": "^1.7", - "symfony/framework-bundle": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2" }, "conflict": { "twig/twig": "^3.0" @@ -44,10 +44,10 @@ "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4", - "symfony/validator": "^4.4" + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2", + "symfony/validator": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/ReviewBundle/composer.json b/src/Sylius/Bundle/ReviewBundle/composer.json index e46c7bc289..1b8597f1f0 100644 --- a/src/Sylius/Bundle/ReviewBundle/composer.json +++ b/src/Sylius/Bundle/ReviewBundle/composer.json @@ -44,7 +44,7 @@ "sylius/resource-bundle": "^1.7", "sylius/review": "^1.6", "sylius/user-bundle": "^1.6", - "symfony/framework-bundle": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2" }, "conflict": { "twig/twig": "^3.0" @@ -53,12 +53,12 @@ "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4", - "symfony/security-bundle": "^4.4", + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2", + "symfony/security-bundle": "^4.4 || ^5.2", "symfony/swiftmailer-bundle": "^3.1", - "symfony/validator": "^4.4" + "symfony/validator": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/ShippingBundle/composer.json b/src/Sylius/Bundle/ShippingBundle/composer.json index 5ffc36b54c..56a1159827 100644 --- a/src/Sylius/Bundle/ShippingBundle/composer.json +++ b/src/Sylius/Bundle/ShippingBundle/composer.json @@ -33,7 +33,7 @@ "sylius/money-bundle": "^1.6", "sylius/resource-bundle": "^1.7", "sylius/shipping": "^1.6", - "symfony/framework-bundle": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2" }, "conflict": { "twig/twig": "^3.0" @@ -44,10 +44,10 @@ "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4", - "symfony/validator": "^4.4" + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2", + "symfony/validator": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/ShopBundle/composer.json b/src/Sylius/Bundle/ShopBundle/composer.json index 0c881babe0..e0714e5095 100644 --- a/src/Sylius/Bundle/ShopBundle/composer.json +++ b/src/Sylius/Bundle/ShopBundle/composer.json @@ -29,8 +29,8 @@ "php": "^7.3", "sylius/core-bundle": "^1.6", "sylius/ui-bundle": "^1.6", - "symfony/framework-bundle": "^4.4", - "symfony/security-bundle": "^4.4", + "symfony/framework-bundle": "^4.4 || ^5.2", + "symfony/security-bundle": "^4.4 || ^5.2", "twig/intl-extra": "^2.12", "twig/twig": "^2.12" }, @@ -40,7 +40,7 @@ "mockery/mockery": "^1.4", "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", - "symfony/dependency-injection": "^4.4" + "symfony/dependency-injection": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/TaxationBundle/composer.json b/src/Sylius/Bundle/TaxationBundle/composer.json index bda2be6d14..93307937d1 100644 --- a/src/Sylius/Bundle/TaxationBundle/composer.json +++ b/src/Sylius/Bundle/TaxationBundle/composer.json @@ -32,7 +32,7 @@ "sylius/registry": "^1.5", "sylius/resource-bundle": "^1.7", "sylius/taxation": "^1.6", - "symfony/framework-bundle": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2" }, "conflict": { "twig/twig": "^3.0" @@ -43,9 +43,9 @@ "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "symfony/browser-kit": "^4.4", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4" + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/TaxonomyBundle/composer.json b/src/Sylius/Bundle/TaxonomyBundle/composer.json index 1ef44a00de..b46554c16f 100644 --- a/src/Sylius/Bundle/TaxonomyBundle/composer.json +++ b/src/Sylius/Bundle/TaxonomyBundle/composer.json @@ -32,7 +32,7 @@ "stof/doctrine-extensions-bundle": "^1.4", "sylius/resource-bundle": "^1.7", "sylius/taxonomy": "^1.6", - "symfony/framework-bundle": "^4.4" + "symfony/framework-bundle": "^4.4 || ^5.2" }, "conflict": { "twig/twig": "^3.0" @@ -41,7 +41,7 @@ "doctrine/orm": "^2.7", "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", - "symfony/dependency-injection": "^4.4" + "symfony/dependency-injection": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Bundle/UiBundle/composer.json b/src/Sylius/Bundle/UiBundle/composer.json index 945ed32beb..f972c1a7ab 100644 --- a/src/Sylius/Bundle/UiBundle/composer.json +++ b/src/Sylius/Bundle/UiBundle/composer.json @@ -34,11 +34,11 @@ "knplabs/knp-menu-bundle": "^3.0", "sonata-project/block-bundle": "^3.20|^4.0", "sylius/grid-bundle": "^1.8", - "symfony/config": "^4.4", - "symfony/framework-bundle": "^4.4", - "symfony/security": "^4.4", - "symfony/security-bundle": "^4.4", - "symfony/templating": "^4.4", + "symfony/config": "^4.4 || ^5.2", + "symfony/framework-bundle": "^4.4 || ^5.2", + "symfony/security": "^4.4 || ^5.2", + "symfony/security-bundle": "^4.4 || ^5.2", + "symfony/templating": "^4.4 || ^5.2", "zendframework/zend-stdlib": "^3.2" }, "conflict": { @@ -49,8 +49,8 @@ "matthiasnoback/symfony-dependency-injection-test": "^4.1", "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", - "symfony/dependency-injection": "^4.4", - "symfony/form": "^4.4", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/form": "^4.4 || ^5.2", "twig/twig": "^2.12" }, "config": { diff --git a/src/Sylius/Bundle/UserBundle/composer.json b/src/Sylius/Bundle/UserBundle/composer.json index cfeb93fc02..cf7432ecaa 100644 --- a/src/Sylius/Bundle/UserBundle/composer.json +++ b/src/Sylius/Bundle/UserBundle/composer.json @@ -43,7 +43,7 @@ "sylius/mailer-bundle": "^1.4", "sylius/resource-bundle": "^1.7", "sylius/user": "^1.6", - "symfony/framework-bundle": "^4.4", + "symfony/framework-bundle": "^4.4 || ^5.2", "webmozart/assert": "^1.8" }, "conflict": { @@ -55,8 +55,8 @@ "php-http/guzzle6-adapter": "^2.0", "phpspec/phpspec": "^7.0", "phpunit/phpunit": "^8.5", - "symfony/dependency-injection": "^4.4", - "symfony/security-bundle": "^4.4", + "symfony/dependency-injection": "^4.4 || ^5.2", + "symfony/security-bundle": "^4.4 || ^5.2", "symfony/swiftmailer-bundle": "^3.1" }, "suggest": { diff --git a/src/Sylius/Component/Addressing/composer.json b/src/Sylius/Component/Addressing/composer.json index 2dc72e6089..d8af2e357a 100644 --- a/src/Sylius/Component/Addressing/composer.json +++ b/src/Sylius/Component/Addressing/composer.json @@ -29,7 +29,7 @@ "php": "^7.3", "sylius/registry": "^1.5", "sylius/resource": "^1.7", - "symfony/intl": "^4.4" + "symfony/intl": "^4.4 || ^5.2" }, "require-dev": { "phpspec/phpspec": "^7.0" diff --git a/src/Sylius/Component/Attribute/composer.json b/src/Sylius/Component/Attribute/composer.json index 68804bd2f3..8777fe38e0 100644 --- a/src/Sylius/Component/Attribute/composer.json +++ b/src/Sylius/Component/Attribute/composer.json @@ -29,7 +29,7 @@ "doctrine/collections": "^1.6", "sylius/registry": "^1.5", "sylius/resource": "^1.7", - "symfony/validator": "^4.4" + "symfony/validator": "^4.4 || ^5.2" }, "require-dev": { "phpspec/phpspec": "^7.0" diff --git a/src/Sylius/Component/Channel/composer.json b/src/Sylius/Component/Channel/composer.json index 8cf06dba7f..2be31d6b97 100644 --- a/src/Sylius/Component/Channel/composer.json +++ b/src/Sylius/Component/Channel/composer.json @@ -29,8 +29,8 @@ "require": { "php": "^7.3", "sylius/resource": "^1.7", - "symfony/form": "^4.4", - "symfony/http-foundation": "^4.4", + "symfony/form": "^4.4 || ^5.2", + "symfony/http-foundation": "^4.4 || ^5.2", "zendframework/zend-stdlib": "^3.2" }, "require-dev": { diff --git a/src/Sylius/Component/Core/composer.json b/src/Sylius/Component/Core/composer.json index eda54a826c..97f7d8b22d 100644 --- a/src/Sylius/Component/Core/composer.json +++ b/src/Sylius/Component/Core/composer.json @@ -48,13 +48,13 @@ "sylius/taxation": "^1.6", "sylius/taxonomy": "^1.6", "sylius/user": "^1.6", - "symfony/http-foundation": "^4.4", + "symfony/http-foundation": "^4.4 || ^5.2", "webmozart/assert": "^1.8", "zendframework/zend-stdlib": "^3.2" }, "require-dev": { "phpspec/phpspec": "^7.0", - "symfony/property-access": "^4.4" + "symfony/property-access": "^4.4 || ^5.2" }, "config": { "bin-dir": "bin" diff --git a/src/Sylius/Component/Currency/composer.json b/src/Sylius/Component/Currency/composer.json index 8e2970e10c..cf0bbf31df 100644 --- a/src/Sylius/Component/Currency/composer.json +++ b/src/Sylius/Component/Currency/composer.json @@ -27,7 +27,7 @@ "require": { "php": "^7.3", "sylius/resource": "^1.7", - "symfony/intl": "^4.4", + "symfony/intl": "^4.4 || ^5.2", "zendframework/zend-stdlib": "^3.2" }, "require-dev": { diff --git a/src/Sylius/Component/Locale/composer.json b/src/Sylius/Component/Locale/composer.json index 17eb881963..7ff243885a 100644 --- a/src/Sylius/Component/Locale/composer.json +++ b/src/Sylius/Component/Locale/composer.json @@ -28,7 +28,7 @@ "require": { "php": "^7.3", "sylius/resource": "^1.7", - "symfony/intl": "^4.4", + "symfony/intl": "^4.4 || ^5.2", "zendframework/zend-stdlib": "^3.2" }, "require-dev": { diff --git a/src/Sylius/Component/Shipping/composer.json b/src/Sylius/Component/Shipping/composer.json index cde1b11ef9..6ce208f8d7 100644 --- a/src/Sylius/Component/Shipping/composer.json +++ b/src/Sylius/Component/Shipping/composer.json @@ -31,7 +31,7 @@ "php": "^7.3", "sylius/registry": "^1.5", "sylius/resource": "^1.7", - "symfony/options-resolver": "^4.4" + "symfony/options-resolver": "^4.4 || ^5.2" }, "require-dev": { "phpspec/phpspec": "^7.0" diff --git a/src/Sylius/Component/User/composer.json b/src/Sylius/Component/User/composer.json index 521ecca24b..b63c5755d6 100644 --- a/src/Sylius/Component/User/composer.json +++ b/src/Sylius/Component/User/composer.json @@ -37,7 +37,7 @@ "doctrine/collections": "^1.6", "sylius/resource": "^1.7", "symfony/polyfill-mbstring": "^1.17", - "symfony/security": "^4.4" + "symfony/security": "^4.4 || ^5.2" }, "require-dev": { "phpspec/phpspec": "^7.0" diff --git a/symfony.lock b/symfony.lock index e7245e20ab..086a1a2dae 100644 --- a/symfony.lock +++ b/symfony.lock @@ -684,6 +684,9 @@ "sylius/theme-bundle": { "version": "v1.4.2" }, + "symfony/amqp-messenger": { + "version": "v5.2.0" + }, "symfony/asset": { "version": "v4.1.3" }, @@ -714,9 +717,6 @@ "symfony/css-selector": { "version": "v4.1.3" }, - "symfony/debug": { - "version": "v4.1.3" - }, "symfony/debug-bundle": { "version": "4.1", "recipe": { @@ -735,6 +735,9 @@ "symfony/doctrine-bridge": { "version": "v4.1.3" }, + "symfony/doctrine-messenger": { + "version": "v5.2.0" + }, "symfony/dom-crawler": { "version": "v4.1.3" }, @@ -789,9 +792,6 @@ "symfony/http-kernel": { "version": "v4.1.3" }, - "symfony/inflector": { - "version": "v4.1.3" - }, "symfony/intl": { "version": "v4.1.3" }, @@ -876,6 +876,9 @@ "symfony/proxy-manager-bridge": { "version": "v4.4.13" }, + "symfony/redis-messenger": { + "version": "v5.2.0" + }, "symfony/routing": { "version": "4.2", "recipe": { From 6b9a46e11409283cc50ac73b1b8ad5a12d11dd57 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 9 Dec 2020 13:34:55 +0100 Subject: [PATCH 02/55] Include Symfony ^5.2 in the matrix --- .github/workflows/application.yml | 2 +- .github/workflows/packages.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/application.yml b/.github/workflows/application.yml index 11af2d6a59..d7abec2577 100644 --- a/.github/workflows/application.yml +++ b/.github/workflows/application.yml @@ -30,7 +30,7 @@ jobs: fail-fast: false matrix: php: [7.3, 7.4] - symfony: [^4.4] + symfony: [^4.4, ^5.2] steps: - diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index e57e609711..ff7e898507 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -49,7 +49,7 @@ jobs: fail-fast: false matrix: php: [7.3, 7.4] - symfony: [4.4.*] + symfony: [^4.4, ^5.2] package: "${{ fromJson(needs.list.outputs.packages) }}" steps: From 3077b3da7756fe3429df80eee5d0fe77e3710f9a Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 9 Dec 2020 13:57:42 +0100 Subject: [PATCH 03/55] Remove usage of removed Event class --- composer.json | 1 + .../UserCartRecalculationListener.php | 8 ++++ .../UserCartRecalculationListenerSpec.php | 38 ++++++++++++++++--- .../UiBundle/Menu/Event/MenuBuilderEvent.php | 3 +- src/Sylius/Bundle/UiBundle/composer.json | 1 + .../Bundle/UserBundle/Event/UserEvent.php | 2 +- src/Sylius/Bundle/UserBundle/composer.json | 1 + symfony.lock | 15 ++------ 8 files changed, 49 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index ee9ced3c7b..7357b50981 100644 --- a/composer.json +++ b/composer.json @@ -55,6 +55,7 @@ "swiftmailer/swiftmailer": "^6.2", "sylius-labs/association-hydrator": "^1.1.2", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3", + "sylius-labs/polyfill-symfony-event-dispatcher": "^1.0.1", "sylius/fixtures-bundle": "^1.6.1", "sylius/grid": "^1.8", "sylius/grid-bundle": "^1.8", diff --git a/src/Sylius/Bundle/CoreBundle/EventListener/UserCartRecalculationListener.php b/src/Sylius/Bundle/CoreBundle/EventListener/UserCartRecalculationListener.php index 5812a2cd70..d615b7953b 100644 --- a/src/Sylius/Bundle/CoreBundle/EventListener/UserCartRecalculationListener.php +++ b/src/Sylius/Bundle/CoreBundle/EventListener/UserCartRecalculationListener.php @@ -40,6 +40,14 @@ final class UserCartRecalculationListener */ public function recalculateCartWhileLogin(object $event): void { + if (!$event instanceof InteractiveLoginEvent && !$event instanceof UserEvent) { + throw new \TypeError(sprintf( + '$event needs to be an instance of "%s" or "%s"', + InteractiveLoginEvent::class, + UserEvent::class + )); + } + try { $cart = $this->cartContext->getCart(); } catch (CartNotFoundException $exception) { diff --git a/src/Sylius/Bundle/CoreBundle/spec/EventListener/UserCartRecalculationListenerSpec.php b/src/Sylius/Bundle/CoreBundle/spec/EventListener/UserCartRecalculationListenerSpec.php index ce51ff9d44..72088c238b 100644 --- a/src/Sylius/Bundle/CoreBundle/spec/EventListener/UserCartRecalculationListenerSpec.php +++ b/src/Sylius/Bundle/CoreBundle/spec/EventListener/UserCartRecalculationListenerSpec.php @@ -15,11 +15,14 @@ namespace spec\Sylius\Bundle\CoreBundle\EventListener; use PhpSpec\ObjectBehavior; use Prophecy\Argument; +use Sylius\Bundle\UserBundle\Event\UserEvent; use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Order\Context\CartContextInterface; use Sylius\Component\Order\Context\CartNotFoundException; use Sylius\Component\Order\Processor\OrderProcessorInterface; -use Symfony\Contracts\EventDispatcher\Event; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; final class UserCartRecalculationListenerSpec extends ObjectBehavior { @@ -28,10 +31,23 @@ final class UserCartRecalculationListenerSpec extends ObjectBehavior $this->beConstructedWith($cartContext, $orderProcessor); } - function it_recalculates_cart_for_logged_in_user( + function it_recalculates_cart_for_logged_in_user_and_interactive_login_event( CartContextInterface $cartContext, OrderProcessorInterface $orderProcessor, - Event $event, + Request $request, + TokenInterface $token, + OrderInterface $order + ): void { + $cartContext->getCart()->willReturn($order); + $orderProcessor->process($order)->shouldBeCalled(); + + $this->recalculateCartWhileLogin(new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())); + } + + function it_recalculates_cart_for_logged_in_user_and_user_event( + CartContextInterface $cartContext, + OrderProcessorInterface $orderProcessor, + UserEvent $event, OrderInterface $order ): void { $cartContext->getCart()->willReturn($order); @@ -40,10 +56,22 @@ final class UserCartRecalculationListenerSpec extends ObjectBehavior $this->recalculateCartWhileLogin($event); } - function it_does_nothing_if_cannot_find_cart( + function it_does_nothing_if_cannot_find_cart_for_interactive_login_event( CartContextInterface $cartContext, OrderProcessorInterface $orderProcessor, - Event $event + Request $request, + TokenInterface $token + ): void { + $cartContext->getCart()->willThrow(CartNotFoundException::class); + $orderProcessor->process(Argument::any())->shouldNotBeCalled(); + + $this->recalculateCartWhileLogin(new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())); + } + + function it_does_nothing_if_cannot_find_cart_for_user_event( + CartContextInterface $cartContext, + OrderProcessorInterface $orderProcessor, + UserEvent $event ): void { $cartContext->getCart()->willThrow(CartNotFoundException::class); $orderProcessor->process(Argument::any())->shouldNotBeCalled(); diff --git a/src/Sylius/Bundle/UiBundle/Menu/Event/MenuBuilderEvent.php b/src/Sylius/Bundle/UiBundle/Menu/Event/MenuBuilderEvent.php index 1862b6de42..511d6c6689 100644 --- a/src/Sylius/Bundle/UiBundle/Menu/Event/MenuBuilderEvent.php +++ b/src/Sylius/Bundle/UiBundle/Menu/Event/MenuBuilderEvent.php @@ -15,9 +15,8 @@ namespace Sylius\Bundle\UiBundle\Menu\Event; use Knp\Menu\FactoryInterface; use Knp\Menu\ItemInterface; -use Symfony\Component\EventDispatcher\Event; +use SyliusLabs\Polyfill\Symfony\EventDispatcher\Event; -/** @psalm-suppress DeprecatedClass */ class MenuBuilderEvent extends Event { /** @var FactoryInterface */ diff --git a/src/Sylius/Bundle/UiBundle/composer.json b/src/Sylius/Bundle/UiBundle/composer.json index f972c1a7ab..b038a3bcf0 100644 --- a/src/Sylius/Bundle/UiBundle/composer.json +++ b/src/Sylius/Bundle/UiBundle/composer.json @@ -33,6 +33,7 @@ "knplabs/knp-menu": "^3.1", "knplabs/knp-menu-bundle": "^3.0", "sonata-project/block-bundle": "^3.20|^4.0", + "sylius-labs/polyfill-symfony-event-dispatcher": "^1.0.1", "sylius/grid-bundle": "^1.8", "symfony/config": "^4.4 || ^5.2", "symfony/framework-bundle": "^4.4 || ^5.2", diff --git a/src/Sylius/Bundle/UserBundle/Event/UserEvent.php b/src/Sylius/Bundle/UserBundle/Event/UserEvent.php index 782912931d..4145fca567 100644 --- a/src/Sylius/Bundle/UserBundle/Event/UserEvent.php +++ b/src/Sylius/Bundle/UserBundle/Event/UserEvent.php @@ -14,7 +14,7 @@ declare(strict_types=1); namespace Sylius\Bundle\UserBundle\Event; use Sylius\Component\User\Model\UserInterface; -use Symfony\Contracts\EventDispatcher\Event; +use SyliusLabs\Polyfill\Symfony\EventDispatcher\Event; class UserEvent extends Event { diff --git a/src/Sylius/Bundle/UserBundle/composer.json b/src/Sylius/Bundle/UserBundle/composer.json index cf7432ecaa..e0b2bf3d93 100644 --- a/src/Sylius/Bundle/UserBundle/composer.json +++ b/src/Sylius/Bundle/UserBundle/composer.json @@ -40,6 +40,7 @@ "php": "^7.3", "doctrine/orm": "^2.7", "egulias/email-validator": "^2.1", + "sylius-labs/polyfill-symfony-event-dispatcher": "^1.0.1", "sylius/mailer-bundle": "^1.4", "sylius/resource-bundle": "^1.7", "sylius/user": "^1.6", diff --git a/symfony.lock b/symfony.lock index 086a1a2dae..b1b84b3890 100644 --- a/symfony.lock +++ b/symfony.lock @@ -19,6 +19,9 @@ "src/Entity/.gitignore" ] }, + "babdev/pagerfanta-bundle": { + "version": "v2.8.0" + }, "behat/behat": { "version": "v3.7.0" }, @@ -248,9 +251,6 @@ "jms/metadata": { "version": "1.7.0" }, - "jms/parser-lib": { - "version": "1.0.0" - }, "jms/serializer": { "version": "1.14.1" }, @@ -447,9 +447,6 @@ "php-http/promise": { "version": "v1.0.0" }, - "phpcollection/phpcollection": { - "version": "0.5.0" - }, "phpdocumentor/reflection-common": { "version": "1.0.1" }, @@ -459,9 +456,6 @@ "phpdocumentor/type-resolver": { "version": "0.4.0" }, - "phpoption/phpoption": { - "version": "1.5.0" - }, "phpspec/php-diff": { "version": "v1.1.0" }, @@ -1078,9 +1072,6 @@ "webmozart/path-util": { "version": "2.3.0" }, - "white-october/pagerfanta-bundle": { - "version": "v1.3.2" - }, "willdurand/hateoas": { "version": "2.12.0" }, From 31a10b04fdd1fd7ca98eb36d71ddea10c8cac9c5 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 31 Dec 2020 17:59:40 +0100 Subject: [PATCH 04/55] [User] Requrie symfony/security-core instead of symfony/security --- src/Sylius/Bundle/UiBundle/composer.json | 2 +- src/Sylius/Component/User/composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sylius/Bundle/UiBundle/composer.json b/src/Sylius/Bundle/UiBundle/composer.json index b038a3bcf0..ee0a511021 100644 --- a/src/Sylius/Bundle/UiBundle/composer.json +++ b/src/Sylius/Bundle/UiBundle/composer.json @@ -37,7 +37,7 @@ "sylius/grid-bundle": "^1.8", "symfony/config": "^4.4 || ^5.2", "symfony/framework-bundle": "^4.4 || ^5.2", - "symfony/security": "^4.4 || ^5.2", + "symfony/security-core": "^4.4 || ^5.2", "symfony/security-bundle": "^4.4 || ^5.2", "symfony/templating": "^4.4 || ^5.2", "zendframework/zend-stdlib": "^3.2" diff --git a/src/Sylius/Component/User/composer.json b/src/Sylius/Component/User/composer.json index b63c5755d6..2865318a17 100644 --- a/src/Sylius/Component/User/composer.json +++ b/src/Sylius/Component/User/composer.json @@ -37,7 +37,7 @@ "doctrine/collections": "^1.6", "sylius/resource": "^1.7", "symfony/polyfill-mbstring": "^1.17", - "symfony/security": "^4.4 || ^5.2" + "symfony/security-core": "^4.4 || ^5.2" }, "require-dev": { "phpspec/phpspec": "^7.0" From 326d38f9e0b01c60dee3948bff55e874250ee15b Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 31 Dec 2020 18:20:01 +0100 Subject: [PATCH 05/55] Fix bugs reported by Psalm --- psalm.xml | 6 ++++-- .../EventListener/UserCartRecalculationListener.php | 1 + .../Bundle/CurrencyBundle/Form/Type/ExchangeRateType.php | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/psalm.xml b/psalm.xml index 7b0f88cf14..ae84b4d4c5 100644 --- a/psalm.xml +++ b/psalm.xml @@ -92,12 +92,13 @@ + + - @@ -110,12 +111,13 @@ + + - diff --git a/src/Sylius/Bundle/CoreBundle/EventListener/UserCartRecalculationListener.php b/src/Sylius/Bundle/CoreBundle/EventListener/UserCartRecalculationListener.php index d615b7953b..2fc14f1ad1 100644 --- a/src/Sylius/Bundle/CoreBundle/EventListener/UserCartRecalculationListener.php +++ b/src/Sylius/Bundle/CoreBundle/EventListener/UserCartRecalculationListener.php @@ -40,6 +40,7 @@ final class UserCartRecalculationListener */ public function recalculateCartWhileLogin(object $event): void { + /** @psalm-suppress DocblockTypeContradiction */ if (!$event instanceof InteractiveLoginEvent && !$event instanceof UserEvent) { throw new \TypeError(sprintf( '$event needs to be an instance of "%s" or "%s"', diff --git a/src/Sylius/Bundle/CurrencyBundle/Form/Type/ExchangeRateType.php b/src/Sylius/Bundle/CurrencyBundle/Form/Type/ExchangeRateType.php index 3d86fb3bd3..7f90a3f890 100644 --- a/src/Sylius/Bundle/CurrencyBundle/Form/Type/ExchangeRateType.php +++ b/src/Sylius/Bundle/CurrencyBundle/Form/Type/ExchangeRateType.php @@ -64,6 +64,7 @@ final class ExchangeRateType extends AbstractResourceType { parent::configureOptions($resolver); + /** @psalm-suppress DeprecatedConstant */ $resolver->setDefault('rounding_mode', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN); } From 333c4e278ce33f343cfc153197aff5ac53be3660 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 31 Dec 2020 18:21:07 +0100 Subject: [PATCH 06/55] [CI] Restrict Symfony version correctly --- .github/workflows/application.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/application.yml b/.github/workflows/application.yml index d7abec2577..87e14a226d 100644 --- a/.github/workflows/application.yml +++ b/.github/workflows/application.yml @@ -49,7 +49,9 @@ jobs: - name: Restrict Symfony version if: matrix.symfony != '' - run: composer config extra.symfony.require "${{ matrix.symfony }}" + run: | + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" + composer config extra.symfony.require "${{ matrix.symfony }}" - name: Get Composer cache directory @@ -151,7 +153,9 @@ jobs: - name: Restrict Symfony version if: matrix.symfony != '' - run: composer config extra.symfony.require "${{ matrix.symfony }}" + run: | + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" + composer config extra.symfony.require "${{ matrix.symfony }}" - name: Get Composer cache directory @@ -278,7 +282,9 @@ jobs: - name: Restrict Symfony version if: matrix.symfony != '' - run: composer config extra.symfony.require "${{ matrix.symfony }}" + run: | + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" + composer config extra.symfony.require "${{ matrix.symfony }}" - name: Install certificates From db4d4f80044fb136892df544409a935540d2e005 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 13:26:30 +0100 Subject: [PATCH 07/55] [AddressingBundle] Fix compatibility with Symfony 5 --- src/Sylius/Bundle/AddressingBundle/.gitignore | 16 ++++++++++------ .../Tests/Form/Type/CountryChoiceTypeTest.php | 10 ++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Sylius/Bundle/AddressingBundle/.gitignore b/src/Sylius/Bundle/AddressingBundle/.gitignore index a24566fdcc..2f743a54c9 100644 --- a/src/Sylius/Bundle/AddressingBundle/.gitignore +++ b/src/Sylius/Bundle/AddressingBundle/.gitignore @@ -1,8 +1,12 @@ -vendor/ -bin/ +/vendor/ +/bin/ -composer.phar -composer.lock +/composer.phar +/composer.lock -test/app/cache -test/app/logs +/test/app/cache +/test/app/logs +/test/var/cache +/test/var/logs + +/.phpunit.result.cache diff --git a/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php b/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php index ee4cad34de..b9fca36c09 100644 --- a/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php +++ b/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php @@ -110,7 +110,11 @@ final class CountryChoiceTypeTest extends TypeTestCase $this->poland->reveal(), ]); - $this->assertChoicesLabels(['Poland'], ['choice_filter' => function (CountryInterface $country): bool { + $this->assertChoicesLabels(['Poland'], ['choice_filter' => static function (?CountryInterface $country): bool { + if ($country === null) { + return false; + } + return $country->getName() === 'Poland'; }]); } @@ -120,7 +124,9 @@ final class CountryChoiceTypeTest extends TypeTestCase $form = $this->factory->create(CountryChoiceType::class, null, $formConfiguration); $view = $form->createView(); - Assert::assertSame($expectedLabels, array_map(function (ChoiceView $choiceView): string { + $i = 1; + + Assert::assertSame($expectedLabels, array_map(static function (ChoiceView $choiceView): string { return $choiceView->label; }, $view->vars['choices'])); } From e35a3a0163311eb6805091b1620d022ceaac8336 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 13:37:53 +0100 Subject: [PATCH 08/55] [ChannelBundle] Fix compatibility with Symfony 5 --- src/Sylius/Bundle/ChannelBundle/.gitignore | 7 ++- .../FakeChannel/FakeChannelPersisterSpec.php | 47 ++++++++++--------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/Sylius/Bundle/ChannelBundle/.gitignore b/src/Sylius/Bundle/ChannelBundle/.gitignore index b8c91b293a..53239bdddf 100644 --- a/src/Sylius/Bundle/ChannelBundle/.gitignore +++ b/src/Sylius/Bundle/ChannelBundle/.gitignore @@ -4,8 +4,11 @@ /composer.phar /composer.lock -test/app/cache -test/app/logs +/test/app/cache +/test/app/logs +/test/var/cache +/test/var/logs /phpspec.yml /phpunit.xml +/.phpunit.result.cache diff --git a/src/Sylius/Bundle/ChannelBundle/spec/Context/FakeChannel/FakeChannelPersisterSpec.php b/src/Sylius/Bundle/ChannelBundle/spec/Context/FakeChannel/FakeChannelPersisterSpec.php index 1cc0f97cde..0e79fd5375 100644 --- a/src/Sylius/Bundle/ChannelBundle/spec/Context/FakeChannel/FakeChannelPersisterSpec.php +++ b/src/Sylius/Bundle/ChannelBundle/spec/Context/FakeChannel/FakeChannelPersisterSpec.php @@ -30,53 +30,54 @@ final class FakeChannelPersisterSpec extends ObjectBehavior $this->beConstructedWith($fakeHostnameProvider); } - function it_applies_only_to_master_requests(ResponseEvent $responseEvent): void + function it_applies_only_to_master_requests(HttpKernelInterface $kernel, Request $request, Response $response): void { - $responseEvent->getRequestType()->willReturn(HttpKernelInterface::SUB_REQUEST); - - $responseEvent->getRequest()->shouldNotBeCalled(); - $responseEvent->getResponse()->shouldNotBeCalled(); - - $this->onKernelResponse($responseEvent); + $this->onKernelResponse(new ResponseEvent( + $kernel->getWrappedObject(), + $request->getWrappedObject(), + HttpKernelInterface::SUB_REQUEST, + $response->getWrappedObject() + )); } function it_applies_only_for_request_with_fake_channel_code( FakeChannelCodeProviderInterface $fakeHostnameProvider, - ResponseEvent $responseEvent, - Request $request + HttpKernelInterface $kernel, + Request $request, + Response $response ): void { - $responseEvent->getRequestType()->willReturn(HttpKernelInterface::MASTER_REQUEST); - $responseEvent->getRequest()->willReturn($request); - $fakeHostnameProvider->getCode($request)->willReturn(null); - $responseEvent->getResponse()->shouldNotBeCalled(); - - $this->onKernelResponse($responseEvent); + $this->onKernelResponse(new ResponseEvent( + $kernel->getWrappedObject(), + $request->getWrappedObject(), + HttpKernelInterface::MASTER_REQUEST, + $response->getWrappedObject() + )); } function it_persists_fake_channel_codes_in_a_cookie( FakeChannelCodeProviderInterface $fakeHostnameProvider, - ResponseEvent $responseEvent, + HttpKernelInterface $kernel, Request $request, Response $response, ResponseHeaderBag $responseHeaderBag ): void { - $responseEvent->getRequestType()->willReturn(HttpKernelInterface::MASTER_REQUEST); - $responseEvent->getRequest()->willReturn($request); - $fakeHostnameProvider->getCode($request)->willReturn('fake_channel_code'); - $responseEvent->getResponse()->willReturn($response); - $response->headers = $responseHeaderBag; $responseHeaderBag - ->setCookie(Argument::that(function (Cookie $cookie) { + ->setCookie(Argument::that(static function (Cookie $cookie): bool { return $cookie->getName() === '_channel_code' && $cookie->getValue() === 'fake_channel_code'; })) ->shouldBeCalled() ; - $this->onKernelResponse($responseEvent); + $this->onKernelResponse(new ResponseEvent( + $kernel->getWrappedObject(), + $request->getWrappedObject(), + HttpKernelInterface::MASTER_REQUEST, + $response->getWrappedObject() + )); } } From 2655e7f2d07547e5285c3987c482bec7327f93fb Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 13:44:11 +0100 Subject: [PATCH 09/55] [OrderBundle] Partially fix compatibility with Symfony 5 --- src/Sylius/Bundle/OrderBundle/.gitignore | 16 ++++++++++------ .../OrderBundle/Remover/ExpiredCartsRemover.php | 4 ++-- .../spec/Remover/ExpiredCartsRemoverSpec.php | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Sylius/Bundle/OrderBundle/.gitignore b/src/Sylius/Bundle/OrderBundle/.gitignore index a24566fdcc..2f743a54c9 100644 --- a/src/Sylius/Bundle/OrderBundle/.gitignore +++ b/src/Sylius/Bundle/OrderBundle/.gitignore @@ -1,8 +1,12 @@ -vendor/ -bin/ +/vendor/ +/bin/ -composer.phar -composer.lock +/composer.phar +/composer.lock -test/app/cache -test/app/logs +/test/app/cache +/test/app/logs +/test/var/cache +/test/var/logs + +/.phpunit.result.cache diff --git a/src/Sylius/Bundle/OrderBundle/Remover/ExpiredCartsRemover.php b/src/Sylius/Bundle/OrderBundle/Remover/ExpiredCartsRemover.php index 5c6efcab56..4dadc9b960 100644 --- a/src/Sylius/Bundle/OrderBundle/Remover/ExpiredCartsRemover.php +++ b/src/Sylius/Bundle/OrderBundle/Remover/ExpiredCartsRemover.php @@ -50,7 +50,7 @@ final class ExpiredCartsRemover implements ExpiredCartsRemoverInterface { $expiredCarts = $this->orderRepository->findCartsNotModifiedSince(new \DateTime('-' . $this->expirationPeriod)); - $this->eventDispatcher->dispatch(SyliusExpiredCartsEvents::PRE_REMOVE, new GenericEvent($expiredCarts)); + $this->eventDispatcher->dispatch(new GenericEvent($expiredCarts), SyliusExpiredCartsEvents::PRE_REMOVE); foreach ($expiredCarts as $expiredCart) { $this->orderManager->remove($expiredCart); @@ -58,6 +58,6 @@ final class ExpiredCartsRemover implements ExpiredCartsRemoverInterface $this->orderManager->flush(); - $this->eventDispatcher->dispatch(SyliusExpiredCartsEvents::POST_REMOVE, new GenericEvent($expiredCarts)); + $this->eventDispatcher->dispatch(new GenericEvent($expiredCarts), SyliusExpiredCartsEvents::POST_REMOVE); } } diff --git a/src/Sylius/Bundle/OrderBundle/spec/Remover/ExpiredCartsRemoverSpec.php b/src/Sylius/Bundle/OrderBundle/spec/Remover/ExpiredCartsRemoverSpec.php index ada3225200..c83e20d0d9 100644 --- a/src/Sylius/Bundle/OrderBundle/spec/Remover/ExpiredCartsRemoverSpec.php +++ b/src/Sylius/Bundle/OrderBundle/spec/Remover/ExpiredCartsRemoverSpec.php @@ -47,7 +47,7 @@ final class ExpiredCartsRemoverSpec extends ObjectBehavior ]); $eventDispatcher - ->dispatch(SyliusExpiredCartsEvents::PRE_REMOVE, Argument::any()) + ->dispatch(Argument::any(), SyliusExpiredCartsEvents::PRE_REMOVE) ->shouldBeCalled() ; @@ -56,7 +56,7 @@ final class ExpiredCartsRemoverSpec extends ObjectBehavior $orderManager->flush(); $eventDispatcher - ->dispatch(SyliusExpiredCartsEvents::POST_REMOVE, Argument::any()) + ->dispatch(Argument::any(), SyliusExpiredCartsEvents::POST_REMOVE) ->shouldBeCalled() ; From 447e865027ac0d72ecc7d86d042c91c94874ac1b Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 13:48:31 +0100 Subject: [PATCH 10/55] [CI] Mark Symfony ^5.2 builds as experimental --- .github/workflows/application.yml | 10 ++++++++-- .github/workflows/packages.yml | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/application.yml b/.github/workflows/application.yml index 87e14a226d..23da7fe1ca 100644 --- a/.github/workflows/application.yml +++ b/.github/workflows/application.yml @@ -31,6 +31,8 @@ jobs: matrix: php: [7.3, 7.4] symfony: [^4.4, ^5.2] + + continue-on-error: ${{ matrix.symfony == '^5.2' }} steps: - @@ -118,9 +120,11 @@ jobs: fail-fast: false matrix: php: [7.3, 7.4] - symfony: [^4.4] + symfony: [^4.4, ^5.2] mysql: [5.7] + continue-on-error: ${{ matrix.symfony == '^5.2' }} + env: APP_ENV: test_cached DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" @@ -246,9 +250,11 @@ jobs: fail-fast: false matrix: php: [7.3, 7.4] - symfony: [^4.4] + symfony: [^4.4, ^5.2] node: [10.x] mysql: [5.7] + + continue-on-error: ${{ matrix.symfony == '^5.2' }} env: APP_ENV: test_cached diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index ff7e898507..f0af002df4 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -51,6 +51,8 @@ jobs: php: [7.3, 7.4] symfony: [^4.4, ^5.2] package: "${{ fromJson(needs.list.outputs.packages) }}" + + continue-on-error: ${{ matrix.symfony == '^5.2' }} steps: - From 15696e3e0482af0e26871d8ada5d11708792f10e Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 14:19:53 +0100 Subject: [PATCH 11/55] Allow for gedmo/doctrine-extensions ^3.0 --- composer.json | 2 +- symfony.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 7357b50981..cb7b4bccad 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "friendsofphp/proxy-manager-lts": "^1.0", "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev", "friendsofsymfony/rest-bundle": "^3.0", - "gedmo/doctrine-extensions": "^2.4.12", + "gedmo/doctrine-extensions": "^2.4.12 || ^3.0", "jms/serializer-bundle": "^3.5", "knplabs/gaufrette": "^0.8", "knplabs/knp-gaufrette-bundle": "^0.7", diff --git a/symfony.lock b/symfony.lock index b1b84b3890..cb7dc4908a 100644 --- a/symfony.lock +++ b/symfony.lock @@ -140,9 +140,6 @@ "doctrine/persistence": { "version": "1.3.8" }, - "doctrine/reflection": { - "version": "1.2.1" - }, "doctrine/sql-formatter": { "version": "1.1.1" }, @@ -200,6 +197,9 @@ ".php_cs.dist" ] }, + "friendsofphp/proxy-manager-lts": { + "version": "v1.0.2" + }, "friendsofsymfony/oauth-server-bundle": { "version": "1.6.2" }, From ec688e7b41dcb0623ad031e0e749072009bd9522 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 14:30:31 +0100 Subject: [PATCH 12/55] Make installable with Symfony ^5.2 --- src/Kernel.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/Kernel.php b/src/Kernel.php index f25b9d7f61..5cf6cd11a6 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -91,25 +91,6 @@ class Kernel extends BaseKernel return parent::getContainerBaseClass(); } - protected function getContainerLoader(ContainerInterface $container): LoaderInterface - { - /** @var ContainerBuilder $container */ - Assert::isInstanceOf($container, ContainerBuilder::class); - - $locator = new FileLocator($this, $this->getRootDir() . '/Resources'); - $resolver = new LoaderResolver([ - new XmlFileLoader($container, $locator), - new YamlFileLoader($container, $locator), - new IniFileLoader($container, $locator), - new PhpFileLoader($container, $locator), - new GlobFileLoader($container, $locator), - new DirectoryLoader($container, $locator), - new ClosureLoader($container), - ]); - - return new DelegatingLoader($resolver); - } - private function isTestEnvironment(): bool { return 0 === strpos($this->getEnvironment(), 'test'); From 8d5b9c7dd0a559c09aca8d3e5201ed604976e911 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 14:36:09 +0100 Subject: [PATCH 13/55] Require symfony/string:^5.2, it's used by StringInflector --- composer.json | 1 + src/Sylius/Component/Core/composer.json | 1 + symfony.lock | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index cb7b4bccad..200ec04876 100644 --- a/composer.json +++ b/composer.json @@ -97,6 +97,7 @@ "symfony/security-guard": "^4.4 || ^5.2", "symfony/security-http": "^4.4 || ^5.2", "symfony/serializer": "^4.4 || ^5.2", + "symfony/string": "^5.2", "symfony/swiftmailer-bundle": "^3.4", "symfony/templating": "^4.4 || ^5.2", "symfony/thanks": "^1.2", diff --git a/src/Sylius/Component/Core/composer.json b/src/Sylius/Component/Core/composer.json index 97f7d8b22d..288765fc1e 100644 --- a/src/Sylius/Component/Core/composer.json +++ b/src/Sylius/Component/Core/composer.json @@ -49,6 +49,7 @@ "sylius/taxonomy": "^1.6", "sylius/user": "^1.6", "symfony/http-foundation": "^4.4 || ^5.2", + "symfony/string": "^5.2", "webmozart/assert": "^1.8", "zendframework/zend-stdlib": "^3.2" }, diff --git a/symfony.lock b/symfony.lock index cb7dc4908a..4f34f65a66 100644 --- a/symfony.lock +++ b/symfony.lock @@ -679,7 +679,7 @@ "version": "v1.4.2" }, "symfony/amqp-messenger": { - "version": "v5.2.0" + "version": "v5.2.1" }, "symfony/asset": { "version": "v4.1.3" @@ -730,7 +730,7 @@ "version": "v4.1.3" }, "symfony/doctrine-messenger": { - "version": "v5.2.0" + "version": "v5.2.1" }, "symfony/dom-crawler": { "version": "v4.1.3" @@ -826,7 +826,7 @@ "version": "v1.9.0" }, "symfony/polyfill-intl-grapheme": { - "version": "v1.17.0" + "version": "v1.22.0" }, "symfony/polyfill-intl-icu": { "version": "v1.9.0" @@ -871,7 +871,7 @@ "version": "v4.4.13" }, "symfony/redis-messenger": { - "version": "v5.2.0" + "version": "v5.2.1" }, "symfony/routing": { "version": "4.2", @@ -921,7 +921,7 @@ "version": "v5.1.5" }, "symfony/string": { - "version": "v5.1.0" + "version": "v5.2.1" }, "symfony/swiftmailer-bundle": { "version": "2.5", From 0c2cb8e3d17cfa259990c133184abde74813b12a Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 14:54:45 +0100 Subject: [PATCH 14/55] Require sylius-labs/association-hydrator:^1.1.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 200ec04876..c190efc995 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "sonata-project/block-bundle": "^4.2", "stof/doctrine-extensions-bundle": "^1.4", "swiftmailer/swiftmailer": "^6.2", - "sylius-labs/association-hydrator": "^1.1.2", + "sylius-labs/association-hydrator": "^1.1.3", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3", "sylius-labs/polyfill-symfony-event-dispatcher": "^1.0.1", "sylius/fixtures-bundle": "^1.6.1", From 14869ea0eb89f38e12efe47c3ba4ba5ba08738eb Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 15:11:45 +0100 Subject: [PATCH 15/55] [Psalm] Do not fail on invalid docblock in \Doctrine\ORM\EntityRepository::__construct --- psalm.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/psalm.xml b/psalm.xml index ae84b4d4c5..14287986c8 100644 --- a/psalm.xml +++ b/psalm.xml @@ -128,6 +128,12 @@ + + + + + + From bcf9be87dde050c1d76d2122e07fabb2aebde458 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 15:14:18 +0100 Subject: [PATCH 16/55] [Psalm] Ignore missing Symfony\Bundle\FrameworkBundle\Templating\EngineInterface --- psalm.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/psalm.xml b/psalm.xml index 14287986c8..cd8f01eeba 100644 --- a/psalm.xml +++ b/psalm.xml @@ -134,6 +134,12 @@ + + + + + + From 11303b6489ca8f5cf6dd93fbec1fbb04337334d8 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 16:27:24 +0100 Subject: [PATCH 17/55] Use tweaked DoctrineStorage for Payum that accepts new Doctrine Persistence API --- .../UseTweakedDoctrineStoragePass.php | 17 +++++ .../PayumBundle/Storage/DoctrineStorage.php | 65 +++++++++++++++++++ .../Bundle/PayumBundle/SyliusPayumBundle.php | 2 + 3 files changed, 84 insertions(+) create mode 100644 src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/UseTweakedDoctrineStoragePass.php create mode 100644 src/Sylius/Bundle/PayumBundle/Storage/DoctrineStorage.php diff --git a/src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/UseTweakedDoctrineStoragePass.php b/src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/UseTweakedDoctrineStoragePass.php new file mode 100644 index 0000000000..43b9636e01 --- /dev/null +++ b/src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/UseTweakedDoctrineStoragePass.php @@ -0,0 +1,17 @@ +setParameter('payum.storage.doctrine.orm.class', DoctrineStorage::class); + } +} diff --git a/src/Sylius/Bundle/PayumBundle/Storage/DoctrineStorage.php b/src/Sylius/Bundle/PayumBundle/Storage/DoctrineStorage.php new file mode 100644 index 0000000000..c23476e6bd --- /dev/null +++ b/src/Sylius/Bundle/PayumBundle/Storage/DoctrineStorage.php @@ -0,0 +1,65 @@ +objectManager = $objectManager; + } + + public function findBy(array $criteria): array + { + return $this->objectManager->getRepository($this->modelClass)->findBy($criteria); + } + + protected function doFind($id): ?object + { + return $this->objectManager->find($this->modelClass, $id); + } + + protected function doUpdateModel($model): void + { + $this->objectManager->persist($model); + $this->objectManager->flush(); + } + + protected function doDeleteModel($model): void + { + $this->objectManager->remove($model); + $this->objectManager->flush(); + } + + protected function doGetIdentity($model): Identity + { + $modelMetadata = $this->objectManager->getClassMetadata(get_class($model)); + $id = $modelMetadata->getIdentifierValues($model); + if (count($id) > 1) { + throw new \LogicException('Storage not support composite primary ids'); + } + + return new Identity(array_shift($id), $model); + } +} diff --git a/src/Sylius/Bundle/PayumBundle/SyliusPayumBundle.php b/src/Sylius/Bundle/PayumBundle/SyliusPayumBundle.php index 5782c6e07a..d0c5b63dbb 100644 --- a/src/Sylius/Bundle/PayumBundle/SyliusPayumBundle.php +++ b/src/Sylius/Bundle/PayumBundle/SyliusPayumBundle.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Sylius\Bundle\PayumBundle; use Sylius\Bundle\PayumBundle\DependencyInjection\Compiler\RegisterGatewayConfigTypePass; +use Sylius\Bundle\PayumBundle\DependencyInjection\Compiler\UseTweakedDoctrineStoragePass; use Sylius\Bundle\ResourceBundle\AbstractResourceBundle; use Sylius\Bundle\ResourceBundle\SyliusResourceBundle; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -32,5 +33,6 @@ final class SyliusPayumBundle extends AbstractResourceBundle parent::build($container); $container->addCompilerPass(new RegisterGatewayConfigTypePass()); + $container->addCompilerPass(new UseTweakedDoctrineStoragePass()); } } From 81178e9a56e9c00d135552bbc472d9c3ab9e8b2e Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 20:54:55 +0100 Subject: [PATCH 18/55] Use sylius-labs/polyfill-symfony-security to account for removed AdvancedUserInterface --- composer.json | 1 + config/bundles.php | 1 + src/Sylius/Component/User/Model/UserInterface.php | 2 +- symfony.lock | 3 +++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c190efc995..3fa281da0d 100644 --- a/composer.json +++ b/composer.json @@ -56,6 +56,7 @@ "sylius-labs/association-hydrator": "^1.1.3", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3", "sylius-labs/polyfill-symfony-event-dispatcher": "^1.0.1", + "sylius-labs/polyfill-symfony-security": "^1.0", "sylius/fixtures-bundle": "^1.6.1", "sylius/grid": "^1.8", "sylius/grid-bundle": "^1.8", diff --git a/config/bundles.php b/config/bundles.php index 3fd77597e9..bc8e8eb477 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -60,4 +60,5 @@ return [ SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], Sonata\Doctrine\Bridge\Symfony\SonataDoctrineSymfonyBundle::class => ['all' => true], Sonata\Twig\Bridge\Symfony\SonataTwigSymfonyBundle::class => ['all' => true], + SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], ]; diff --git a/src/Sylius/Component/User/Model/UserInterface.php b/src/Sylius/Component/User/Model/UserInterface.php index 950c59a63a..7cb28947c5 100644 --- a/src/Sylius/Component/User/Model/UserInterface.php +++ b/src/Sylius/Component/User/Model/UserInterface.php @@ -17,8 +17,8 @@ use Doctrine\Common\Collections\Collection; use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TimestampableInterface; use Sylius\Component\Resource\Model\ToggleableInterface; +use SyliusLabs\Polyfill\Symfony\Security\Core\User\AdvancedUserInterface; use Symfony\Component\Security\Core\Encoder\EncoderAwareInterface; -use Symfony\Component\Security\Core\User\AdvancedUserInterface; interface UserInterface extends AdvancedUserInterface, diff --git a/symfony.lock b/symfony.lock index 4f34f65a66..cb2250e8fe 100644 --- a/symfony.lock +++ b/symfony.lock @@ -657,6 +657,9 @@ "sylius-labs/polyfill-symfony-event-dispatcher": { "version": "v1.0.0" }, + "sylius-labs/polyfill-symfony-security": { + "version": "v1.0.0" + }, "sylius-labs/sensio-distribution-bundle": { "version": "v6.0.1" }, From 8144de2da8f591c656f4318ffcef2e366ff7f1f6 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 20:57:25 +0100 Subject: [PATCH 19/55] [Psalm] Improve configuration --- psalm.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/psalm.xml b/psalm.xml index cd8f01eeba..c1f967605c 100644 --- a/psalm.xml +++ b/psalm.xml @@ -89,9 +89,7 @@ - - @@ -99,12 +97,13 @@ + - + From f0df509e23c482d2716263d4863369db8c24a003 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 20:58:35 +0100 Subject: [PATCH 20/55] Remove use of deprecated method Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent::getException --- psalm.xml | 1 - .../AdminBundle/EventListener/ResourceDeleteSubscriber.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/psalm.xml b/psalm.xml index c1f967605c..ee530c9215 100644 --- a/psalm.xml +++ b/psalm.xml @@ -111,7 +111,6 @@ - diff --git a/src/Sylius/Bundle/AdminBundle/EventListener/ResourceDeleteSubscriber.php b/src/Sylius/Bundle/AdminBundle/EventListener/ResourceDeleteSubscriber.php index 897bacd47b..ec50712270 100644 --- a/src/Sylius/Bundle/AdminBundle/EventListener/ResourceDeleteSubscriber.php +++ b/src/Sylius/Bundle/AdminBundle/EventListener/ResourceDeleteSubscriber.php @@ -47,7 +47,7 @@ final class ResourceDeleteSubscriber implements EventSubscriberInterface public function onResourceDelete(ExceptionEvent $event): void { - $exception = $event->getException(); + $exception = $event->getThrowable(); if (!$exception instanceof ForeignKeyConstraintViolationException) { return; } From a419508ef46eb83649fc7685a1f4cffca2e0e271 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 21:02:12 +0100 Subject: [PATCH 21/55] [Psalm] Improve configuration --- psalm.xml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/psalm.xml b/psalm.xml index ee530c9215..6ea0630feb 100644 --- a/psalm.xml +++ b/psalm.xml @@ -89,14 +89,7 @@ - - - - - - - - + @@ -109,13 +102,7 @@ - - - - - - - + From 25b38747be57a123387f5a0f9b9ae4713e000364 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 21:34:58 +0100 Subject: [PATCH 22/55] Use sylius-labs/polyfill-symfony-framework-bundle to account for removed ContainerAwareCommand --- composer.json | 1 + .../Bundle/AdminApiBundle/Command/CreateClientCommand.php | 2 +- .../AdminApiBundle/spec/Command/CreateClientCommandSpec.php | 2 +- .../Bundle/CoreBundle/Command/AbstractInstallCommand.php | 2 +- .../Bundle/CoreBundle/Command/CancelUnpaidOrdersCommand.php | 2 +- .../Bundle/OrderBundle/Command/RemoveExpiredCartsCommand.php | 2 +- src/Sylius/Bundle/UserBundle/Command/AbstractRoleCommand.php | 2 +- symfony.lock | 3 +++ 8 files changed, 10 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 3fa281da0d..2a2d97db24 100644 --- a/composer.json +++ b/composer.json @@ -56,6 +56,7 @@ "sylius-labs/association-hydrator": "^1.1.3", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3", "sylius-labs/polyfill-symfony-event-dispatcher": "^1.0.1", + "sylius-labs/polyfill-symfony-framework-bundle": "^1.0", "sylius-labs/polyfill-symfony-security": "^1.0", "sylius/fixtures-bundle": "^1.6.1", "sylius/grid": "^1.8", diff --git a/src/Sylius/Bundle/AdminApiBundle/Command/CreateClientCommand.php b/src/Sylius/Bundle/AdminApiBundle/Command/CreateClientCommand.php index 3b289b0750..5c1e1e634a 100644 --- a/src/Sylius/Bundle/AdminApiBundle/Command/CreateClientCommand.php +++ b/src/Sylius/Bundle/AdminApiBundle/Command/CreateClientCommand.php @@ -15,7 +15,7 @@ namespace Sylius\Bundle\AdminApiBundle\Command; use FOS\OAuthServerBundle\Model\ClientManagerInterface; use Sylius\Bundle\AdminApiBundle\Model\Client; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use SyliusLabs\Polyfill\Symfony\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Sylius/Bundle/AdminApiBundle/spec/Command/CreateClientCommandSpec.php b/src/Sylius/Bundle/AdminApiBundle/spec/Command/CreateClientCommandSpec.php index 30545672da..705b48e3b3 100644 --- a/src/Sylius/Bundle/AdminApiBundle/spec/Command/CreateClientCommandSpec.php +++ b/src/Sylius/Bundle/AdminApiBundle/spec/Command/CreateClientCommandSpec.php @@ -17,7 +17,7 @@ use FOS\OAuthServerBundle\Model\ClientManager; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Sylius\Bundle\AdminApiBundle\Model\Client; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use SyliusLabs\Polyfill\Symfony\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php b/src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php index e8e2b69693..8544d811f5 100644 --- a/src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php +++ b/src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php @@ -15,7 +15,7 @@ namespace Sylius\Bundle\CoreBundle\Command; use Doctrine\ORM\EntityManagerInterface; use Sylius\Bundle\CoreBundle\Installer\Executor\CommandExecutor; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use SyliusLabs\Polyfill\Symfony\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Sylius/Bundle/CoreBundle/Command/CancelUnpaidOrdersCommand.php b/src/Sylius/Bundle/CoreBundle/Command/CancelUnpaidOrdersCommand.php index c6d70e8af8..8d70ef683e 100644 --- a/src/Sylius/Bundle/CoreBundle/Command/CancelUnpaidOrdersCommand.php +++ b/src/Sylius/Bundle/CoreBundle/Command/CancelUnpaidOrdersCommand.php @@ -13,7 +13,7 @@ declare(strict_types=1); namespace Sylius\Bundle\CoreBundle\Command; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use SyliusLabs\Polyfill\Symfony\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Sylius/Bundle/OrderBundle/Command/RemoveExpiredCartsCommand.php b/src/Sylius/Bundle/OrderBundle/Command/RemoveExpiredCartsCommand.php index 9011548663..4e23bf058b 100644 --- a/src/Sylius/Bundle/OrderBundle/Command/RemoveExpiredCartsCommand.php +++ b/src/Sylius/Bundle/OrderBundle/Command/RemoveExpiredCartsCommand.php @@ -13,7 +13,7 @@ declare(strict_types=1); namespace Sylius\Bundle\OrderBundle\Command; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use SyliusLabs\Polyfill\Symfony\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Sylius/Bundle/UserBundle/Command/AbstractRoleCommand.php b/src/Sylius/Bundle/UserBundle/Command/AbstractRoleCommand.php index e99255a4c3..42d2d498b1 100644 --- a/src/Sylius/Bundle/UserBundle/Command/AbstractRoleCommand.php +++ b/src/Sylius/Bundle/UserBundle/Command/AbstractRoleCommand.php @@ -16,7 +16,7 @@ namespace Sylius\Bundle\UserBundle\Command; use Doctrine\Persistence\ObjectManager; use Sylius\Component\User\Model\UserInterface; use Sylius\Component\User\Repository\UserRepositoryInterface; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use SyliusLabs\Polyfill\Symfony\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; diff --git a/symfony.lock b/symfony.lock index cb2250e8fe..a20df87631 100644 --- a/symfony.lock +++ b/symfony.lock @@ -657,6 +657,9 @@ "sylius-labs/polyfill-symfony-event-dispatcher": { "version": "v1.0.0" }, + "sylius-labs/polyfill-symfony-framework-bundle": { + "version": "v1.0.0" + }, "sylius-labs/polyfill-symfony-security": { "version": "v1.0.0" }, From e6170fe53ae5dd98bd8e20598fff0d189104303f Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 21:44:50 +0100 Subject: [PATCH 23/55] [Psalm] Fix configuration for Symfony ^4.4 deprecations --- psalm.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/psalm.xml b/psalm.xml index 6ea0630feb..1aacaffe2d 100644 --- a/psalm.xml +++ b/psalm.xml @@ -89,19 +89,23 @@ + + + + From a36c90e06a248581444794cc8382ab0b45935042 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 22:05:30 +0100 Subject: [PATCH 24/55] Remove unnecessary Twig routes in dev environment --- config/routes/dev/twig.yaml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 config/routes/dev/twig.yaml diff --git a/config/routes/dev/twig.yaml b/config/routes/dev/twig.yaml deleted file mode 100644 index f4ee83960b..0000000000 --- a/config/routes/dev/twig.yaml +++ /dev/null @@ -1,3 +0,0 @@ -_errors: - resource: '@TwigBundle/Resources/config/routing/errors.xml' - prefix: /_error From aa1d930bfafd06f36a94dc448c1ae0995ce838cb Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 22:05:58 +0100 Subject: [PATCH 25/55] Rename "message_bus" service to "messenger.default_bus" to comply with Symfony 5.2 --- .../ApiBundle/Resources/config/services/event_handlers.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/services/event_handlers.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/services/event_handlers.xml index 27bcb3fb8f..8ad82cce7c 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/services/event_handlers.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/services/event_handlers.xml @@ -17,7 +17,7 @@ > - + From 11d9f9aba49a2db172008b5ea1e4f56293ae6344 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 22:11:43 +0100 Subject: [PATCH 26/55] Make commands' execute() always return int --- .../Bundle/CoreBundle/Command/CancelUnpaidOrdersCommand.php | 2 +- src/Sylius/Bundle/CoreBundle/Command/InstallAssetsCommand.php | 4 ++-- .../Bundle/CoreBundle/Command/InstallSampleDataCommand.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Sylius/Bundle/CoreBundle/Command/CancelUnpaidOrdersCommand.php b/src/Sylius/Bundle/CoreBundle/Command/CancelUnpaidOrdersCommand.php index 8d70ef683e..92c288a74b 100644 --- a/src/Sylius/Bundle/CoreBundle/Command/CancelUnpaidOrdersCommand.php +++ b/src/Sylius/Bundle/CoreBundle/Command/CancelUnpaidOrdersCommand.php @@ -32,7 +32,7 @@ class CancelUnpaidOrdersCommand extends ContainerAwareCommand ); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $expirationTime = $this->getContainer()->getParameter('sylius_order.order_expiration_period'); diff --git a/src/Sylius/Bundle/CoreBundle/Command/InstallAssetsCommand.php b/src/Sylius/Bundle/CoreBundle/Command/InstallAssetsCommand.php index 6db03840d6..b02fde6d70 100644 --- a/src/Sylius/Bundle/CoreBundle/Command/InstallAssetsCommand.php +++ b/src/Sylius/Bundle/CoreBundle/Command/InstallAssetsCommand.php @@ -31,7 +31,7 @@ EOT ; } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln(sprintf( 'Installing Sylius assets for environment %s.', @@ -55,6 +55,6 @@ EOT $this->runCommands($commands, $output); - return null; + return 0; } } diff --git a/src/Sylius/Bundle/CoreBundle/Command/InstallSampleDataCommand.php b/src/Sylius/Bundle/CoreBundle/Command/InstallSampleDataCommand.php index 7302fe33ae..7fc40c80bb 100644 --- a/src/Sylius/Bundle/CoreBundle/Command/InstallSampleDataCommand.php +++ b/src/Sylius/Bundle/CoreBundle/Command/InstallSampleDataCommand.php @@ -36,7 +36,7 @@ EOT ; } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { /** @var QuestionHelper $questionHelper */ $questionHelper = $this->getHelper('question'); @@ -80,6 +80,6 @@ EOT $this->runCommands($commands, $output); $outputStyle->newLine(2); - return null; + return 0; } } From 0714e77abdc766ef1bc7857b266dff35d3116a76 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 22:14:04 +0100 Subject: [PATCH 27/55] Fix packages builds by requiring SyliusLabs polyfill libraries --- src/Sylius/Bundle/AdminApiBundle/composer.json | 1 + src/Sylius/Bundle/CoreBundle/composer.json | 1 + src/Sylius/Bundle/OrderBundle/composer.json | 1 + src/Sylius/Bundle/UserBundle/composer.json | 1 + src/Sylius/Component/User/composer.json | 1 + 5 files changed, 5 insertions(+) diff --git a/src/Sylius/Bundle/AdminApiBundle/composer.json b/src/Sylius/Bundle/AdminApiBundle/composer.json index 75ecfc1433..f9c31a73ba 100644 --- a/src/Sylius/Bundle/AdminApiBundle/composer.json +++ b/src/Sylius/Bundle/AdminApiBundle/composer.json @@ -26,6 +26,7 @@ "php": "^7.3", "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3", + "sylius-labs/polyfill-symfony-framework-bundle": "^1.0", "sylius/core-bundle": "^1.6", "symfony/form": "^4.4 || ^5.2", "symfony/framework-bundle": "^4.4 || ^5.2", diff --git a/src/Sylius/Bundle/CoreBundle/composer.json b/src/Sylius/Bundle/CoreBundle/composer.json index fd4984cd24..864756c7cd 100644 --- a/src/Sylius/Bundle/CoreBundle/composer.json +++ b/src/Sylius/Bundle/CoreBundle/composer.json @@ -38,6 +38,7 @@ "swiftmailer/swiftmailer": "^6.2", "sylius-labs/association-hydrator": "^1.1", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3", + "sylius-labs/polyfill-symfony-framework-bundle": "^1.0", "sylius/addressing-bundle": "^1.6", "sylius/attribute-bundle": "^1.6", "sylius/channel-bundle": "^1.6", diff --git a/src/Sylius/Bundle/OrderBundle/composer.json b/src/Sylius/Bundle/OrderBundle/composer.json index ffe0a538e4..440af68f49 100644 --- a/src/Sylius/Bundle/OrderBundle/composer.json +++ b/src/Sylius/Bundle/OrderBundle/composer.json @@ -29,6 +29,7 @@ "require": { "php": "^7.3", "stof/doctrine-extensions-bundle": "^1.4", + "sylius-labs/polyfill-symfony-framework-bundle": "^1.0", "sylius/money-bundle": "^1.6", "sylius/order": "^1.6", "sylius/resource-bundle": "^1.7", diff --git a/src/Sylius/Bundle/UserBundle/composer.json b/src/Sylius/Bundle/UserBundle/composer.json index e0b2bf3d93..834275c6dd 100644 --- a/src/Sylius/Bundle/UserBundle/composer.json +++ b/src/Sylius/Bundle/UserBundle/composer.json @@ -41,6 +41,7 @@ "doctrine/orm": "^2.7", "egulias/email-validator": "^2.1", "sylius-labs/polyfill-symfony-event-dispatcher": "^1.0.1", + "sylius-labs/polyfill-symfony-framework-bundle": "^1.0", "sylius/mailer-bundle": "^1.4", "sylius/resource-bundle": "^1.7", "sylius/user": "^1.6", diff --git a/src/Sylius/Component/User/composer.json b/src/Sylius/Component/User/composer.json index 2865318a17..b6b463ba05 100644 --- a/src/Sylius/Component/User/composer.json +++ b/src/Sylius/Component/User/composer.json @@ -35,6 +35,7 @@ "require": { "php": "^7.3", "doctrine/collections": "^1.6", + "sylius-labs/polyfill-symfony-security": "^1.0", "sylius/resource": "^1.7", "symfony/polyfill-mbstring": "^1.17", "symfony/security-core": "^4.4 || ^5.2" From d683ad6d78563f02c268c7ee0def12bf18d91495 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 22:27:56 +0100 Subject: [PATCH 28/55] [ApiBundle] Fix event dispatcher usage --- .../Applicator/ShipmentStateMachineTransitionApplicator.php | 2 +- .../Applicator/ShipmentStateMachineTransitionApplicatorSpec.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sylius/Bundle/ApiBundle/Applicator/ShipmentStateMachineTransitionApplicator.php b/src/Sylius/Bundle/ApiBundle/Applicator/ShipmentStateMachineTransitionApplicator.php index 09f2efbb36..1839978dfb 100644 --- a/src/Sylius/Bundle/ApiBundle/Applicator/ShipmentStateMachineTransitionApplicator.php +++ b/src/Sylius/Bundle/ApiBundle/Applicator/ShipmentStateMachineTransitionApplicator.php @@ -40,7 +40,7 @@ final class ShipmentStateMachineTransitionApplicator implements ShipmentStateMac { $this->applyTransition($data, ShipmentTransitions::TRANSITION_SHIP); - $this->eventDispatcher->dispatch('sylius.shipment.post_ship', new GenericEvent($data)); + $this->eventDispatcher->dispatch(new GenericEvent($data), 'sylius.shipment.post_ship'); return $data; } diff --git a/src/Sylius/Bundle/ApiBundle/spec/Applicator/ShipmentStateMachineTransitionApplicatorSpec.php b/src/Sylius/Bundle/ApiBundle/spec/Applicator/ShipmentStateMachineTransitionApplicatorSpec.php index 9fb45d9c36..d6373b040a 100644 --- a/src/Sylius/Bundle/ApiBundle/spec/Applicator/ShipmentStateMachineTransitionApplicatorSpec.php +++ b/src/Sylius/Bundle/ApiBundle/spec/Applicator/ShipmentStateMachineTransitionApplicatorSpec.php @@ -37,7 +37,7 @@ final class ShipmentStateMachineTransitionApplicatorSpec extends ObjectBehavior $stateMachineFactory->get($shipment, ShipmentTransitions::GRAPH)->willReturn($stateMachine); $stateMachine->apply(ShipmentTransitions::TRANSITION_SHIP)->shouldBeCalled(); - $eventDispatcher->dispatch('sylius.shipment.post_ship', new GenericEvent($shipment->getWrappedObject()))->shouldBeCalled(); + $eventDispatcher->dispatch(new GenericEvent($shipment->getWrappedObject()), 'sylius.shipment.post_ship')->shouldBeCalled(); $this->ship($shipment); } From 1033ef35e9fd2ced902a736eb7f32f260a695a91 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 22:34:07 +0100 Subject: [PATCH 29/55] [ApiBundle] Fix ViewEvent mocking in specs --- .../ProductSlugEventSubscriberSpec.php | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/Sylius/Bundle/ApiBundle/spec/EventSubscriber/ProductSlugEventSubscriberSpec.php b/src/Sylius/Bundle/ApiBundle/spec/EventSubscriber/ProductSlugEventSubscriberSpec.php index 30996bd5e1..9dd17fed07 100644 --- a/src/Sylius/Bundle/ApiBundle/spec/EventSubscriber/ProductSlugEventSubscriberSpec.php +++ b/src/Sylius/Bundle/ApiBundle/spec/EventSubscriber/ProductSlugEventSubscriberSpec.php @@ -21,6 +21,7 @@ use Sylius\Component\Core\Model\ProductTranslationInterface; use Sylius\Component\Product\Generator\SlugGeneratorInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\ViewEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; final class ProductSlugEventSubscriberSpec extends ObjectBehavior { @@ -33,11 +34,9 @@ final class ProductSlugEventSubscriberSpec extends ObjectBehavior SlugGeneratorInterface $slugGenerator, ProductInterface $product, ProductTranslationInterface $productTranslation, - Request $request, - ViewEvent $event + HttpKernelInterface $kernel, + Request $request ): void { - $event->getControllerResult()->willReturn($product); - $event->getRequest()->willReturn($request); $request->getMethod()->willReturn(Request::METHOD_POST); $product->getTranslations()->willReturn(new ArrayCollection([$productTranslation->getWrappedObject()])); @@ -47,20 +46,22 @@ final class ProductSlugEventSubscriberSpec extends ObjectBehavior $slugGenerator->generate('Audi RS7')->willReturn('audi-rs7'); $productTranslation->setSlug('audi-rs7')->shouldBeCalled(); - $event->setControllerResult($product)->shouldBeCalled(); - $this->generateSlug($event); + $this->generateSlug(new ViewEvent( + $kernel->getWrappedObject(), + $request->getWrappedObject(), + HttpKernelInterface::MASTER_REQUEST, + $product->getWrappedObject() + )); } function it_does_nothing_if_the_product_has_slug( SlugGeneratorInterface $slugGenerator, ProductInterface $product, ProductTranslationInterface $productTranslation, - Request $request, - ViewEvent $event + HttpKernelInterface $kernel, + Request $request ): void { - $event->getControllerResult()->willReturn($product); - $event->getRequest()->willReturn($request); $request->getMethod()->willReturn(Request::METHOD_POST); $product->getTranslations()->willReturn(new ArrayCollection([$productTranslation->getWrappedObject()])); @@ -70,20 +71,21 @@ final class ProductSlugEventSubscriberSpec extends ObjectBehavior $slugGenerator->generate(Argument::any())->shouldNotBeCalled(); $productTranslation->setSlug(Argument::any())->shouldNotBeCalled(); - $event->setControllerResult($product)->shouldBeCalled(); - - $this->generateSlug($event); + $this->generateSlug(new ViewEvent( + $kernel->getWrappedObject(), + $request->getWrappedObject(), + HttpKernelInterface::MASTER_REQUEST, + $product->getWrappedObject() + )); } function it_does_nothing_if_the_product_has_no_name( SlugGeneratorInterface $slugGenerator, ProductInterface $product, ProductTranslationInterface $productTranslation, - Request $request, - ViewEvent $event + HttpKernelInterface $kernel, + Request $request ): void { - $event->getControllerResult()->willReturn($product); - $event->getRequest()->willReturn($request); $request->getMethod()->willReturn(Request::METHOD_POST); $product->getTranslations()->willReturn(new ArrayCollection([$productTranslation->getWrappedObject()])); @@ -93,8 +95,11 @@ final class ProductSlugEventSubscriberSpec extends ObjectBehavior $slugGenerator->generate(Argument::any())->shouldNotBeCalled(); $productTranslation->setSlug(Argument::any())->shouldNotBeCalled(); - $event->setControllerResult($product)->shouldBeCalled(); - - $this->generateSlug($event); + $this->generateSlug(new ViewEvent( + $kernel->getWrappedObject(), + $request->getWrappedObject(), + HttpKernelInterface::MASTER_REQUEST, + $product->getWrappedObject() + )); } } From 18a474801f8b9c187a3ecc369a01d9ee2cb1c334 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 22:36:01 +0100 Subject: [PATCH 30/55] [Core] Require symfony/mime explicitly --- src/Sylius/Component/Core/composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Sylius/Component/Core/composer.json b/src/Sylius/Component/Core/composer.json index 288765fc1e..d656d92d3e 100644 --- a/src/Sylius/Component/Core/composer.json +++ b/src/Sylius/Component/Core/composer.json @@ -49,6 +49,7 @@ "sylius/taxonomy": "^1.6", "sylius/user": "^1.6", "symfony/http-foundation": "^4.4 || ^5.2", + "symfony/mime": "^4.4 || ^5.2", "symfony/string": "^5.2", "webmozart/assert": "^1.8", "zendframework/zend-stdlib": "^3.2" From 468d71fd4210792d88388fc4ac78c237123e5cf0 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 22:37:38 +0100 Subject: [PATCH 31/55] [UiBundle] Replace templating with Twig in specs --- .../UiBundle/spec/Controller/SecurityControllerSpec.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Sylius/Bundle/UiBundle/spec/Controller/SecurityControllerSpec.php b/src/Sylius/Bundle/UiBundle/spec/Controller/SecurityControllerSpec.php index 9cbc568691..7df73c4691 100644 --- a/src/Sylius/Bundle/UiBundle/spec/Controller/SecurityControllerSpec.php +++ b/src/Sylius/Bundle/UiBundle/spec/Controller/SecurityControllerSpec.php @@ -25,13 +25,14 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; +use Twig\Environment; final class SecurityControllerSpec extends ObjectBehavior { function let( AuthenticationUtils $authenticationUtils, FormFactoryInterface $formFactory, - EngineInterface $templatingEngine, + Environment $templatingEngine, AuthorizationCheckerInterface $authorizationChecker, RouterInterface $router ): void { @@ -45,7 +46,7 @@ final class SecurityControllerSpec extends ObjectBehavior FormFactoryInterface $formFactory, Form $form, FormView $formView, - EngineInterface $templatingEngine, + Environment $templatingEngine, AuthorizationCheckerInterface $authorizationChecker, Response $response ): void { From 5cfc2b6eecec41a1f8e1689fdaddc2ec5f35c936 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 22:39:24 +0100 Subject: [PATCH 32/55] [ShopBundle] Fix event dispatcher usage --- .../EventListener/CustomerEmailUpdaterListener.php | 2 +- .../EventListener/UserRegistrationListener.php | 2 +- .../EventListener/CustomerEmailUpdaterListenerSpec.php | 10 +++++----- .../EventListener/UserRegistrationListenerSpec.php | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Sylius/Bundle/ShopBundle/EventListener/CustomerEmailUpdaterListener.php b/src/Sylius/Bundle/ShopBundle/EventListener/CustomerEmailUpdaterListener.php index a3720e31f0..aabf377a6e 100644 --- a/src/Sylius/Bundle/ShopBundle/EventListener/CustomerEmailUpdaterListener.php +++ b/src/Sylius/Bundle/ShopBundle/EventListener/CustomerEmailUpdaterListener.php @@ -111,7 +111,7 @@ final class CustomerEmailUpdaterListener } if (!$user->isEnabled() && !$user->isVerified() && null !== $user->getEmailVerificationToken()) { - $this->eventDispatcher->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, new GenericEvent($user)); + $this->eventDispatcher->dispatch(new GenericEvent($user), UserEvents::REQUEST_VERIFICATION_TOKEN); /** @var FlashBagInterface $flashBag */ $flashBag = $this->session->getBag('flashes'); diff --git a/src/Sylius/Bundle/ShopBundle/EventListener/UserRegistrationListener.php b/src/Sylius/Bundle/ShopBundle/EventListener/UserRegistrationListener.php index 30f2bec07a..dc7875dcac 100644 --- a/src/Sylius/Bundle/ShopBundle/EventListener/UserRegistrationListener.php +++ b/src/Sylius/Bundle/ShopBundle/EventListener/UserRegistrationListener.php @@ -91,7 +91,7 @@ final class UserRegistrationListener $this->userManager->persist($user); $this->userManager->flush(); - $this->eventDispatcher->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, new GenericEvent($user)); + $this->eventDispatcher->dispatch(new GenericEvent($user), UserEvents::REQUEST_VERIFICATION_TOKEN); } private function enableAndLogin(ShopUserInterface $user): void diff --git a/src/Sylius/Bundle/ShopBundle/spec/EventListener/CustomerEmailUpdaterListenerSpec.php b/src/Sylius/Bundle/ShopBundle/spec/EventListener/CustomerEmailUpdaterListenerSpec.php index 4d29f4b158..f9eab64d47 100644 --- a/src/Sylius/Bundle/ShopBundle/spec/EventListener/CustomerEmailUpdaterListenerSpec.php +++ b/src/Sylius/Bundle/ShopBundle/spec/EventListener/CustomerEmailUpdaterListenerSpec.php @@ -199,7 +199,7 @@ final class CustomerEmailUpdaterListenerSpec extends ObjectBehavior $flashBag->add('success', 'sylius.user.verify_email_request')->shouldBeCalled(); $eventDispatcher - ->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, Argument::type(GenericEvent::class)) + ->dispatch(Argument::type(GenericEvent::class), UserEvents::REQUEST_VERIFICATION_TOKEN) ->shouldBeCalled() ; @@ -234,7 +234,7 @@ final class CustomerEmailUpdaterListenerSpec extends ObjectBehavior $flashBag->add(Argument::any())->shouldNotBeCalled(); $eventDispatcher - ->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, Argument::type(GenericEvent::class)) + ->dispatch(Argument::type(GenericEvent::class), UserEvents::REQUEST_VERIFICATION_TOKEN) ->shouldNotBeCalled() ; @@ -269,7 +269,7 @@ final class CustomerEmailUpdaterListenerSpec extends ObjectBehavior $flashBag->add(Argument::any())->shouldNotBeCalled(); $eventDispatcher - ->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, Argument::type(GenericEvent::class)) + ->dispatch(Argument::type(GenericEvent::class), UserEvents::REQUEST_VERIFICATION_TOKEN) ->shouldNotBeCalled() ; @@ -304,7 +304,7 @@ final class CustomerEmailUpdaterListenerSpec extends ObjectBehavior $flashBag->add(Argument::any())->shouldNotBeCalled(); $eventDispatcher - ->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, Argument::type(GenericEvent::class)) + ->dispatch(Argument::type(GenericEvent::class), UserEvents::REQUEST_VERIFICATION_TOKEN) ->shouldNotBeCalled() ; @@ -335,7 +335,7 @@ final class CustomerEmailUpdaterListenerSpec extends ObjectBehavior $flashBag->add(Argument::any())->shouldNotBeCalled(); $eventDispatcher - ->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, Argument::type(GenericEvent::class)) + ->dispatch(Argument::type(GenericEvent::class), UserEvents::REQUEST_VERIFICATION_TOKEN) ->shouldNotBeCalled() ; diff --git a/src/Sylius/Bundle/ShopBundle/spec/EventListener/UserRegistrationListenerSpec.php b/src/Sylius/Bundle/ShopBundle/spec/EventListener/UserRegistrationListenerSpec.php index c1d3f239bf..6f3c0f6d30 100644 --- a/src/Sylius/Bundle/ShopBundle/spec/EventListener/UserRegistrationListenerSpec.php +++ b/src/Sylius/Bundle/ShopBundle/spec/EventListener/UserRegistrationListenerSpec.php @@ -68,7 +68,7 @@ final class UserRegistrationListenerSpec extends ObjectBehavior $userManager->flush()->shouldBeCalled(); $eventDispatcher - ->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, Argument::type(GenericEvent::class)) + ->dispatch(Argument::type(GenericEvent::class), UserEvents::REQUEST_VERIFICATION_TOKEN) ->shouldBeCalled() ; @@ -103,7 +103,7 @@ final class UserRegistrationListenerSpec extends ObjectBehavior $user->setEmailVerificationToken(Argument::any())->shouldNotBeCalled(); $eventDispatcher - ->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, Argument::type(GenericEvent::class)) + ->dispatch(Argument::type(GenericEvent::class), UserEvents::REQUEST_VERIFICATION_TOKEN) ->shouldNotBeCalled() ; @@ -138,7 +138,7 @@ final class UserRegistrationListenerSpec extends ObjectBehavior $user->setEmailVerificationToken(Argument::any())->shouldNotBeCalled(); $eventDispatcher - ->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, Argument::type(GenericEvent::class)) + ->dispatch(Argument::type(GenericEvent::class), UserEvents::REQUEST_VERIFICATION_TOKEN) ->shouldNotBeCalled() ; From 31876509719b95cd78c2d1ca0ada5842bdd1fe2e Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 22:41:59 +0100 Subject: [PATCH 33/55] [CoreBundle] Fix InteractiveLoginEvent mocks --- .../EventListener/CartBlamerListenerSpec.php | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Sylius/Bundle/CoreBundle/spec/EventListener/CartBlamerListenerSpec.php b/src/Sylius/Bundle/CoreBundle/spec/EventListener/CartBlamerListenerSpec.php index 1d02543bf6..b50a9ed228 100644 --- a/src/Sylius/Bundle/CoreBundle/spec/EventListener/CartBlamerListenerSpec.php +++ b/src/Sylius/Bundle/CoreBundle/spec/EventListener/CartBlamerListenerSpec.php @@ -24,6 +24,7 @@ use Sylius\Component\Order\Context\CartContextInterface; use Sylius\Component\Order\Context\CartNotFoundException; use Sylius\Component\Order\Model\OrderInterface as BaseOrderInterface; use Sylius\Component\Resource\Exception\UnexpectedTypeException; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; @@ -48,14 +49,17 @@ final class CartBlamerListenerSpec extends ObjectBehavior function it_throws_exception_when_cart_does_not_implement_core_order_interface_on_interactive_login( BaseOrderInterface $order, CartContextInterface $cartContext, - InteractiveLoginEvent $interactiveLoginEvent, ShopUserInterface $user, + Request $request, TokenInterface $token ): void { $cartContext->getCart()->willReturn($order); - $interactiveLoginEvent->getAuthenticationToken()->willReturn($token); $token->getUser()->willReturn($user); - $this->shouldThrow(UnexpectedTypeException::class)->during('onInteractiveLogin', [$interactiveLoginEvent]); + + $this + ->shouldThrow(UnexpectedTypeException::class) + ->during('onInteractiveLogin', [new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())]) + ; } function it_blames_cart_on_user_on_implicit_login( @@ -79,32 +83,34 @@ final class CartBlamerListenerSpec extends ObjectBehavior ObjectManager $cartManager, CartContextInterface $cartContext, OrderInterface $cart, - InteractiveLoginEvent $interactiveLoginEvent, + Request $request, TokenInterface $token, ShopUserInterface $user, CustomerInterface $customer ): void { $cartContext->getCart()->willReturn($cart); - $interactiveLoginEvent->getAuthenticationToken()->willReturn($token); $token->getUser()->willReturn($user); $user->getCustomer()->willReturn($customer); + $cart->setCustomer($customer)->shouldBeCalled(); $cartManager->persist($cart)->shouldBeCalled(); $cartManager->flush()->shouldBeCalled(); - $this->onInteractiveLogin($interactiveLoginEvent); + + $this->onInteractiveLogin(new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())); } function it_does_nothing_if_given_user_is_invalid_on_interactive_login( CartContextInterface $cartContext, OrderInterface $cart, - InteractiveLoginEvent $interactiveLoginEvent, + Request $request, TokenInterface $token ): void { $cartContext->getCart()->willReturn($cart); - $interactiveLoginEvent->getAuthenticationToken()->willReturn($token); $token->getUser()->willReturn('anon.'); + $cart->setCustomer(Argument::any())->shouldNotBeCalled(); - $this->onInteractiveLogin($interactiveLoginEvent); + + $this->onInteractiveLogin(new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())); } function it_does_nothing_if_there_is_no_existing_cart_on_implicit_login( @@ -119,13 +125,13 @@ final class CartBlamerListenerSpec extends ObjectBehavior function it_does_nothing_if_there_is_no_existing_cart_on_interactive_login( CartContextInterface $cartContext, - InteractiveLoginEvent $interactiveLoginEvent, + Request $request, TokenInterface $token, ShopUserInterface $user ): void { $cartContext->getCart()->willThrow(CartNotFoundException::class); - $interactiveLoginEvent->getAuthenticationToken()->willReturn($token); $token->getUser()->willReturn($user); - $this->onInteractiveLogin($interactiveLoginEvent); + + $this->onInteractiveLogin(new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())); } } From 0c28301ef85343718ff62d1d62e843fb5ba77d79 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jan 2021 22:46:58 +0100 Subject: [PATCH 34/55] [UserBundle] Fix InteractiveLoginEvent mocks --- .../UpdateUserEncoderListenerSpec.php | 35 +++++++------------ .../UserLastLoginSubscriberSpec.php | 15 ++++---- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/Sylius/Bundle/UserBundle/spec/EventListener/UpdateUserEncoderListenerSpec.php b/src/Sylius/Bundle/UserBundle/spec/EventListener/UpdateUserEncoderListenerSpec.php index 5b0ba1ec43..a43a5d592b 100644 --- a/src/Sylius/Bundle/UserBundle/spec/EventListener/UpdateUserEncoderListenerSpec.php +++ b/src/Sylius/Bundle/UserBundle/spec/EventListener/UpdateUserEncoderListenerSpec.php @@ -32,10 +32,9 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior function it_does_nothing_if_user_does_not_implement_user_interface( ObjectManager $objectManager, + Request $request, TokenInterface $token ): void { - $event = new InteractiveLoginEvent(new Request(), $token->getWrappedObject()); - $user = new \stdClass(); $token->getUser()->willReturn($user); @@ -43,31 +42,29 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior $objectManager->persist($user)->shouldNotBeCalled(); $objectManager->flush()->shouldNotBeCalled(); - $this->onSecurityInteractiveLogin($event); + $this->onSecurityInteractiveLogin(new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())); } function it_does_nothing_if_user_does_not_implement_specified_class_or_interface( ObjectManager $objectManager, + Request $request, TokenInterface $token, User $user ): void { - $event = new InteractiveLoginEvent(new Request(), $token->getWrappedObject()); - $token->getUser()->willReturn($user); $objectManager->persist($user)->shouldNotBeCalled(); $objectManager->flush()->shouldNotBeCalled(); - $this->onSecurityInteractiveLogin($event); + $this->onSecurityInteractiveLogin(new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())); } function it_does_nothing_if_user_uses_the_recommended_encoder( ObjectManager $objectManager, + Request $request, TokenInterface $token, FixtureUser $user ): void { - $event = new InteractiveLoginEvent(new Request(), $token->getWrappedObject()); - $token->getUser()->willReturn($user); $user->getEncoderName()->willReturn('newalgo'); @@ -78,7 +75,7 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior $objectManager->persist($user)->shouldNotBeCalled(); $objectManager->flush()->shouldNotBeCalled(); - $this->onSecurityInteractiveLogin($event); + $this->onSecurityInteractiveLogin(new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())); } function it_does_nothing_if_plain_password_could_not_be_resolved( @@ -86,7 +83,7 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior TokenInterface $token, FixtureUser $user ): void { - $event = new InteractiveLoginEvent(new Request(), $token->getWrappedObject()); + $request = new Request(); $token->getUser()->willReturn($user); @@ -98,7 +95,7 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior $objectManager->persist($user)->shouldNotBeCalled(); $objectManager->flush()->shouldNotBeCalled(); - $this->onSecurityInteractiveLogin($event); + $this->onSecurityInteractiveLogin(new InteractiveLoginEvent($request, $token->getWrappedObject())); } function it_does_nothing_if_resolved_plain_password_is_null( @@ -109,8 +106,6 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior $request = new Request(); $request->request->set('_password', null); - $event = new InteractiveLoginEvent($request, $token->getWrappedObject()); - $token->getUser()->willReturn($user); $user->getEncoderName()->willReturn('oldalgo'); @@ -121,7 +116,7 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior $objectManager->persist($user)->shouldNotBeCalled(); $objectManager->flush()->shouldNotBeCalled(); - $this->onSecurityInteractiveLogin($event); + $this->onSecurityInteractiveLogin(new InteractiveLoginEvent($request, $token->getWrappedObject())); } function it_does_nothing_if_resolved_plain_password_is_empty( @@ -132,8 +127,6 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior $request = new Request(); $request->request->set('_password', ''); - $event = new InteractiveLoginEvent($request, $token->getWrappedObject()); - $token->getUser()->willReturn($user); $user->getEncoderName()->willReturn('oldalgo'); @@ -144,7 +137,7 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior $objectManager->persist($user)->shouldNotBeCalled(); $objectManager->flush()->shouldNotBeCalled(); - $this->onSecurityInteractiveLogin($event); + $this->onSecurityInteractiveLogin(new InteractiveLoginEvent($request, $token->getWrappedObject())); } function it_updates_the_encoder_and_plain_password_if_using_old_encoder_and_plain_password_could_be_resolved( @@ -155,8 +148,6 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior $request = new Request(); $request->request->set('_password', 'plainpassword'); - $event = new InteractiveLoginEvent($request, $token->getWrappedObject()); - $token->getUser()->willReturn($user); $user->getEncoderName()->willReturn('oldalgo'); @@ -167,7 +158,7 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior $objectManager->persist($user)->shouldBeCalled(); $objectManager->flush()->shouldBeCalled(); - $this->onSecurityInteractiveLogin($event); + $this->onSecurityInteractiveLogin(new InteractiveLoginEvent($request, $token->getWrappedObject())); } function it_updates_the_encoder_and_plain_password_if_using_default_null_encoder_and_plain_password_could_be_resolved( @@ -178,8 +169,6 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior $request = new Request(); $request->request->set('_password', 'plainpassword'); - $event = new InteractiveLoginEvent($request, $token->getWrappedObject()); - $token->getUser()->willReturn($user); $user->getEncoderName()->willReturn(null); @@ -190,6 +179,6 @@ final class UpdateUserEncoderListenerSpec extends ObjectBehavior $objectManager->persist($user)->shouldBeCalled(); $objectManager->flush()->shouldBeCalled(); - $this->onSecurityInteractiveLogin($event); + $this->onSecurityInteractiveLogin(new InteractiveLoginEvent($request, $token->getWrappedObject())); } } diff --git a/src/Sylius/Bundle/UserBundle/spec/EventListener/UserLastLoginSubscriberSpec.php b/src/Sylius/Bundle/UserBundle/spec/EventListener/UserLastLoginSubscriberSpec.php index 1305e78b5b..736c720a21 100644 --- a/src/Sylius/Bundle/UserBundle/spec/EventListener/UserLastLoginSubscriberSpec.php +++ b/src/Sylius/Bundle/UserBundle/spec/EventListener/UserLastLoginSubscriberSpec.php @@ -48,10 +48,10 @@ final class UserLastLoginSubscriberSpec extends ObjectBehavior function it_updates_user_last_login_on_security_interactive_login( ObjectManager $userManager, + Request $request, TokenInterface $token, UserInterface $user ): void { - $event = new InteractiveLoginEvent(new Request(), $token->getWrappedObject()); $token->getUser()->willReturn($user); $user->setLastLogin(Argument::type(\DateTimeInterface::class))->shouldBeCalled(); @@ -59,7 +59,7 @@ final class UserLastLoginSubscriberSpec extends ObjectBehavior $userManager->persist($user)->shouldBeCalled(); $userManager->flush()->shouldBeCalled(); - $this->onSecurityInteractiveLogin($event); + $this->onSecurityInteractiveLogin(new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())); } function it_updates_user_last_login_on_implicit_login( @@ -96,12 +96,12 @@ final class UserLastLoginSubscriberSpec extends ObjectBehavior function it_updates_only_user_specified_in_constructor( ObjectManager $userManager, UserEvent $event, + Request $request, TokenInterface $token, SymfonyUserInterface $user ): void { $this->beConstructedWith($userManager, 'FakeBundle\User\Model\User'); - $interactiveLoginEvent = new InteractiveLoginEvent(new Request(), $token->getWrappedObject()); $token->getUser()->willReturn($user); $event->getUser()->willReturn($user); @@ -109,22 +109,25 @@ final class UserLastLoginSubscriberSpec extends ObjectBehavior $userManager->persist(Argument::any())->shouldNotBeCalled(); $userManager->flush()->shouldNotBeCalled(); - $this->onSecurityInteractiveLogin($interactiveLoginEvent); + $this->onSecurityInteractiveLogin(new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())); } function it_throws_exception_if_subscriber_is_used_for_class_other_than_sylius_user_interface( ObjectManager $userManager, + Request $request, TokenInterface $token, SymfonyUserInterface $user ): void { $this->beConstructedWith($userManager, SymfonyUserInterface::class); - $interactiveLoginEvent = new InteractiveLoginEvent(new Request(), $token->getWrappedObject()); $token->getUser()->willReturn($user); $userManager->persist(Argument::any())->shouldNotBeCalled(); $userManager->flush()->shouldNotBeCalled(); - $this->shouldThrow(\UnexpectedValueException::class)->during('onSecurityInteractiveLogin', [$interactiveLoginEvent]); + $this + ->shouldThrow(\UnexpectedValueException::class) + ->during('onSecurityInteractiveLogin', [new InteractiveLoginEvent($request->getWrappedObject(), $token->getWrappedObject())]) + ; } } From 2d65663328e4b31b356008ed1311a565a1af795a Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 13 Jan 2021 08:18:41 +0100 Subject: [PATCH 35/55] Remove unnecessary "sylius.translator.listener" service --- .../CoreBundle/Resources/config/services/listeners.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/services/listeners.xml b/src/Sylius/Bundle/CoreBundle/Resources/config/services/listeners.xml index 3d40071329..f9c597dd80 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/services/listeners.xml +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/services/listeners.xml @@ -72,11 +72,6 @@ - - - - - From c9ffd5199426b4fa041e88bc594d44866b7d3a59 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 13 Jan 2021 09:12:48 +0100 Subject: [PATCH 36/55] [CoreBundle] Fix mocks of ExceptionEvent in tests --- ...rDependencyBreakingExceptionListenerTest.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Sylius/Bundle/CoreBundle/Tests/Listener/CircularDependencyBreakingExceptionListenerTest.php b/src/Sylius/Bundle/CoreBundle/Tests/Listener/CircularDependencyBreakingExceptionListenerTest.php index b2c70ebbf0..732756bf41 100644 --- a/src/Sylius/Bundle/CoreBundle/Tests/Listener/CircularDependencyBreakingExceptionListenerTest.php +++ b/src/Sylius/Bundle/CoreBundle/Tests/Listener/CircularDependencyBreakingExceptionListenerTest.php @@ -16,8 +16,10 @@ namespace Sylius\Bundle\CoreBundle\Tests\Listener; use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; use Sylius\Bundle\CoreBundle\EventListener\CircularDependencyBreakingErrorListener; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Symfony\Component\HttpKernel\EventListener\ErrorListener; +use Symfony\Component\HttpKernel\HttpKernelInterface; final class CircularDependencyBreakingExceptionListenerTest extends TestCase { @@ -28,7 +30,7 @@ final class CircularDependencyBreakingExceptionListenerTest extends TestCase $decoratedListener = $this->createMock(ErrorListener::class); $listener = new CircularDependencyBreakingErrorListener($decoratedListener); - $event = $this->createMock(ExceptionEvent::class); + $event = $this->createExceptionEvent(); $secondException = new \Exception('Second'); $firstException = new \Exception('First', 0, $secondException); @@ -62,7 +64,7 @@ final class CircularDependencyBreakingExceptionListenerTest extends TestCase $decoratedListener = $this->createMock(ErrorListener::class); $listener = new CircularDependencyBreakingErrorListener($decoratedListener); - $event = $this->createMock(ExceptionEvent::class); + $event = $this->createExceptionEvent(); $fourthException = new \Exception('Fourth'); $thirdException = new \Exception('Third', 0, $fourthException); @@ -102,7 +104,7 @@ final class CircularDependencyBreakingExceptionListenerTest extends TestCase $decoratedListener = $this->createMock(ErrorListener::class); $listener = new CircularDependencyBreakingErrorListener($decoratedListener); - $event = $this->createMock(ExceptionEvent::class); + $event = $this->createExceptionEvent(); $secondException = new \Exception('Second'); $firstException = new \Exception('First', 0, $secondException); @@ -134,4 +136,13 @@ final class CircularDependencyBreakingExceptionListenerTest extends TestCase $property->setAccessible(true); $property->setValue($exception, $previous); } + + private function createExceptionEvent(): ExceptionEvent + { + $kernel = $this->createMock(HttpKernelInterface::class); + $request = $this->createMock(Request::class); + $exception = new \Exception(); + + return new ExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $exception); + } } From bd41054e18c0dabd21e66969426e412e8dd8c73e Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 13 Jan 2021 09:14:14 +0100 Subject: [PATCH 37/55] [CoreBundle] Prevent from polluting the filesystem with test application cache and logs --- src/Sylius/Bundle/CoreBundle/Tests/TestKernel.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Sylius/Bundle/CoreBundle/Tests/TestKernel.php b/src/Sylius/Bundle/CoreBundle/Tests/TestKernel.php index cceb2af3e5..282d2ebc21 100644 --- a/src/Sylius/Bundle/CoreBundle/Tests/TestKernel.php +++ b/src/Sylius/Bundle/CoreBundle/Tests/TestKernel.php @@ -173,4 +173,14 @@ final class TestKernel extends BaseKernel protected function configureRoutes(RoutingConfigurator $routes): void { } + + public function getCacheDir(): string + { + return sys_get_temp_dir() . '/SyliusCoreBundle/cache/' . $this->getEnvironment(); + } + + public function getLogDir(): string + { + return sys_get_temp_dir() . '/SyliusCoreBundle/logs'; + } } From 75f070fc38371bca909da72af2c5e888239be710 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 13 Jan 2021 09:14:42 +0100 Subject: [PATCH 38/55] [CoreBundle] Ignore PHPUnit result cache in Git --- src/Sylius/Bundle/CoreBundle/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Sylius/Bundle/CoreBundle/.gitignore b/src/Sylius/Bundle/CoreBundle/.gitignore index ae840f0924..5081a08983 100644 --- a/src/Sylius/Bundle/CoreBundle/.gitignore +++ b/src/Sylius/Bundle/CoreBundle/.gitignore @@ -6,3 +6,4 @@ /phpunit.xml /phpspec.yml +/.phpunit.result.cache From 16e99feb062863d693418b3bbc667ac784e93c53 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 13 Jan 2021 09:16:17 +0100 Subject: [PATCH 39/55] [CoreBundle] Fix payment method fixture configuration test --- .../CoreBundle/Tests/Fixture/PaymentMethodFixtureTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sylius/Bundle/CoreBundle/Tests/Fixture/PaymentMethodFixtureTest.php b/src/Sylius/Bundle/CoreBundle/Tests/Fixture/PaymentMethodFixtureTest.php index 4d12c36acb..55a8b981ec 100644 --- a/src/Sylius/Bundle/CoreBundle/Tests/Fixture/PaymentMethodFixtureTest.php +++ b/src/Sylius/Bundle/CoreBundle/Tests/Fixture/PaymentMethodFixtureTest.php @@ -78,7 +78,7 @@ final class PaymentMethodFixtureTest extends TestCase public function payment_method_instructions_configuration_must_by_string(): void { $this->assertConfigurationIsValid([['custom' => [['instructions' => 'test']]]], 'custom.*.instructions'); - $this->assertConfigurationIsInvalid([['custom' => [['instructions' => ['test']]]]], 'Invalid type for path "payment_method.custom.0.instructions". Expected scalar, but got array'); + $this->assertConfigurationIsInvalid([['custom' => [['instructions' => ['test']]]]]); } /** @@ -115,7 +115,7 @@ final class PaymentMethodFixtureTest extends TestCase public function payment_method_gateway_configuration_must_by_array(): void { $this->assertConfigurationIsValid([['custom' => [['gatewayConfig' => ['username' => 'USERNAME']]]]], 'custom.*.gatewayConfig'); - $this->assertConfigurationIsInvalid([['custom' => [['gatewayConfig' => 'USERNAME']]]], 'Invalid type for path "payment_method.custom.0.gatewayConfig". Expected array, but got string'); + $this->assertConfigurationIsInvalid([['custom' => [['gatewayConfig' => 'USERNAME']]]]); } /** From a74f084862918d3604f8bde4dd48012838f5d01a Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 13 Jan 2021 09:39:34 +0100 Subject: [PATCH 40/55] Require sylius/theme-bundle ^2.1.1 which supports Symfony 5 --- composer.json | 2 +- src/Sylius/Bundle/CoreBundle/composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 2a2d97db24..ffdceac8fb 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,7 @@ "sylius/registry": "^1.5", "sylius/resource": "^1.7", "sylius/resource-bundle": "^1.7", - "sylius/theme-bundle": "^2.1", + "sylius/theme-bundle": "^2.1.1", "symfony/asset": "^4.4 || ^5.2", "symfony/config": "^4.4 || ^5.2", "symfony/console": "^4.4 || ^5.2", diff --git a/src/Sylius/Bundle/CoreBundle/composer.json b/src/Sylius/Bundle/CoreBundle/composer.json index 864756c7cd..64cbf098db 100644 --- a/src/Sylius/Bundle/CoreBundle/composer.json +++ b/src/Sylius/Bundle/CoreBundle/composer.json @@ -60,7 +60,7 @@ "sylius/shipping-bundle": "^1.6", "sylius/taxation-bundle": "^1.6", "sylius/taxonomy-bundle": "^1.6", - "sylius/theme-bundle": "^2.1", + "sylius/theme-bundle": "^2.1.1", "sylius/ui-bundle": "^1.6", "sylius/user-bundle": "^1.6", "symfony/framework-bundle": "^4.4 || ^5.2", From a32efb3af0baa77fece8cf173c260376b80e61bc Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 13 Jan 2021 09:47:13 +0100 Subject: [PATCH 41/55] Do not pass int form keys, cast them to string instead --- .../Configuration/SelectAttributeChoicesCollectionType.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Sylius/Bundle/AttributeBundle/Form/Type/AttributeType/Configuration/SelectAttributeChoicesCollectionType.php b/src/Sylius/Bundle/AttributeBundle/Form/Type/AttributeType/Configuration/SelectAttributeChoicesCollectionType.php index 2908433b8e..66fde343fb 100644 --- a/src/Sylius/Bundle/AttributeBundle/Form/Type/AttributeType/Configuration/SelectAttributeChoicesCollectionType.php +++ b/src/Sylius/Bundle/AttributeBundle/Form/Type/AttributeType/Configuration/SelectAttributeChoicesCollectionType.php @@ -53,6 +53,7 @@ class SelectAttributeChoicesCollectionType extends AbstractType continue; } + $key = (string) $key; $newKey = $this->getUniqueKey(); $fixedData[$newKey] = $this->resolveValues($values); From beb414255cc4d2a27eadaf707cea3eeca588fa3a Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 13 Jan 2021 09:51:11 +0100 Subject: [PATCH 42/55] Fix all the rest of event dispatcher calls --- .../Bundle/AdminBundle/Menu/CustomerShowMenuBuilder.php | 4 ++-- src/Sylius/Bundle/AdminBundle/Menu/MainMenuBuilder.php | 2 +- src/Sylius/Bundle/AdminBundle/Menu/OrderShowMenuBuilder.php | 4 ++-- src/Sylius/Bundle/AdminBundle/Menu/ProductFormMenuBuilder.php | 4 ++-- .../Bundle/AdminBundle/Menu/ProductUpdateMenuBuilder.php | 4 ++-- .../Bundle/AdminBundle/Menu/ProductVariantFormMenuBuilder.php | 4 ++-- .../Bundle/AdminBundle/Menu/PromotionUpdateMenuBuilder.php | 4 ++-- src/Sylius/Bundle/CoreBundle/Security/UserImpersonator.php | 2 +- src/Sylius/Bundle/OrderBundle/Controller/OrderController.php | 2 +- src/Sylius/Bundle/ShopBundle/Menu/AccountMenuBuilder.php | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Sylius/Bundle/AdminBundle/Menu/CustomerShowMenuBuilder.php b/src/Sylius/Bundle/AdminBundle/Menu/CustomerShowMenuBuilder.php index c74297f316..20917678d8 100644 --- a/src/Sylius/Bundle/AdminBundle/Menu/CustomerShowMenuBuilder.php +++ b/src/Sylius/Bundle/AdminBundle/Menu/CustomerShowMenuBuilder.php @@ -49,8 +49,8 @@ final class CustomerShowMenuBuilder $this->addChildren($menu, $customer); $this->eventDispatcher->dispatch( - self::EVENT_NAME, - new CustomerShowMenuBuilderEvent($this->factory, $menu, $customer) + new CustomerShowMenuBuilderEvent($this->factory, $menu, $customer), + self::EVENT_NAME ); return $menu; diff --git a/src/Sylius/Bundle/AdminBundle/Menu/MainMenuBuilder.php b/src/Sylius/Bundle/AdminBundle/Menu/MainMenuBuilder.php index e5baf8bad3..e23347e425 100644 --- a/src/Sylius/Bundle/AdminBundle/Menu/MainMenuBuilder.php +++ b/src/Sylius/Bundle/AdminBundle/Menu/MainMenuBuilder.php @@ -44,7 +44,7 @@ final class MainMenuBuilder $this->addMarketingSubMenu($menu); $this->addConfigurationSubMenu($menu); - $this->eventDispatcher->dispatch(self::EVENT_NAME, new MenuBuilderEvent($this->factory, $menu)); + $this->eventDispatcher->dispatch(new MenuBuilderEvent($this->factory, $menu), self::EVENT_NAME); return $menu; } diff --git a/src/Sylius/Bundle/AdminBundle/Menu/OrderShowMenuBuilder.php b/src/Sylius/Bundle/AdminBundle/Menu/OrderShowMenuBuilder.php index fdf9d66c70..32c38fee63 100644 --- a/src/Sylius/Bundle/AdminBundle/Menu/OrderShowMenuBuilder.php +++ b/src/Sylius/Bundle/AdminBundle/Menu/OrderShowMenuBuilder.php @@ -88,8 +88,8 @@ final class OrderShowMenuBuilder } $this->eventDispatcher->dispatch( - self::EVENT_NAME, - new OrderShowMenuBuilderEvent($this->factory, $menu, $order, $stateMachine) + new OrderShowMenuBuilderEvent($this->factory, $menu, $order, $stateMachine), + self::EVENT_NAME ); return $menu; diff --git a/src/Sylius/Bundle/AdminBundle/Menu/ProductFormMenuBuilder.php b/src/Sylius/Bundle/AdminBundle/Menu/ProductFormMenuBuilder.php index f59df6b61d..c14f3f4616 100644 --- a/src/Sylius/Bundle/AdminBundle/Menu/ProductFormMenuBuilder.php +++ b/src/Sylius/Bundle/AdminBundle/Menu/ProductFormMenuBuilder.php @@ -83,8 +83,8 @@ final class ProductFormMenuBuilder } $this->eventDispatcher->dispatch( - self::EVENT_NAME, - new ProductMenuBuilderEvent($this->factory, $menu, $options['product']) + new ProductMenuBuilderEvent($this->factory, $menu, $options['product']), + self::EVENT_NAME ); return $menu; diff --git a/src/Sylius/Bundle/AdminBundle/Menu/ProductUpdateMenuBuilder.php b/src/Sylius/Bundle/AdminBundle/Menu/ProductUpdateMenuBuilder.php index db0f4152f8..406efd14ba 100644 --- a/src/Sylius/Bundle/AdminBundle/Menu/ProductUpdateMenuBuilder.php +++ b/src/Sylius/Bundle/AdminBundle/Menu/ProductUpdateMenuBuilder.php @@ -89,8 +89,8 @@ final class ProductUpdateMenuBuilder $menu->addChild($manageVariantsItem); $this->eventDispatcher->dispatch( - self::EVENT_NAME, - new ProductMenuBuilderEvent($this->factory, $menu, $product) + new ProductMenuBuilderEvent($this->factory, $menu, $product), + self::EVENT_NAME ); return $menu; diff --git a/src/Sylius/Bundle/AdminBundle/Menu/ProductVariantFormMenuBuilder.php b/src/Sylius/Bundle/AdminBundle/Menu/ProductVariantFormMenuBuilder.php index e85516b497..4c953d7d71 100644 --- a/src/Sylius/Bundle/AdminBundle/Menu/ProductVariantFormMenuBuilder.php +++ b/src/Sylius/Bundle/AdminBundle/Menu/ProductVariantFormMenuBuilder.php @@ -63,8 +63,8 @@ final class ProductVariantFormMenuBuilder ; $this->eventDispatcher->dispatch( - self::EVENT_NAME, - new ProductVariantMenuBuilderEvent($this->factory, $menu, $options['product_variant']) + new ProductVariantMenuBuilderEvent($this->factory, $menu, $options['product_variant']), + self::EVENT_NAME ); return $menu; diff --git a/src/Sylius/Bundle/AdminBundle/Menu/PromotionUpdateMenuBuilder.php b/src/Sylius/Bundle/AdminBundle/Menu/PromotionUpdateMenuBuilder.php index 171dd1ffe5..f2611befa8 100644 --- a/src/Sylius/Bundle/AdminBundle/Menu/PromotionUpdateMenuBuilder.php +++ b/src/Sylius/Bundle/AdminBundle/Menu/PromotionUpdateMenuBuilder.php @@ -46,8 +46,8 @@ final class PromotionUpdateMenuBuilder $this->addChildren($menu, $promotion); $this->eventDispatcher->dispatch( - self::EVENT_NAME, - new PromotionMenuBuilderEvent($this->factory, $menu, $promotion) + new PromotionMenuBuilderEvent($this->factory, $menu, $promotion), + self::EVENT_NAME ); return $menu; diff --git a/src/Sylius/Bundle/CoreBundle/Security/UserImpersonator.php b/src/Sylius/Bundle/CoreBundle/Security/UserImpersonator.php index 6873e33b0d..4fc6b4ee12 100644 --- a/src/Sylius/Bundle/CoreBundle/Security/UserImpersonator.php +++ b/src/Sylius/Bundle/CoreBundle/Security/UserImpersonator.php @@ -48,6 +48,6 @@ final class UserImpersonator implements UserImpersonatorInterface $this->session->set($this->sessionTokenParameter, serialize($token)); $this->session->save(); - $this->eventDispatcher->dispatch(UserEvents::SECURITY_IMPERSONATE, new UserEvent($user)); + $this->eventDispatcher->dispatch(new UserEvent($user), UserEvents::SECURITY_IMPERSONATE); } } diff --git a/src/Sylius/Bundle/OrderBundle/Controller/OrderController.php b/src/Sylius/Bundle/OrderBundle/Controller/OrderController.php index 1d391440af..d8ada79717 100644 --- a/src/Sylius/Bundle/OrderBundle/Controller/OrderController.php +++ b/src/Sylius/Bundle/OrderBundle/Controller/OrderController.php @@ -100,7 +100,7 @@ class OrderController extends ResourceController $this->eventDispatcher->dispatchPostEvent(ResourceActions::UPDATE, $configuration, $resource); - $this->getEventDispatcher()->dispatch(SyliusCartEvents::CART_CHANGE, new GenericEvent($resource)); + $this->getEventDispatcher()->dispatch(new GenericEvent($resource), SyliusCartEvents::CART_CHANGE); $this->manager->flush(); if (!$configuration->isHtmlRequest()) { diff --git a/src/Sylius/Bundle/ShopBundle/Menu/AccountMenuBuilder.php b/src/Sylius/Bundle/ShopBundle/Menu/AccountMenuBuilder.php index 8f950f388e..db9bd88877 100644 --- a/src/Sylius/Bundle/ShopBundle/Menu/AccountMenuBuilder.php +++ b/src/Sylius/Bundle/ShopBundle/Menu/AccountMenuBuilder.php @@ -65,7 +65,7 @@ final class AccountMenuBuilder ->setLabelAttribute('icon', 'cart') ; - $this->eventDispatcher->dispatch(self::EVENT_NAME, new MenuBuilderEvent($this->factory, $menu)); + $this->eventDispatcher->dispatch(new MenuBuilderEvent($this->factory, $menu), self::EVENT_NAME); return $menu; } From ca218e6886a7059f6669d805b5cdd42df3c369e5 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 13 Jan 2021 12:12:09 +0100 Subject: [PATCH 43/55] Account for plain password being null in Symfony 5 --- .../Component/User/Security/PasswordUpdater.php | 2 +- .../User/spec/Security/PasswordUpdaterSpec.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Sylius/Component/User/Security/PasswordUpdater.php b/src/Sylius/Component/User/Security/PasswordUpdater.php index 441af090d0..ad4b4229f6 100644 --- a/src/Sylius/Component/User/Security/PasswordUpdater.php +++ b/src/Sylius/Component/User/Security/PasswordUpdater.php @@ -27,7 +27,7 @@ final class PasswordUpdater implements PasswordUpdaterInterface public function updatePassword(CredentialsHolderInterface $user): void { - if ('' !== $user->getPlainPassword()) { + if (!in_array($user->getPlainPassword(), ['', null], true)) { $user->setPassword($this->userPasswordEncoder->encode($user)); $user->eraseCredentials(); } diff --git a/src/Sylius/Component/User/spec/Security/PasswordUpdaterSpec.php b/src/Sylius/Component/User/spec/Security/PasswordUpdaterSpec.php index 90c27b7591..d17131f368 100644 --- a/src/Sylius/Component/User/spec/Security/PasswordUpdaterSpec.php +++ b/src/Sylius/Component/User/spec/Security/PasswordUpdaterSpec.php @@ -54,4 +54,16 @@ final class PasswordUpdaterSpec extends ObjectBehavior $this->updatePassword($user); } + + function it_does_nothing_if_plain_password_is_null(UserPasswordEncoderInterface $userPasswordEncoder, UserInterface $user): void + { + $user->getPlainPassword()->willReturn(null); + + $userPasswordEncoder->encode($user)->willReturn('topSecretEncodedPassword'); + + $user->setPassword(Argument::any())->shouldNotBeCalled(); + $user->eraseCredentials()->shouldNotBeCalled(); + + $this->updatePassword($user); + } } From ac2d41aa68436ece5817a704f117117a08cbbb6f Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 13 Jan 2021 12:16:51 +0100 Subject: [PATCH 44/55] Fix ZoneType choice_filter --- src/Sylius/Bundle/AddressingBundle/Form/Type/ZoneType.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sylius/Bundle/AddressingBundle/Form/Type/ZoneType.php b/src/Sylius/Bundle/AddressingBundle/Form/Type/ZoneType.php index 8b92a2917f..93a1b91e50 100644 --- a/src/Sylius/Bundle/AddressingBundle/Form/Type/ZoneType.php +++ b/src/Sylius/Bundle/AddressingBundle/Form/Type/ZoneType.php @@ -72,8 +72,8 @@ final class ZoneType extends AbstractResourceType ]; if ($zone->getType() === ZoneInterface::TYPE_ZONE) { - $entryOptions['entry_options']['choice_filter'] = function (ZoneInterface $subZone) use ($zone): bool { - return $zone->getId() !== $subZone->getId(); + $entryOptions['entry_options']['choice_filter'] = static function (?ZoneInterface $subZone) use ($zone): bool { + return $subZone !== null && $zone->getId() !== $subZone->getId(); }; } From c03b3f61806a9cbc09e17df9d5d278da2c4811fb Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 13 Jan 2021 12:21:04 +0100 Subject: [PATCH 45/55] Do not use integer keys in forms - ChangePaymentMethodType --- .../CoreBundle/Form/Type/Checkout/ChangePaymentMethodType.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sylius/Bundle/CoreBundle/Form/Type/Checkout/ChangePaymentMethodType.php b/src/Sylius/Bundle/CoreBundle/Form/Type/Checkout/ChangePaymentMethodType.php index 023bc2e437..5e3787df59 100644 --- a/src/Sylius/Bundle/CoreBundle/Form/Type/Checkout/ChangePaymentMethodType.php +++ b/src/Sylius/Bundle/CoreBundle/Form/Type/Checkout/ChangePaymentMethodType.php @@ -29,8 +29,8 @@ final class ChangePaymentMethodType extends AbstractType $form = $event->getForm(); foreach ($payments as $key => $payment) { - if (!in_array($payment->getState(), [PaymentInterface::STATE_NEW, PaymentInterface::STATE_CART])) { - $form->remove($key); + if (!in_array($payment->getState(), [PaymentInterface::STATE_NEW, PaymentInterface::STATE_CART], true)) { + $form->remove((string) $key); } } }); From f5f9284c108e4c23611290d2750089a54961f36a Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 14 Jan 2021 12:06:03 +0100 Subject: [PATCH 46/55] Make index.php compatible with Symfony 5 --- public/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.php b/public/index.php index 7509d6ad2b..db05775c9f 100644 --- a/public/index.php +++ b/public/index.php @@ -3,7 +3,7 @@ declare(strict_types=1); use App\Kernel; -use Symfony\Component\Debug\Debug; +use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\HttpFoundation\Request; require dirname(__DIR__) . '/config/bootstrap.php'; From cf2b90e0b7e50ac4b5b62abff0aaa872c8238055 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 14 Jan 2021 12:11:07 +0100 Subject: [PATCH 47/55] Fix products edit page by not rendering the same field twice --- .../Resources/views/Product/Tab/_details.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Product/Tab/_details.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Product/Tab/_details.html.twig index 835dbd5e61..7bb8f43a57 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Product/Tab/_details.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Product/Tab/_details.html.twig @@ -22,8 +22,8 @@ @@ -34,7 +34,7 @@ {% if product.simple %}
-

{{ 'sylius.ui.pricing'|trans }}

+

{{ 'sylius.ui.pricing'|trans }}

{% include "@SyliusAdmin/Product/_channel_pricing.html.twig" with { product: product, variantForm: form.variant } only %}
From c18f11efacaaab12b1c507b628e089061d52a639 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 14 Jan 2021 12:40:50 +0100 Subject: [PATCH 48/55] Fix inifite loop caused by form widget theme block rendering itself --- .../Bundle/UiBundle/Resources/views/Form/theme.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sylius/Bundle/UiBundle/Resources/views/Form/theme.html.twig b/src/Sylius/Bundle/UiBundle/Resources/views/Form/theme.html.twig index 64e9fd2a41..300a5cc3f6 100644 --- a/src/Sylius/Bundle/UiBundle/Resources/views/Form/theme.html.twig +++ b/src/Sylius/Bundle/UiBundle/Resources/views/Form/theme.html.twig @@ -150,13 +150,13 @@ {% block sylius_promotion_rule_widget %}
- {{ form_widget(form) }} + {{ block('form_widget') }}
{% endblock %} {% block sylius_promotion_action_widget %}
- {{ form_widget(form) }} + {{ block('form_widget') }}
{% endblock %} From e9e191bb4e9d7a8de8d9f67fbc8cb336f5c764bb Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 14 Jan 2021 15:16:00 +0100 Subject: [PATCH 49/55] Fix redirects using Symfony's RedirectController --- docs/cookbook/shop/checkout.rst | 2 +- .../Bundle/AdminBundle/Resources/config/routing/taxon.yml | 2 +- .../Bundle/ShopBundle/Resources/config/routing/account.yml | 2 +- .../Bundle/ShopBundle/Resources/config/routing/checkout.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/cookbook/shop/checkout.rst b/docs/cookbook/shop/checkout.rst index 67621a622d..7721c8ee69 100644 --- a/docs/cookbook/shop/checkout.rst +++ b/docs/cookbook/shop/checkout.rst @@ -203,7 +203,7 @@ to the ``app/Resources/SyliusShopBundle/config/routing/checkout.yml`` file. path: / methods: [GET] defaults: - _controller: FrameworkBundle:Redirect:redirect + _controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController:redirectAction route: sylius_shop_checkout_address sylius_shop_checkout_address: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/taxon.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/taxon.yml index 6c5bc92326..0e037ad7c6 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/taxon.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/taxon.yml @@ -17,7 +17,7 @@ sylius_admin_taxon_index: path: /taxons/ methods: [GET] defaults: - _controller: FrameworkBundle:Redirect:redirect + _controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController:redirectAction route: sylius_admin_taxon_create permanent: true diff --git a/src/Sylius/Bundle/ShopBundle/Resources/config/routing/account.yml b/src/Sylius/Bundle/ShopBundle/Resources/config/routing/account.yml index 84f60b2e3b..a4b7d46afe 100644 --- a/src/Sylius/Bundle/ShopBundle/Resources/config/routing/account.yml +++ b/src/Sylius/Bundle/ShopBundle/Resources/config/routing/account.yml @@ -13,7 +13,7 @@ sylius_shop_account_root: path: / methods: [GET] defaults: - _controller: FrameworkBundle:Redirect:redirect + _controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController:redirectAction route: sylius_shop_account_dashboard permanent: true diff --git a/src/Sylius/Bundle/ShopBundle/Resources/config/routing/checkout.yml b/src/Sylius/Bundle/ShopBundle/Resources/config/routing/checkout.yml index fee098e0c9..3e71c66223 100644 --- a/src/Sylius/Bundle/ShopBundle/Resources/config/routing/checkout.yml +++ b/src/Sylius/Bundle/ShopBundle/Resources/config/routing/checkout.yml @@ -5,7 +5,7 @@ sylius_shop_checkout_start: path: / methods: [GET] defaults: - _controller: FrameworkBundle:Redirect:redirect + _controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController:redirectAction route: sylius_shop_checkout_address sylius_shop_checkout_address: From 9a6e0d414a25ac8eb6dac55e53efe0b0b9cf08ee Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Mon, 18 Jan 2021 15:11:50 +0100 Subject: [PATCH 50/55] [PayumBundle] Fix application crash while capturing payments --- .../InjectContainerIntoControllersPass.php | 46 +++++++++++++++++++ .../UseTweakedDoctrineStoragePass.php | 3 ++ .../SyliusPayumExtension.php | 24 ++++++++++ .../Bundle/PayumBundle/SyliusPayumBundle.php | 2 + 4 files changed, 75 insertions(+) create mode 100644 src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/InjectContainerIntoControllersPass.php diff --git a/src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/InjectContainerIntoControllersPass.php b/src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/InjectContainerIntoControllersPass.php new file mode 100644 index 0000000000..cd2d0e3592 --- /dev/null +++ b/src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/InjectContainerIntoControllersPass.php @@ -0,0 +1,46 @@ +findDefinition($service); + } catch (ServiceNotFoundException $exception) { + $definition = new Definition($service); + + $container->setDefinition($service, $definition); + } + + $definition->addMethodCall('setContainer', [new Reference('service_container')]); + $definition->setPublic(true); + } + } +} diff --git a/src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/UseTweakedDoctrineStoragePass.php b/src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/UseTweakedDoctrineStoragePass.php index 43b9636e01..bf562e44a5 100644 --- a/src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/UseTweakedDoctrineStoragePass.php +++ b/src/Sylius/Bundle/PayumBundle/DependencyInjection/Compiler/UseTweakedDoctrineStoragePass.php @@ -8,6 +8,9 @@ use Sylius\Bundle\PayumBundle\Storage\DoctrineStorage; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; +/** + * @internal + */ final class UseTweakedDoctrineStoragePass implements CompilerPassInterface { public function process(ContainerBuilder $container): void diff --git a/src/Sylius/Bundle/PayumBundle/DependencyInjection/SyliusPayumExtension.php b/src/Sylius/Bundle/PayumBundle/DependencyInjection/SyliusPayumExtension.php index b1f3613ac6..ada1d6302c 100644 --- a/src/Sylius/Bundle/PayumBundle/DependencyInjection/SyliusPayumExtension.php +++ b/src/Sylius/Bundle/PayumBundle/DependencyInjection/SyliusPayumExtension.php @@ -13,11 +13,15 @@ declare(strict_types=1); namespace Sylius\Bundle\PayumBundle\DependencyInjection; +use Payum\Bundle\PayumBundle\Controller; use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\DependencyInjection\Reference; final class SyliusPayumExtension extends AbstractResourceExtension implements PrependExtensionInterface { @@ -30,6 +34,26 @@ final class SyliusPayumExtension extends AbstractResourceExtension implements Pr $loader->load('services.xml'); +// $services = [ +// Controller\AuthorizeController::class, +// Controller\CancelController::class, +// Controller\CaptureController::class, +// Controller\NotifyController::class, +// Controller\PayoutController::class, +// Controller\RefundController::class, +// Controller\SyncController::class, +// ]; +// +// foreach ($services as $service) { +// try { +// $definition = $container->findDefinition($service); +// } catch (ServiceNotFoundException $exception) { +// $definition = new Definition($service); +// } +// +// $definition->addMethodCall('setContainer', [new Reference('service_container')]); +// } + $container->setParameter('payum.template.layout', $config['template']['layout']); $container->setParameter('payum.template.obtain_credit_card', $config['template']['obtain_credit_card']); } diff --git a/src/Sylius/Bundle/PayumBundle/SyliusPayumBundle.php b/src/Sylius/Bundle/PayumBundle/SyliusPayumBundle.php index d0c5b63dbb..ec9939c122 100644 --- a/src/Sylius/Bundle/PayumBundle/SyliusPayumBundle.php +++ b/src/Sylius/Bundle/PayumBundle/SyliusPayumBundle.php @@ -13,6 +13,7 @@ declare(strict_types=1); namespace Sylius\Bundle\PayumBundle; +use Sylius\Bundle\PayumBundle\DependencyInjection\Compiler\InjectContainerIntoControllersPass; use Sylius\Bundle\PayumBundle\DependencyInjection\Compiler\RegisterGatewayConfigTypePass; use Sylius\Bundle\PayumBundle\DependencyInjection\Compiler\UseTweakedDoctrineStoragePass; use Sylius\Bundle\ResourceBundle\AbstractResourceBundle; @@ -32,6 +33,7 @@ final class SyliusPayumBundle extends AbstractResourceBundle { parent::build($container); + $container->addCompilerPass(new InjectContainerIntoControllersPass()); $container->addCompilerPass(new RegisterGatewayConfigTypePass()); $container->addCompilerPass(new UseTweakedDoctrineStoragePass()); } From eb40b5a6798067ab02298fb0094cf0194a1deca2 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 21 Jan 2021 11:00:51 +0100 Subject: [PATCH 51/55] [ApiBundle] Fix the issue with too few arguments passed to has* methods Ref: https://github.com/symfony/symfony/issues/39885 --- phpstan.neon | 4 + psalm.xml | 1 + .../ReflectionExtractorHotfixPass.php | 35 + .../Extractor/ReflectionExtractor.php | 848 ++++++++++++++++++ .../Bundle/ApiBundle/SyliusApiBundle.php | 4 +- 5 files changed, 891 insertions(+), 1 deletion(-) create mode 100644 src/Sylius/Bundle/ApiBundle/DependencyInjection/Compiler/ReflectionExtractorHotfixPass.php create mode 100644 src/Sylius/Bundle/ApiBundle/PropertyInfo/Extractor/ReflectionExtractor.php diff --git a/phpstan.neon b/phpstan.neon index e337b3df85..c170f33e95 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -19,5 +19,9 @@ parameters: # Deprecated classes - 'src/Sylius/Bundle/CoreBundle/Application/Kernel.php' + # Symfony 5.1+ hotfixes + - 'src/Sylius/Bundle/ApiBundle/DependencyInjection/Compiler/ReflectionExtractorHotfixPass.php' + - 'src/Sylius/Bundle/ApiBundle/PropertyInfo/Extractor/ReflectionExtractor.php' + ignoreErrors: - '/Access to an undefined property Doctrine\\Common\\Collections\\ArrayCollection/' diff --git a/psalm.xml b/psalm.xml index 1aacaffe2d..af5b8ed304 100644 --- a/psalm.xml +++ b/psalm.xml @@ -11,6 +11,7 @@ + diff --git a/src/Sylius/Bundle/ApiBundle/DependencyInjection/Compiler/ReflectionExtractorHotfixPass.php b/src/Sylius/Bundle/ApiBundle/DependencyInjection/Compiler/ReflectionExtractorHotfixPass.php new file mode 100644 index 0000000000..2d033e39ad --- /dev/null +++ b/src/Sylius/Bundle/ApiBundle/DependencyInjection/Compiler/ReflectionExtractorHotfixPass.php @@ -0,0 +1,35 @@ +findDefinition('property_info.reflection_extractor')->setClass(ReflectionExtractor::class); + } catch (ServiceNotFoundException $exception) { + return; + } + } +} diff --git a/src/Sylius/Bundle/ApiBundle/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Sylius/Bundle/ApiBundle/PropertyInfo/Extractor/ReflectionExtractor.php new file mode 100644 index 0000000000..7625eef3bd --- /dev/null +++ b/src/Sylius/Bundle/ApiBundle/PropertyInfo/Extractor/ReflectionExtractor.php @@ -0,0 +1,848 @@ + Type::BUILTIN_TYPE_INT, + 'boolean' => Type::BUILTIN_TYPE_BOOL, + 'double' => Type::BUILTIN_TYPE_FLOAT, + ]; + + private $mutatorPrefixes; + private $accessorPrefixes; + private $arrayMutatorPrefixes; + private $enableConstructorExtraction; + private $methodReflectionFlags; + private $magicMethodsFlags; + private $propertyReflectionFlags; + private $inflector; + + private $arrayMutatorPrefixesFirst; + private $arrayMutatorPrefixesLast; + + /** + * @param string[]|null $mutatorPrefixes + * @param string[]|null $accessorPrefixes + * @param string[]|null $arrayMutatorPrefixes + */ + public function __construct(array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null, bool $enableConstructorExtraction = true, int $accessFlags = self::ALLOW_PUBLIC, InflectorInterface $inflector = null, int $magicMethodsFlags = self::ALLOW_MAGIC_GET | self::ALLOW_MAGIC_SET) + { + $this->mutatorPrefixes = null !== $mutatorPrefixes ? $mutatorPrefixes : self::$defaultMutatorPrefixes; + $this->accessorPrefixes = null !== $accessorPrefixes ? $accessorPrefixes : self::$defaultAccessorPrefixes; + $this->arrayMutatorPrefixes = null !== $arrayMutatorPrefixes ? $arrayMutatorPrefixes : self::$defaultArrayMutatorPrefixes; + $this->enableConstructorExtraction = $enableConstructorExtraction; + $this->methodReflectionFlags = $this->getMethodsFlags($accessFlags); + $this->propertyReflectionFlags = $this->getPropertyFlags($accessFlags); + $this->magicMethodsFlags = $magicMethodsFlags; + $this->inflector = $inflector ?? new EnglishInflector(); + + $this->arrayMutatorPrefixesFirst = array_merge($this->arrayMutatorPrefixes, array_diff($this->mutatorPrefixes, $this->arrayMutatorPrefixes)); + $this->arrayMutatorPrefixesLast = array_reverse($this->arrayMutatorPrefixesFirst); + } + + /** + * {@inheritdoc} + */ + public function getProperties(string $class, array $context = []): ?array + { + try { + $reflectionClass = new \ReflectionClass($class); + } catch (\ReflectionException $e) { + return null; + } + + $reflectionProperties = $reflectionClass->getProperties(); + + $properties = []; + foreach ($reflectionProperties as $reflectionProperty) { + if ($reflectionProperty->getModifiers() & $this->propertyReflectionFlags) { + $properties[$reflectionProperty->name] = $reflectionProperty->name; + } + } + + foreach ($reflectionClass->getMethods($this->methodReflectionFlags) as $reflectionMethod) { + if ($reflectionMethod->isStatic()) { + continue; + } + + $propertyName = $this->getPropertyName($reflectionMethod->name, $reflectionProperties); + if (!$propertyName || isset($properties[$propertyName])) { + continue; + } + if ($reflectionClass->hasProperty($lowerCasedPropertyName = lcfirst($propertyName)) || (!$reflectionClass->hasProperty($propertyName) && !preg_match('/^[A-Z]{2,}/', $propertyName))) { + $propertyName = $lowerCasedPropertyName; + } + $properties[$propertyName] = $propertyName; + } + + return $properties ? array_values($properties) : null; + } + + /** + * {@inheritdoc} + */ + public function getTypes(string $class, string $property, array $context = []): ?array + { + if ($fromMutator = $this->extractFromMutator($class, $property)) { + return $fromMutator; + } + + if ($fromAccessor = $this->extractFromAccessor($class, $property)) { + return $fromAccessor; + } + + if ( + ($context['enable_constructor_extraction'] ?? $this->enableConstructorExtraction) && + $fromConstructor = $this->extractFromConstructor($class, $property) + ) { + return $fromConstructor; + } + + if ($fromDefaultValue = $this->extractFromDefaultValue($class, $property)) { + return $fromDefaultValue; + } + + if (\PHP_VERSION_ID >= 70400) { + try { + $reflectionProperty = new \ReflectionProperty($class, $property); + $type = $reflectionProperty->getType(); + if (null !== $type) { + return $this->extractFromReflectionType($type, $reflectionProperty->getDeclaringClass()); + } + } catch (\ReflectionException $e) { + // noop + } + } + + return null; + } + + /** + * {@inheritdoc} + */ + public function getTypesFromConstructor(string $class, string $property): ?array + { + try { + $reflection = new \ReflectionClass($class); + } catch (\ReflectionException $e) { + return null; + } + if (!$reflectionConstructor = $reflection->getConstructor()) { + return null; + } + if (!$reflectionParameter = $this->getReflectionParameterFromConstructor($property, $reflectionConstructor)) { + return null; + } + if (!$reflectionType = $reflectionParameter->getType()) { + return null; + } + if (!$types = $this->extractFromReflectionType($reflectionType, $reflectionConstructor->getDeclaringClass())) { + return null; + } + + return $types; + } + + private function getReflectionParameterFromConstructor(string $property, \ReflectionMethod $reflectionConstructor): ?\ReflectionParameter + { + $reflectionParameter = null; + foreach ($reflectionConstructor->getParameters() as $reflectionParameter) { + if ($reflectionParameter->getName() === $property) { + return $reflectionParameter; + } + } + + return null; + } + + /** + * {@inheritdoc} + */ + public function isReadable(string $class, string $property, array $context = []): ?bool + { + if ($this->isAllowedProperty($class, $property)) { + return true; + } + + return null !== $this->getReadInfo($class, $property, $context); + } + + /** + * {@inheritdoc} + */ + public function isWritable(string $class, string $property, array $context = []): ?bool + { + if ($this->isAllowedProperty($class, $property)) { + return true; + } + + [$reflectionMethod] = $this->getMutatorMethod($class, $property); + + return null !== $reflectionMethod; + } + + /** + * {@inheritdoc} + */ + public function isInitializable(string $class, string $property, array $context = []): ?bool + { + try { + $reflectionClass = new \ReflectionClass($class); + } catch (\ReflectionException $e) { + return null; + } + + if (!$reflectionClass->isInstantiable()) { + return false; + } + + if ($constructor = $reflectionClass->getConstructor()) { + foreach ($constructor->getParameters() as $parameter) { + if ($property === $parameter->name) { + return true; + } + } + } elseif ($parentClass = $reflectionClass->getParentClass()) { + return $this->isInitializable($parentClass->getName(), $property); + } + + return false; + } + + /** + * {@inheritdoc} + */ + public function getReadInfo(string $class, string $property, array $context = []): ?PropertyReadInfo + { + try { + $reflClass = new \ReflectionClass($class); + } catch (\ReflectionException $e) { + return null; + } + + $allowGetterSetter = $context['enable_getter_setter_extraction'] ?? false; + $magicMethods = $context['enable_magic_methods_extraction'] ?? $this->magicMethodsFlags; + $allowMagicCall = (bool) ($magicMethods & self::ALLOW_MAGIC_CALL); + $allowMagicGet = (bool) ($magicMethods & self::ALLOW_MAGIC_GET); + + if (isset($context['enable_magic_call_extraction'])) { + trigger_deprecation('symfony/property-info', '5.2', 'Using the "enable_magic_call_extraction" context option in "%s()" is deprecated. Use "enable_magic_methods_extraction" instead.', __METHOD__); + + $allowMagicCall = $context['enable_magic_call_extraction'] ?? false; + } + + $hasProperty = $reflClass->hasProperty($property); + $camelProp = $this->camelize($property); + $getsetter = lcfirst($camelProp); // jQuery style, e.g. read: last(), write: last($item) + + foreach ($this->accessorPrefixes as $prefix) { + $methodName = $prefix.$camelProp; + + if ($reflClass->hasMethod($methodName) && $reflClass->getMethod($methodName)->getModifiers() & $this->methodReflectionFlags && !$reflClass->getMethod($methodName)->getNumberOfRequiredParameters()) { + $method = $reflClass->getMethod($methodName); + + return new PropertyReadInfo(PropertyReadInfo::TYPE_METHOD, $methodName, $this->getReadVisiblityForMethod($method), $method->isStatic(), false); + } + } + + if ($allowGetterSetter && $reflClass->hasMethod($getsetter) && ($reflClass->getMethod($getsetter)->getModifiers() & $this->methodReflectionFlags)) { + $method = $reflClass->getMethod($getsetter); + + return new PropertyReadInfo(PropertyReadInfo::TYPE_METHOD, $getsetter, $this->getReadVisiblityForMethod($method), $method->isStatic(), false); + } + + if ($hasProperty && ($reflClass->getProperty($property)->getModifiers() & $this->propertyReflectionFlags)) { + $reflProperty = $reflClass->getProperty($property); + + return new PropertyReadInfo(PropertyReadInfo::TYPE_PROPERTY, $property, $this->getReadVisiblityForProperty($reflProperty), $reflProperty->isStatic(), true); + } + + if ($allowMagicGet && $reflClass->hasMethod('__get') && ($reflClass->getMethod('__get')->getModifiers() & $this->methodReflectionFlags)) { + return new PropertyReadInfo(PropertyReadInfo::TYPE_PROPERTY, $property, PropertyReadInfo::VISIBILITY_PUBLIC, false, false); + } + + if ($allowMagicCall && $reflClass->hasMethod('__call') && ($reflClass->getMethod('__call')->getModifiers() & $this->methodReflectionFlags)) { + return new PropertyReadInfo(PropertyReadInfo::TYPE_METHOD, 'get'.$camelProp, PropertyReadInfo::VISIBILITY_PUBLIC, false, false); + } + + return null; + } + + /** + * {@inheritdoc} + */ + public function getWriteInfo(string $class, string $property, array $context = []): ?PropertyWriteInfo + { + try { + $reflClass = new \ReflectionClass($class); + } catch (\ReflectionException $e) { + return null; + } + + $allowGetterSetter = $context['enable_getter_setter_extraction'] ?? false; + $magicMethods = $context['enable_magic_methods_extraction'] ?? $this->magicMethodsFlags; + $allowMagicCall = (bool) ($magicMethods & self::ALLOW_MAGIC_CALL); + $allowMagicSet = (bool) ($magicMethods & self::ALLOW_MAGIC_SET); + + if (isset($context['enable_magic_call_extraction'])) { + trigger_deprecation('symfony/property-info', '5.2', 'Using the "enable_magic_call_extraction" context option in "%s()" is deprecated. Use "enable_magic_methods_extraction" instead.', __METHOD__); + + $allowMagicCall = $context['enable_magic_call_extraction'] ?? false; + } + + $allowConstruct = $context['enable_constructor_extraction'] ?? $this->enableConstructorExtraction; + $allowAdderRemover = $context['enable_adder_remover_extraction'] ?? true; + + $camelized = $this->camelize($property); + $constructor = $reflClass->getConstructor(); + $singulars = $this->inflector->singularize($camelized); + $errors = []; + + if (null !== $constructor && $allowConstruct) { + foreach ($constructor->getParameters() as $parameter) { + if ($parameter->getName() === $property) { + return new PropertyWriteInfo(PropertyWriteInfo::TYPE_CONSTRUCTOR, $property); + } + } + } + + [$adderAccessName, $removerAccessName, $adderAndRemoverErrors] = $this->findAdderAndRemover($reflClass, $singulars); + if ($allowAdderRemover && null !== $adderAccessName && null !== $removerAccessName) { + $adderMethod = $reflClass->getMethod($adderAccessName); + $removerMethod = $reflClass->getMethod($removerAccessName); + + $mutator = new PropertyWriteInfo(PropertyWriteInfo::TYPE_ADDER_AND_REMOVER); + $mutator->setAdderInfo(new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $adderAccessName, $this->getWriteVisiblityForMethod($adderMethod), $adderMethod->isStatic())); + $mutator->setRemoverInfo(new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $removerAccessName, $this->getWriteVisiblityForMethod($removerMethod), $removerMethod->isStatic())); + + return $mutator; + } + + $errors = array_merge($errors, $adderAndRemoverErrors); + + foreach ($this->mutatorPrefixes as $mutatorPrefix) { + $methodName = $mutatorPrefix.$camelized; + + [$accessible, $methodAccessibleErrors] = $this->isMethodAccessible($reflClass, $methodName, 1); + if (!$accessible) { + $errors = array_merge($errors, $methodAccessibleErrors); + continue; + } + + $method = $reflClass->getMethod($methodName); + + if (!\in_array($mutatorPrefix, $this->arrayMutatorPrefixes, true)) { + return new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $methodName, $this->getWriteVisiblityForMethod($method), $method->isStatic()); + } + } + + $getsetter = lcfirst($camelized); + + if ($allowGetterSetter) { + [$accessible, $methodAccessibleErrors] = $this->isMethodAccessible($reflClass, $getsetter, 1); + if ($accessible) { + $method = $reflClass->getMethod($getsetter); + + return new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $getsetter, $this->getWriteVisiblityForMethod($method), $method->isStatic()); + } + + $errors = array_merge($errors, $methodAccessibleErrors); + } + + if ($reflClass->hasProperty($property) && ($reflClass->getProperty($property)->getModifiers() & $this->propertyReflectionFlags)) { + $reflProperty = $reflClass->getProperty($property); + + return new PropertyWriteInfo(PropertyWriteInfo::TYPE_PROPERTY, $property, $this->getWriteVisiblityForProperty($reflProperty), $reflProperty->isStatic()); + } + + if ($allowMagicSet) { + [$accessible, $methodAccessibleErrors] = $this->isMethodAccessible($reflClass, '__set', 2); + if ($accessible) { + return new PropertyWriteInfo(PropertyWriteInfo::TYPE_PROPERTY, $property, PropertyWriteInfo::VISIBILITY_PUBLIC, false); + } + + $errors = array_merge($errors, $methodAccessibleErrors); + } + + if ($allowMagicCall) { + [$accessible, $methodAccessibleErrors] = $this->isMethodAccessible($reflClass, '__call', 2); + if ($accessible) { + return new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, 'set'.$camelized, PropertyWriteInfo::VISIBILITY_PUBLIC, false); + } + + $errors = array_merge($errors, $methodAccessibleErrors); + } + + if (!$allowAdderRemover && null !== $adderAccessName && null !== $removerAccessName) { + $errors[] = sprintf( + 'The property "%s" in class "%s" can be defined with the methods "%s()" but '. + 'the new value must be an array or an instance of \Traversable', + $property, + $reflClass->getName(), + implode('()", "', [$adderAccessName, $removerAccessName]) + ); + } + + $noneProperty = new PropertyWriteInfo(); + $noneProperty->setErrors($errors); + + return $noneProperty; + } + + /** + * @return Type[]|null + */ + private function extractFromMutator(string $class, string $property): ?array + { + [$reflectionMethod, $prefix] = $this->getMutatorMethod($class, $property); + if (null === $reflectionMethod) { + return null; + } + + $reflectionParameters = $reflectionMethod->getParameters(); + $reflectionParameter = $reflectionParameters[0]; + + if (!$reflectionType = $reflectionParameter->getType()) { + return null; + } + $type = $this->extractFromReflectionType($reflectionType, $reflectionMethod->getDeclaringClass()); + + if (1 === \count($type) && \in_array($prefix, $this->arrayMutatorPrefixes)) { + $type = [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), $type[0])]; + } + + return $type; + } + + /** + * Tries to extract type information from accessors. + * + * @return Type[]|null + */ + private function extractFromAccessor(string $class, string $property): ?array + { + [$reflectionMethod, $prefix] = $this->getAccessorMethod($class, $property); + if (null === $reflectionMethod) { + return null; + } + + if ($reflectionType = $reflectionMethod->getReturnType()) { + return $this->extractFromReflectionType($reflectionType, $reflectionMethod->getDeclaringClass()); + } + + if (\in_array($prefix, ['is', 'can', 'has'])) { + return [new Type(Type::BUILTIN_TYPE_BOOL)]; + } + + return null; + } + + /** + * Tries to extract type information from constructor. + * + * @return Type[]|null + */ + private function extractFromConstructor(string $class, string $property): ?array + { + try { + $reflectionClass = new \ReflectionClass($class); + } catch (\ReflectionException $e) { + return null; + } + + $constructor = $reflectionClass->getConstructor(); + + if (!$constructor) { + return null; + } + + foreach ($constructor->getParameters() as $parameter) { + if ($property !== $parameter->name) { + continue; + } + $reflectionType = $parameter->getType(); + + return $reflectionType ? $this->extractFromReflectionType($reflectionType, $constructor->getDeclaringClass()) : null; + } + + if ($parentClass = $reflectionClass->getParentClass()) { + return $this->extractFromConstructor($parentClass->getName(), $property); + } + + return null; + } + + private function extractFromDefaultValue(string $class, string $property): ?array + { + try { + $reflectionClass = new \ReflectionClass($class); + } catch (\ReflectionException $e) { + return null; + } + + $defaultValue = $reflectionClass->getDefaultProperties()[$property] ?? null; + + if (null === $defaultValue) { + return null; + } + + $type = \gettype($defaultValue); + $type = static::MAP_TYPES[$type] ?? $type; + + return [new Type($type, false, null, Type::BUILTIN_TYPE_ARRAY === $type)]; + } + + private function extractFromReflectionType(\ReflectionType $reflectionType, \ReflectionClass $declaringClass): array + { + $types = []; + $nullable = $reflectionType->allowsNull(); + + foreach ($reflectionType instanceof \ReflectionUnionType ? $reflectionType->getTypes() : [$reflectionType] as $type) { + $phpTypeOrClass = $reflectionType instanceof \ReflectionNamedType ? $reflectionType->getName() : (string) $type; + if ('null' === $phpTypeOrClass || 'mixed' === $phpTypeOrClass) { + continue; + } + + if (Type::BUILTIN_TYPE_ARRAY === $phpTypeOrClass) { + $types[] = new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true); + } elseif ('void' === $phpTypeOrClass) { + $types[] = new Type(Type::BUILTIN_TYPE_NULL, $nullable); + } elseif ($type->isBuiltin()) { + $types[] = new Type($phpTypeOrClass, $nullable); + } else { + $types[] = new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $this->resolveTypeName($phpTypeOrClass, $declaringClass)); + } + } + + return $types; + } + + private function resolveTypeName(string $name, \ReflectionClass $declaringClass): string + { + if ('self' === $lcName = strtolower($name)) { + return $declaringClass->name; + } + if ('parent' === $lcName && $parent = $declaringClass->getParentClass()) { + return $parent->name; + } + + return $name; + } + + private function isAllowedProperty(string $class, string $property): bool + { + try { + $reflectionProperty = new \ReflectionProperty($class, $property); + + return $reflectionProperty->getModifiers() & $this->propertyReflectionFlags; + } catch (\ReflectionException $e) { + // Return false if the property doesn't exist + } + + return false; + } + + /** + * Gets the accessor method. + * + * Returns an array with a the instance of \ReflectionMethod as first key + * and the prefix of the method as second or null if not found. + */ + private function getAccessorMethod(string $class, string $property): ?array + { + $ucProperty = ucfirst($property); + + foreach ($this->accessorPrefixes as $prefix) { + try { + $reflectionMethod = new \ReflectionMethod($class, $prefix.$ucProperty); + if ($reflectionMethod->isStatic()) { + continue; + } + + if (0 === $reflectionMethod->getNumberOfRequiredParameters()) { + return [$reflectionMethod, $prefix]; + } + } catch (\ReflectionException $e) { + // Return null if the property doesn't exist + } + } + + return null; + } + + /** + * Returns an array with a the instance of \ReflectionMethod as first key + * and the prefix of the method as second or null if not found. + */ + private function getMutatorMethod(string $class, string $property): ?array + { + $ucProperty = ucfirst($property); + $ucSingulars = $this->inflector->singularize($ucProperty); + + $mutatorPrefixes = \in_array($ucProperty, $ucSingulars, true) ? $this->arrayMutatorPrefixesLast : $this->arrayMutatorPrefixesFirst; + + foreach ($mutatorPrefixes as $prefix) { + $names = [$ucProperty]; + if (\in_array($prefix, $this->arrayMutatorPrefixes)) { + $names = array_merge($names, $ucSingulars); + } + + foreach ($names as $name) { + try { + $reflectionMethod = new \ReflectionMethod($class, $prefix.$name); + if ($reflectionMethod->isStatic()) { + continue; + } + + // Parameter can be optional to allow things like: method(array $foo = null) + if ($reflectionMethod->getNumberOfParameters() >= 1) { + return [$reflectionMethod, $prefix]; + } + } catch (\ReflectionException $e) { + // Try the next prefix if the method doesn't exist + } + } + } + + return null; + } + + private function getPropertyName(string $methodName, array $reflectionProperties): ?string + { + $pattern = implode('|', array_merge($this->accessorPrefixes, $this->mutatorPrefixes)); + + if ('' !== $pattern && preg_match('/^('.$pattern.')(.+)$/i', $methodName, $matches)) { + if (!\in_array($matches[1], $this->arrayMutatorPrefixes)) { + return $matches[2]; + } + + foreach ($reflectionProperties as $reflectionProperty) { + foreach ($this->inflector->singularize($reflectionProperty->name) as $name) { + if (strtolower($name) === strtolower($matches[2])) { + return $reflectionProperty->name; + } + } + } + + return $matches[2]; + } + + return null; + } + + /** + * Searches for add and remove methods. + * + * @param \ReflectionClass $reflClass The reflection class for the given object + * @param array $singulars The singular form of the property name or null + * + * @return array An array containing the adder and remover when found and errors + */ + private function findAdderAndRemover(\ReflectionClass $reflClass, array $singulars): array + { + if (!\is_array($this->arrayMutatorPrefixes) && 2 !== \count($this->arrayMutatorPrefixes)) { + return [null, null, []]; + } + + [$addPrefix, $removePrefix] = $this->arrayMutatorPrefixes; + $errors = []; + + foreach ($singulars as $singular) { + $addMethod = $addPrefix.$singular; + $removeMethod = $removePrefix.$singular; + + [$addMethodFound, $addMethodAccessibleErrors] = $this->isMethodAccessible($reflClass, $addMethod, 1); + [$removeMethodFound, $removeMethodAccessibleErrors] = $this->isMethodAccessible($reflClass, $removeMethod, 1); + $errors = array_merge($errors, $addMethodAccessibleErrors, $removeMethodAccessibleErrors); + + if ($addMethodFound && $removeMethodFound) { + return [$addMethod, $removeMethod, []]; + } + + if ($addMethodFound && !$removeMethodFound) { + $errors[] = sprintf('The add method "%s" in class "%s" was found, but the corresponding remove method "%s" was not found', $addMethod, $reflClass->getName(), $removeMethod); + } elseif (!$addMethodFound && $removeMethodFound) { + $errors[] = sprintf('The remove method "%s" in class "%s" was found, but the corresponding add method "%s" was not found', $removeMethod, $reflClass->getName(), $addMethod); + } + } + + return [null, null, $errors]; + } + + /** + * Returns whether a method is public and has the number of required parameters and errors. + */ + private function isMethodAccessible(\ReflectionClass $class, string $methodName, int $parameters): array + { + $errors = []; + + if ($class->hasMethod($methodName)) { + $method = $class->getMethod($methodName); + + if (\ReflectionMethod::IS_PUBLIC === $this->methodReflectionFlags && !$method->isPublic()) { + $errors[] = sprintf('The method "%s" in class "%s" was found but does not have public access.', $methodName, $class->getName()); + } elseif ($method->getNumberOfRequiredParameters() > $parameters || $method->getNumberOfParameters() < $parameters) { + $errors[] = sprintf('The method "%s" in class "%s" requires %d arguments, but should accept only %d.', $methodName, $class->getName(), $method->getNumberOfRequiredParameters(), $parameters); + } else { + return [true, $errors]; + } + } + + return [false, $errors]; + } + + /** + * Camelizes a given string. + */ + private function camelize(string $string): string + { + return str_replace(' ', '', ucwords(str_replace('_', ' ', $string))); + } + + /** + * Return allowed reflection method flags. + */ + private function getMethodsFlags(int $accessFlags): int + { + $methodFlags = 0; + + if ($accessFlags & self::ALLOW_PUBLIC) { + $methodFlags |= \ReflectionMethod::IS_PUBLIC; + } + + if ($accessFlags & self::ALLOW_PRIVATE) { + $methodFlags |= \ReflectionMethod::IS_PRIVATE; + } + + if ($accessFlags & self::ALLOW_PROTECTED) { + $methodFlags |= \ReflectionMethod::IS_PROTECTED; + } + + return $methodFlags; + } + + /** + * Return allowed reflection property flags. + */ + private function getPropertyFlags(int $accessFlags): int + { + $propertyFlags = 0; + + if ($accessFlags & self::ALLOW_PUBLIC) { + $propertyFlags |= \ReflectionProperty::IS_PUBLIC; + } + + if ($accessFlags & self::ALLOW_PRIVATE) { + $propertyFlags |= \ReflectionProperty::IS_PRIVATE; + } + + if ($accessFlags & self::ALLOW_PROTECTED) { + $propertyFlags |= \ReflectionProperty::IS_PROTECTED; + } + + return $propertyFlags; + } + + private function getReadVisiblityForProperty(\ReflectionProperty $reflectionProperty): string + { + if ($reflectionProperty->isPrivate()) { + return PropertyReadInfo::VISIBILITY_PRIVATE; + } + + if ($reflectionProperty->isProtected()) { + return PropertyReadInfo::VISIBILITY_PROTECTED; + } + + return PropertyReadInfo::VISIBILITY_PUBLIC; + } + + private function getReadVisiblityForMethod(\ReflectionMethod $reflectionMethod): string + { + if ($reflectionMethod->isPrivate()) { + return PropertyReadInfo::VISIBILITY_PRIVATE; + } + + if ($reflectionMethod->isProtected()) { + return PropertyReadInfo::VISIBILITY_PROTECTED; + } + + return PropertyReadInfo::VISIBILITY_PUBLIC; + } + + private function getWriteVisiblityForProperty(\ReflectionProperty $reflectionProperty): string + { + if ($reflectionProperty->isPrivate()) { + return PropertyWriteInfo::VISIBILITY_PRIVATE; + } + + if ($reflectionProperty->isProtected()) { + return PropertyWriteInfo::VISIBILITY_PROTECTED; + } + + return PropertyWriteInfo::VISIBILITY_PUBLIC; + } + + private function getWriteVisiblityForMethod(\ReflectionMethod $reflectionMethod): string + { + if ($reflectionMethod->isPrivate()) { + return PropertyWriteInfo::VISIBILITY_PRIVATE; + } + + if ($reflectionMethod->isProtected()) { + return PropertyWriteInfo::VISIBILITY_PROTECTED; + } + + return PropertyWriteInfo::VISIBILITY_PUBLIC; + } +} diff --git a/src/Sylius/Bundle/ApiBundle/SyliusApiBundle.php b/src/Sylius/Bundle/ApiBundle/SyliusApiBundle.php index 9c0382d934..7b3c7ff26a 100644 --- a/src/Sylius/Bundle/ApiBundle/SyliusApiBundle.php +++ b/src/Sylius/Bundle/ApiBundle/SyliusApiBundle.php @@ -14,14 +14,16 @@ declare(strict_types=1); namespace Sylius\Bundle\ApiBundle; use Sylius\Bundle\ApiBundle\DependencyInjection\Compiler\CommandDataTransformerPass; +use Sylius\Bundle\ApiBundle\DependencyInjection\Compiler\ReflectionExtractorHotfixPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; /** @experimental */ final class SyliusApiBundle extends Bundle { - public function build(ContainerBuilder $builder) + public function build(ContainerBuilder $builder): void { $builder->addCompilerPass(new CommandDataTransformerPass()); + $builder->addCompilerPass(new ReflectionExtractorHotfixPass()); } } From fdb07fa1ad4c07ba451a5dfb9271d67c60e1d1d5 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 21 Jan 2021 11:11:25 +0100 Subject: [PATCH 52/55] [Behat] Fix theme-related tests --- config/routes/test/routing.yaml | 2 +- config/routes/test_cached/routing.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes/test/routing.yaml b/config/routes/test/routing.yaml index 0ca57d9a04..6a6bd07275 100644 --- a/config/routes/test/routing.yaml +++ b/config/routes/test/routing.yaml @@ -1,5 +1,5 @@ sylius_test_plugin_main: path: /test/main - controller: FrameworkBundle:Template:template + controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction defaults: template: "@SyliusTestPlugin/main.html.twig" diff --git a/config/routes/test_cached/routing.yaml b/config/routes/test_cached/routing.yaml index 0ca57d9a04..6a6bd07275 100644 --- a/config/routes/test_cached/routing.yaml +++ b/config/routes/test_cached/routing.yaml @@ -1,5 +1,5 @@ sylius_test_plugin_main: path: /test/main - controller: FrameworkBundle:Template:template + controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction defaults: template: "@SyliusTestPlugin/main.html.twig" From a91875c277188f8cec8cdb76d5b369e9b8435d46 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 21 Jan 2021 11:12:42 +0100 Subject: [PATCH 53/55] [CI] Remove marking Symfony 5.2 builds as experimental --- .github/workflows/application.yml | 6 ------ .github/workflows/packages.yml | 2 -- 2 files changed, 8 deletions(-) diff --git a/.github/workflows/application.yml b/.github/workflows/application.yml index 23da7fe1ca..e56a6a1e96 100644 --- a/.github/workflows/application.yml +++ b/.github/workflows/application.yml @@ -32,8 +32,6 @@ jobs: php: [7.3, 7.4] symfony: [^4.4, ^5.2] - continue-on-error: ${{ matrix.symfony == '^5.2' }} - steps: - uses: actions/checkout@v2 @@ -123,8 +121,6 @@ jobs: symfony: [^4.4, ^5.2] mysql: [5.7] - continue-on-error: ${{ matrix.symfony == '^5.2' }} - env: APP_ENV: test_cached DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" @@ -254,8 +250,6 @@ jobs: node: [10.x] mysql: [5.7] - continue-on-error: ${{ matrix.symfony == '^5.2' }} - env: APP_ENV: test_cached DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index f0af002df4..6f3f82161a 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -52,8 +52,6 @@ jobs: symfony: [^4.4, ^5.2] package: "${{ fromJson(needs.list.outputs.packages) }}" - continue-on-error: ${{ matrix.symfony == '^5.2' }} - steps: - uses: actions/checkout@v2 From 9f2063695cc2bc482004384ecb3e1529b75ffe13 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 21 Jan 2021 14:45:51 +0100 Subject: [PATCH 54/55] [PayumBundle] Remove commented out code from PayumExtension --- .../SyliusPayumExtension.php | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/src/Sylius/Bundle/PayumBundle/DependencyInjection/SyliusPayumExtension.php b/src/Sylius/Bundle/PayumBundle/DependencyInjection/SyliusPayumExtension.php index ada1d6302c..645f03a95b 100644 --- a/src/Sylius/Bundle/PayumBundle/DependencyInjection/SyliusPayumExtension.php +++ b/src/Sylius/Bundle/PayumBundle/DependencyInjection/SyliusPayumExtension.php @@ -34,26 +34,6 @@ final class SyliusPayumExtension extends AbstractResourceExtension implements Pr $loader->load('services.xml'); -// $services = [ -// Controller\AuthorizeController::class, -// Controller\CancelController::class, -// Controller\CaptureController::class, -// Controller\NotifyController::class, -// Controller\PayoutController::class, -// Controller\RefundController::class, -// Controller\SyncController::class, -// ]; -// -// foreach ($services as $service) { -// try { -// $definition = $container->findDefinition($service); -// } catch (ServiceNotFoundException $exception) { -// $definition = new Definition($service); -// } -// -// $definition->addMethodCall('setContainer', [new Reference('service_container')]); -// } - $container->setParameter('payum.template.layout', $config['template']['layout']); $container->setParameter('payum.template.obtain_credit_card', $config['template']['obtain_credit_card']); } From e6ae947429f89de997131670307e3437bd4e0b97 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 21 Jan 2021 14:54:13 +0100 Subject: [PATCH 55/55] Delete debugging code --- .../Tests/Form/Type/CountryChoiceTypeTest.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php b/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php index b9fca36c09..75e8e6b37c 100644 --- a/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php +++ b/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php @@ -111,11 +111,7 @@ final class CountryChoiceTypeTest extends TypeTestCase ]); $this->assertChoicesLabels(['Poland'], ['choice_filter' => static function (?CountryInterface $country): bool { - if ($country === null) { - return false; - } - - return $country->getName() === 'Poland'; + return $country !== null && $country->getName() === 'Poland'; }]); } @@ -124,8 +120,6 @@ final class CountryChoiceTypeTest extends TypeTestCase $form = $this->factory->create(CountryChoiceType::class, null, $formConfiguration); $view = $form->createView(); - $i = 1; - Assert::assertSame($expectedLabels, array_map(static function (ChoiceView $choiceView): string { return $choiceView->label; }, $view->vars['choices']));