diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8fa0a406..faa073c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,11 +23,7 @@ jobs: node: ["16.x"] mysql: ["5.7", "8.0"] symfony: ["^5.4", "^6.0"] - sylius: ["~1.11.0", "~1.12.0"] - exclude: - - - symfony: "^6.0" - sylius: "~1.11.0" + sylius: ["~1.12.0"] env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" diff --git a/composer.json b/composer.json index 5aa9aa60..99d4f38e 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "phpseclib/phpseclib": "^2.0", "polishsymfonycommunity/symfony-mocker-container": "^1.0", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.4 || ^0.2", - "sylius/sylius": "~1.11.0 || ~1.12.0", + "sylius/sylius": "~1.12.0", "symfony/mailer": "^5.4 || ^6.0" }, "require-dev": { @@ -26,26 +26,21 @@ "friends-of-behat/suite-settings-extension": "^1.0", "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", + "lchrusciel/api-test-case": "^5.1", "phpspec/phpspec": "^7.0", - "phpstan/phpstan": "0.12.98", - "phpstan/phpstan-doctrine": "0.12.33", - "phpstan/phpstan-webmozart-assert": "0.12.12", + "phpstan/phpstan": "^1.6", + "phpstan/phpstan-doctrine": "1.3.37", + "phpstan/phpstan-webmozart-assert": "^1.1", "phpunit/phpunit": "^8.5", "sylius-labs/coding-standard": "^4.0", + "sylius/sylius-rector": "0.11.x-dev", "symfony/browser-kit": "^5.4 || ^6.0", "symfony/debug-bundle": "^5.4 || ^6.0", "symfony/dotenv": "^5.4 || ^6.0", "symfony/intl": "^5.4 || ^6.0", "symfony/web-profiler-bundle": "^5.4 || ^6.0", - "vimeo/psalm": "4.27.0", - "rector/rector": "^0.11.53", - "lchrusciel/api-test-case": "^5.1", - "symfony/webpack-encore-bundle": "^1.15" - }, - "conflict": { - "doctrine/doctrine-bundle": "2.3.0", - "doctrine/dbal": "^3.0.0", - "sylius/invoicing-plugin": "<0.16.0" + "symfony/webpack-encore-bundle": "^1.15", + "vimeo/psalm": "4.27.0" }, "autoload": { "psr-4": { @@ -73,7 +68,7 @@ "scripts": { "analyse": [ "@composer validate --strict", - "vendor/bin/phpstan.phar analyse -c phpstan.neon -l max src/", + "vendor/bin/phpstan.phar analyse", "vendor/bin/psalm" ], "fix": [ diff --git a/ecs.php b/ecs.php index 625ca542..40c669c9 100644 --- a/ecs.php +++ b/ecs.php @@ -3,12 +3,13 @@ use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer; use SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use Symplify\EasyCodingStandard\Config\ECSConfig; use Symplify\EasyCodingStandard\ValueObject\Option; -return static function (ContainerConfigurator $containerConfigurator): void { - $containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php'); +return static function (ECSConfig $config): void { + $config->import('vendor/sylius-labs/coding-standard/ecs.php'); - $containerConfigurator->parameters()->set(Option::SKIP, [ + $config->skip([ VisibilityRequiredFixer::class => ['*Spec.php'], InlineDocCommentDeclarationSniff::class . '.MissingVariable', ]); diff --git a/phpstan.neon b/phpstan.neon.dist similarity index 98% rename from phpstan.neon rename to phpstan.neon.dist index 4492da04..9b4bc47f 100644 --- a/phpstan.neon +++ b/phpstan.neon.dist @@ -3,6 +3,8 @@ includes: - vendor/phpstan/phpstan-webmozart-assert/extension.neon parameters: + level: 3 + reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false diff --git a/psalm.xml b/psalm.xml index d8968a42..5b990dc2 100644 --- a/psalm.xml +++ b/psalm.xml @@ -17,12 +17,24 @@ + + + + + + + + + + + + diff --git a/src/Controller/CancelPayPalCheckoutPaymentAction.php b/src/Controller/CancelPayPalCheckoutPaymentAction.php index ad53d03d..0020c599 100644 --- a/src/Controller/CancelPayPalCheckoutPaymentAction.php +++ b/src/Controller/CancelPayPalCheckoutPaymentAction.php @@ -26,7 +26,13 @@ public function __construct( public function __invoke(Request $request): Response { - $content = (array) json_decode((string) $request->getContent(false), true); + /** + * @var string $content + * @psalm-suppress UnnecessaryVarAnnotation + */ + $content = $request->getContent(); + + $content = (array) json_decode($content, true); $payment = $this->paymentProvider->getByPayPalOrderId((string) $content['payPalOrderId']); diff --git a/src/Controller/CancelPayPalOrderAction.php b/src/Controller/CancelPayPalOrderAction.php index a2c1dcd1..ea5d15bc 100644 --- a/src/Controller/CancelPayPalOrderAction.php +++ b/src/Controller/CancelPayPalOrderAction.php @@ -37,7 +37,13 @@ public function __construct( public function __invoke(Request $request): Response { - $content = (array) json_decode((string) $request->getContent(false), true); + /** + * @var string $content + * @psalm-suppress UnnecessaryVarAnnotation + */ + $content = $request->getContent(); + + $content = (array) json_decode($content, true); $payment = $this->paymentProvider->getByPayPalOrderId((string) $content['payPalOrderId']); diff --git a/src/Controller/CancelPayPalPaymentAction.php b/src/Controller/CancelPayPalPaymentAction.php index 125f043b..33c407e8 100644 --- a/src/Controller/CancelPayPalPaymentAction.php +++ b/src/Controller/CancelPayPalPaymentAction.php @@ -48,7 +48,13 @@ public function __construct( public function __invoke(Request $request): Response { - $content = (array) json_decode((string) $request->getContent(false), true); + /** + * @var string $content + * @psalm-suppress UnnecessaryVarAnnotation + */ + $content = $request->getContent(); + + $content = (array) json_decode($content, true); $payment = $this->paymentProvider->getByPayPalOrderId((string) $content['payPalOrderId']); diff --git a/src/Controller/PayPalPaymentOnErrorAction.php b/src/Controller/PayPalPaymentOnErrorAction.php index c3ddb52b..9c218499 100644 --- a/src/Controller/PayPalPaymentOnErrorAction.php +++ b/src/Controller/PayPalPaymentOnErrorAction.php @@ -29,7 +29,13 @@ public function __construct(FlashBagInterface|RequestStack $flashBagOrRequestSta public function __invoke(Request $request): Response { - $this->logger->error((string) $request->getContent()); + /** + * @var string $content + * @psalm-suppress UnnecessaryVarAnnotation + */ + $content = $request->getContent(); + + $this->logger->error($content); FlashBagProvider::getFlashBag($this->flashBagOrRequestStack) ->add('error', 'sylius.pay_pal.something_went_wrong') ; diff --git a/src/Controller/Webhook/RefundOrderAction.php b/src/Controller/Webhook/RefundOrderAction.php index 67e9d465..0c9bc9aa 100644 --- a/src/Controller/Webhook/RefundOrderAction.php +++ b/src/Controller/Webhook/RefundOrderAction.php @@ -62,7 +62,13 @@ public function __invoke(Request $request): Response private function getPayPalPaymentUrl(Request $request): string { - $content = (array) json_decode((string) $request->getContent(false), true); + /** + * @var string $content + * @psalm-suppress UnnecessaryVarAnnotation + */ + $content = $request->getContent(); + + $content = (array) json_decode($content, true); Assert::keyExists($content, 'resource'); $resource = (array) $content['resource']; Assert::keyExists($resource, 'links'); diff --git a/src/Migrations/Version20200907102535.php b/src/Migrations/Version20200907102535.php index b6120e80..55428440 100644 --- a/src/Migrations/Version20200907102535.php +++ b/src/Migrations/Version20200907102535.php @@ -5,32 +5,23 @@ namespace Sylius\PayPalPlugin\Migrations; use Doctrine\DBAL\Schema\Schema; -use Doctrine\Migrations\AbstractMigration; +use Sylius\Bundle\CoreBundle\Doctrine\Migrations\AbstractMigration as SyliusAbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ -final class Version20200907102535 extends AbstractMigration +final class Version20200907102535 extends SyliusAbstractMigration { public function getDescription(): string { - return ''; + return 'Add PayPalCredentials table'; } public function up(Schema $schema): void { - // this up() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); - $this->addSql('CREATE TABLE sylius_paypal_plugin_pay_pal_credentials (id VARCHAR(255) NOT NULL, payment_method_id INT DEFAULT NULL, access_token VARCHAR(255) NOT NULL, creation_time DATETIME NOT NULL, expiration_time DATETIME NOT NULL, INDEX IDX_C56F54AD5AA1164F (payment_method_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); $this->addSql('ALTER TABLE sylius_paypal_plugin_pay_pal_credentials ADD CONSTRAINT FK_C56F54AD5AA1164F FOREIGN KEY (payment_method_id) REFERENCES sylius_payment_method (id)'); } public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); - $this->addSql('DROP TABLE sylius_paypal_plugin_pay_pal_credentials'); } } diff --git a/src/UrlUtils.php b/src/UrlUtils.php index dceb49fe..f4041879 100644 --- a/src/UrlUtils.php +++ b/src/UrlUtils.php @@ -28,7 +28,7 @@ private function __construct() * * @return string the resulting string */ - public static function appendQueryString(string $url, string $queryString, int $mode = APPEND_QUERY_STRING_IGNORE_DUPLICATE): string + public static function appendQueryString(string $url, string $queryString, int $mode = self::APPEND_QUERY_STRING_IGNORE_DUPLICATE): string { if ('' === $queryString) { return $url; diff --git a/tests/Application/.env b/tests/Application/.env index b7c019cd..c8c681a9 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -22,7 +22,13 @@ DATABASE_URL=mysql://root@127.0.0.1/sylius_pay_pal_plugin_%kernel.environment% MAILER_URL=smtp://localhost ###< symfony/swiftmailer-bundle ### +###> symfony/messenger ### MESSENGER_TRANSPORT_DSN=doctrine://default +SYLIUS_MESSENGER_TRANSPORT_MAIN_DSN=doctrine://default +SYLIUS_MESSENGER_TRANSPORT_MAIN_FAILED_DSN=doctrine://default?queue_name=main_failed +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_DSN=doctrine://default?queue_name=catalog_promotion_removal +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_FAILED_DSN=doctrine://default?queue_name=catalog_promotion_removal_failed +###< symfony/messenger ### ###> symfony/mailer ### MAILER_DSN=null://null diff --git a/tests/Application/.env.test b/tests/Application/.env.test index 86f84732..24a84d6d 100644 --- a/tests/Application/.env.test +++ b/tests/Application/.env.test @@ -4,4 +4,11 @@ KERNEL_CLASS='Tests\Sylius\PayPalPlugin\Application\Kernel' TEST_CLIENT_ID='AWKG4oiWX9AOifqtdkbOTgSgi3MqcaiyAt-x9Pa35lDdW94kjrOEqN-n3NQ4hD2TuomgpiDc27snMKd9' +###> symfony/messenger ### +# Sync transport turned for testing env for the ease of testing MESSENGER_TRANSPORT_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_MAIN_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_MAIN_FAILED_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_FAILED_DSN=sync:// +###< symfony/messenger ###