From 302ab87f0c44840761a1920db280748a1acd9020 Mon Sep 17 00:00:00 2001 From: Benjamin BOUDIER Date: Fri, 30 Dec 2022 10:54:11 +0100 Subject: [PATCH] WIP: symfony 6 compatibility --- Gateway/AbstractPaymentGateway.php | 5 ++-- Gateway/AlmaPaymentGateway.php | 3 +- Gateway/AtosSipsBinPaymentGateway.php | 3 +- Gateway/AtosSipsJsonPaymentGateway.php | 3 +- Gateway/AtosSipsPostPaymentGateway.php | 3 +- Gateway/EurekaPaymentGateway.php | 3 +- Gateway/PayboxPaymentGateway.php | 3 +- Gateway/StripePaymentGateway.php | 3 +- Gateway/SystemPayPaymentGateway.php | 3 +- .../ManageTransactionStepEventAction.php | 5 ++-- Tests/Unit/Gateway/PaymentGatewayTestCase.php | 6 ++-- Tests/Unit/Payment/PaymentContextTest.php | 6 ++-- composer.json | 29 +++++++++---------- 13 files changed, 42 insertions(+), 33 deletions(-) diff --git a/Gateway/AbstractPaymentGateway.php b/Gateway/AbstractPaymentGateway.php index ee5b868..965e6c1 100644 --- a/Gateway/AbstractPaymentGateway.php +++ b/Gateway/AbstractPaymentGateway.php @@ -7,11 +7,12 @@ use IDCI\Bundle\PaymentBundle\Model\Transaction; use Symfony\Component\HttpFoundation\Request; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Twig\Environment; abstract class AbstractPaymentGateway implements PaymentGatewayInterface { /** - * @var \Twig_Environment + * @var Environment */ protected $templating; @@ -21,7 +22,7 @@ abstract class AbstractPaymentGateway implements PaymentGatewayInterface protected $dispatcher; public function __construct( - \Twig_Environment $templating, + Environment $templating, EventDispatcherInterface $dispatcher ) { $this->templating = $templating; diff --git a/Gateway/AlmaPaymentGateway.php b/Gateway/AlmaPaymentGateway.php index ff03b35..ef40484 100644 --- a/Gateway/AlmaPaymentGateway.php +++ b/Gateway/AlmaPaymentGateway.php @@ -14,11 +14,12 @@ use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Twig\Environment; class AlmaPaymentGateway extends AbstractPaymentGateway { public function __construct( - \Twig_Environment $templating, + Environment $templating, EventDispatcherInterface $dispatcher, LoggerInterface $logger ) { diff --git a/Gateway/AtosSipsBinPaymentGateway.php b/Gateway/AtosSipsBinPaymentGateway.php index f75f407..7c29fbe 100644 --- a/Gateway/AtosSipsBinPaymentGateway.php +++ b/Gateway/AtosSipsBinPaymentGateway.php @@ -11,6 +11,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Process\Process; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Twig\Environment; class AtosSipsBinPaymentGateway extends AbstractPaymentGateway { @@ -30,7 +31,7 @@ class AtosSipsBinPaymentGateway extends AbstractPaymentGateway private $responseBinPath; public function __construct( - \Twig_Environment $templating, + Environment $templating, EventDispatcherInterface $dispatcher, string $pathfile, string $requestBinPath, diff --git a/Gateway/AtosSipsJsonPaymentGateway.php b/Gateway/AtosSipsJsonPaymentGateway.php index fe1fc04..c5389ea 100644 --- a/Gateway/AtosSipsJsonPaymentGateway.php +++ b/Gateway/AtosSipsJsonPaymentGateway.php @@ -12,6 +12,7 @@ use Payum\ISO4217\ISO4217; use Symfony\Component\HttpFoundation\Request; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Twig\Environment; class AtosSipsJsonPaymentGateway extends AbstractPaymentGateway { @@ -21,7 +22,7 @@ class AtosSipsJsonPaymentGateway extends AbstractPaymentGateway private $serverHostName; public function __construct( - \Twig_Environment $templating, + Environment $templating, EventDispatcherInterface $dispatcher, string $serverHostName ) { diff --git a/Gateway/AtosSipsPostPaymentGateway.php b/Gateway/AtosSipsPostPaymentGateway.php index 3495828..d452f42 100644 --- a/Gateway/AtosSipsPostPaymentGateway.php +++ b/Gateway/AtosSipsPostPaymentGateway.php @@ -10,6 +10,7 @@ use Payum\ISO4217\ISO4217; use Symfony\Component\HttpFoundation\Request; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Twig\Environment; class AtosSipsPostPaymentGateway extends AbstractPaymentGateway { @@ -19,7 +20,7 @@ class AtosSipsPostPaymentGateway extends AbstractPaymentGateway private $serverHostName; public function __construct( - \Twig_Environment $templating, + Environment $templating, EventDispatcherInterface $dispatcher, string $serverHostName ) { diff --git a/Gateway/EurekaPaymentGateway.php b/Gateway/EurekaPaymentGateway.php index 349373c..82fff56 100644 --- a/Gateway/EurekaPaymentGateway.php +++ b/Gateway/EurekaPaymentGateway.php @@ -11,6 +11,7 @@ use IDCI\Bundle\PaymentBundle\Payment\PaymentStatus; use Symfony\Component\HttpFoundation\Request; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Twig\Environment; class EurekaPaymentGateway extends AbstractPaymentGateway { @@ -23,7 +24,7 @@ class EurekaPaymentGateway extends AbstractPaymentGateway private $serverHostName; public function __construct( - \Twig_Environment $templating, + Environment $templating, EventDispatcherInterface $dispatcher, EurekaPaymentGatewayClient $eurekaPaymentGatewayClient ) { diff --git a/Gateway/PayboxPaymentGateway.php b/Gateway/PayboxPaymentGateway.php index 2b4cec1..7f7e919 100644 --- a/Gateway/PayboxPaymentGateway.php +++ b/Gateway/PayboxPaymentGateway.php @@ -10,6 +10,7 @@ use Payum\ISO4217\ISO4217; use Symfony\Component\HttpFoundation\Request; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Twig\Environment; class PayboxPaymentGateway extends AbstractPaymentGateway { @@ -19,7 +20,7 @@ class PayboxPaymentGateway extends AbstractPaymentGateway private $serverHostName; public function __construct( - \Twig_Environment $templating, + Environment $templating, EventDispatcherInterface $dispatcher, string $serverHostName, string $keyPath, diff --git a/Gateway/StripePaymentGateway.php b/Gateway/StripePaymentGateway.php index 3a95870..2a8f0ed 100644 --- a/Gateway/StripePaymentGateway.php +++ b/Gateway/StripePaymentGateway.php @@ -9,6 +9,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Twig\Environment; class StripePaymentGateway extends AbstractPaymentGateway { @@ -18,7 +19,7 @@ class StripePaymentGateway extends AbstractPaymentGateway private $router; public function __construct( - \Twig_Environment $templating, + Environment $templating, EventDispatcherInterface $dispatcher, UrlGeneratorInterface $router ) { diff --git a/Gateway/SystemPayPaymentGateway.php b/Gateway/SystemPayPaymentGateway.php index 3cc76ff..e063f4d 100644 --- a/Gateway/SystemPayPaymentGateway.php +++ b/Gateway/SystemPayPaymentGateway.php @@ -11,6 +11,7 @@ use Payum\ISO4217\ISO4217; use Symfony\Component\HttpFoundation\Request; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Twig\Environment; class SystemPayPaymentGateway extends AbstractPaymentGateway { @@ -24,7 +25,7 @@ class SystemPayPaymentGateway extends AbstractPaymentGateway private $serverUrl; public function __construct( - \Twig_Environment $templating, + Environment $templating, EventDispatcherInterface $dispatcher, string $serverUrl ) { diff --git a/Step/Event/Action/ManageTransactionStepEventAction.php b/Step/Event/Action/ManageTransactionStepEventAction.php index d8191a4..d3265e3 100644 --- a/Step/Event/Action/ManageTransactionStepEventAction.php +++ b/Step/Event/Action/ManageTransactionStepEventAction.php @@ -16,6 +16,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Twig\Environment; class ManageTransactionStepEventAction extends AbstractStepEventAction { @@ -45,7 +46,7 @@ class ManageTransactionStepEventAction extends AbstractStepEventAction protected $dispatcher; /** - * @var \Twig_Environment + * @var Environment */ private $templating; @@ -60,7 +61,7 @@ public function __construct( UrlGeneratorInterface $router, RequestStack $requestStack, EventDispatcherInterface $dispatcher, - \Twig_Environment $templating, + Environment $templating, array $templates ) { $this->paymentManager = $paymentManager; diff --git a/Tests/Unit/Gateway/PaymentGatewayTestCase.php b/Tests/Unit/Gateway/PaymentGatewayTestCase.php index 6c034a4..d18c0fc 100644 --- a/Tests/Unit/Gateway/PaymentGatewayTestCase.php +++ b/Tests/Unit/Gateway/PaymentGatewayTestCase.php @@ -6,13 +6,13 @@ use IDCI\Bundle\PaymentBundle\Model\Transaction; use IDCI\Bundle\PaymentBundle\Payment\TransactionFactory; use PHPUnit\Framework\TestCase; -use Twig\Environment as TwigEnvironment; +use Twig\Environment; use Twig\Loader\FilesystemLoader; class PaymentGatewayTestCase extends TestCase { /** - * @var \Twig_Environment + * @var Environment */ protected $twig; @@ -36,7 +36,7 @@ public function setUp() $loader = new FilesystemLoader(); $loader->addPath(__DIR__.'/../../..', 'IDCIPaymentBundle'); - $this->twig = new TwigEnvironment($loader); + $this->twig = new Environment($loader); $this->paymentGatewayConfiguration = (new PaymentGatewayConfiguration()) ->setAlias('dummy_gateway_alias') diff --git a/Tests/Unit/Payment/PaymentContextTest.php b/Tests/Unit/Payment/PaymentContextTest.php index ed2aa93..e09427c 100644 --- a/Tests/Unit/Payment/PaymentContextTest.php +++ b/Tests/Unit/Payment/PaymentContextTest.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; -use Twig\Environment as TwigEnvironment; +use Twig\Environment; use Twig\Loader\ArrayLoader; class PaymentContextTest extends TestCase @@ -35,7 +35,7 @@ class PaymentContextTest extends TestCase private $dispatcher; /** - * @var \Twig_Environment + * @var Environment */ private $twig; @@ -51,7 +51,7 @@ class PaymentContextTest extends TestCase public function setUp() { - $this->twig = new TwigEnvironment(new ArrayLoader()); + $this->twig = new Environment(new ArrayLoader()); $this->paymentGateway = $this->getMockBuilder(AbstractPaymentGateway::class) ->setConstructorArgs([$this->twig]) diff --git a/composer.json b/composer.json index 3e1bb36..f1aa0cd 100644 --- a/composer.json +++ b/composer.json @@ -12,32 +12,31 @@ } ], "require": { - "php": ">=7.0", - "symfony/dependency-injection": "^4.0", - "symfony/dom-crawler": "^4.0", - "symfony/framework-bundle": "^4.0", - "symfony/form": "^4.0", - "symfony/templating": "^4.0", - "symfony/twig-bundle": "^4.0", + "php": "^7.1 || ^8.0", + "symfony/dependency-injection": "^4.0 || ^5.0 || ^6.0", + "symfony/dom-crawler": "^4.0 || ^5.0 || ^6.0", + "symfony/framework-bundle": "^4.0 || ^5.0 || ^6.0", + "symfony/form": "^4.0 || ^5.0 || ^6.0", + "symfony/templating": "^4.0 || ^5.0 || ^6.0", + "symfony/twig-bundle": "^4.0 || ^5.0 || ^6.0", "symfony/monolog-bundle": "^3.3", - "symfony/process": "^4.0", - "ramsey/uuid": "^4.0", + "symfony/process": "^4.0 || ^5.0 || ^6.0", + "ramsey/uuid": "^4.0 || ^5.0 || ^6.0", "ramsey/uuid-doctrine": "^1.4", - "doctrine/persistence": "^1.1", + "doctrine/persistence": "^2.2 || ^3.0", "payum/iso4217": "~1.0", "paypal/rest-api-sdk-php": "^1.13", "stripe/stripe-php": "^6.7", "jwarkentin/flaky": "~0.0.9", - "payplug/payplug-php": "~2.5", - "pascaldevink/shortuuid": "~2.0" + "payplug/payplug-php": "~2.5" }, "suggest": { "alma/alma-php-client": "^1.0", - "idci/step-bundle": "~3.0", - "symfony/cache": "^4.0" + "idci/step-bundle": ">=4.0", + "symfony/cache": "^4.0 || ^5.0 || ^6.0" }, "require-dev": { - "phpunit/phpunit": "~5.7" + "phpunit/phpunit": "^9.0" }, "autoload": { "psr-4": {