From b50a6532437b349ddf0ac23391fa054f1bf1763b Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 30 Aug 2022 17:39:21 +0200 Subject: [PATCH 1/7] feat: drop support of symfony 4, drop support of php 7.4, remove deprecated functions --- Command/CreateCaptureTokenCommand.php | 11 +-- Command/CreateNotifyTokenCommand.php | 11 +-- Command/DebugGatewayCommand.php | 13 +--- Command/StatusCommand.php | 10 +-- Controller/AuthorizeController.php | 6 +- Controller/CancelController.php | 6 +- Controller/CaptureController.php | 6 +- Controller/NotifyController.php | 6 +- Controller/PayoutController.php | 6 +- Controller/PayumController.php | 78 +------------------ Controller/RefundController.php | 6 +- Controller/SyncController.php | 6 +- .../Compiler/BuildGatewayFactoriesPass.php | 1 - .../Storage/AbstractStorageFactory.php | 2 +- .../Storage/StorageFactoryInterface.php | 8 +- DependencyInjection/PayumExtension.php | 1 - Tests/Controller/AuthorizeControllerTest.php | 1 - Tests/Controller/CancelControllerTest.php | 1 - Tests/Controller/NotifyControllerTest.php | 1 - Tests/Controller/PayoutControllerTest.php | 1 - Tests/Controller/RefundControllerTest.php | 1 - .../BuildGatewayFactoriesBuilderPassTest.php | 2 - .../Compiler/BuildStoragesPassTest.php | 3 - .../Factory/AbstractStorageFactoryTest.php | 2 +- .../Factory/CustomStorageFactoryTest.php | 2 +- .../Factory/Propel1StorageFactoryTest.php | 2 - .../Factory/Propel2StorageFactoryTest.php | 2 - .../MainConfigurationTest.php | 4 +- .../PayumExtensionTest.php | 2 +- .../ReplyToHttpResponseListenerTest.php | 10 +-- .../Command/DebugGatewayCommandTest.php | 2 +- .../PayumExtensionTest.php | 1 - .../Type/CreditCardExpirationDateTypeTest.php | 1 - Tests/Functional/WebTestCase.php | 24 ------ Tests/Functional/app/AppKernel.php | 46 +++++++---- Tests/Functional/app/AppKernelShared.php | 38 --------- Tests/Functional/app/config/config_sf4.yml | 4 - Tests/Functional/app/config/config_sf6.yml | 1 + Tests/Sonata/GatewayConfigAdminTest.php | 2 +- Traits/ControllerTrait.php | 25 ++---- composer.json | 27 ++++--- phpunit.xml.dist | 8 +- 42 files changed, 96 insertions(+), 294 deletions(-) delete mode 100644 Tests/Functional/app/AppKernelShared.php delete mode 100644 Tests/Functional/app/config/config_sf4.yml diff --git a/Command/CreateCaptureTokenCommand.php b/Command/CreateCaptureTokenCommand.php index d220809..6513a5d 100644 --- a/Command/CreateCaptureTokenCommand.php +++ b/Command/CreateCaptureTokenCommand.php @@ -13,14 +13,8 @@ #[AsCommand(name: 'payum:security:create-capture-token')] class CreateCaptureTokenCommand extends Command { - protected static $defaultName = 'payum:security:create-capture-token'; - - private Payum $payum; - - public function __construct(Payum $payum) + public function __construct(private Payum $payum) { - $this->payum = $payum; - parent::__construct(); } @@ -30,7 +24,6 @@ public function __construct(Payum $payum) protected function configure(): void { $this - ->setName(static::$defaultName) ->addArgument('gateway-name', InputArgument::REQUIRED, 'The gateway name associated with the token') ->addOption('model-class', null, InputOption::VALUE_OPTIONAL, 'The model class associated with the token') ->addOption('model-id', null, InputOption::VALUE_OPTIONAL, 'The model id associated with the token') @@ -66,6 +59,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(sprintf('After Url: %s', $token->getAfterUrl() ?: 'null')); $output->writeln(sprintf('Details: %s', (string) $token->getDetails())); - return 0; + return Command::SUCCESS; } } diff --git a/Command/CreateNotifyTokenCommand.php b/Command/CreateNotifyTokenCommand.php index 4021137..1f0f150 100644 --- a/Command/CreateNotifyTokenCommand.php +++ b/Command/CreateNotifyTokenCommand.php @@ -13,14 +13,8 @@ #[AsCommand(name: 'payum:security:create-notify-token')] class CreateNotifyTokenCommand extends Command { - protected static $defaultName = 'payum:security:create-notify-token'; - - private Payum $payum; - - public function __construct(Payum $payum) + public function __construct(private Payum $payum) { - $this->payum = $payum; - parent::__construct(); } @@ -30,7 +24,6 @@ public function __construct(Payum $payum) protected function configure(): void { $this - ->setName(static::$defaultName) ->addArgument('gateway-name', InputArgument::REQUIRED, 'The gateway name associated with the token') ->addOption('model-class', null, InputOption::VALUE_OPTIONAL, 'The model class associated with the token') ->addOption('model-id', null, InputOption::VALUE_OPTIONAL, 'The model id associated with the token') @@ -63,6 +56,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(sprintf('Url: %s', $token->getTargetUrl())); $output->writeln(sprintf('Details: %s', (string) $token->getDetails() ?: 'null')); - return 0; + return Command::SUCCESS; } } diff --git a/Command/DebugGatewayCommand.php b/Command/DebugGatewayCommand.php index 4f14bbb..c91b12c 100644 --- a/Command/DebugGatewayCommand.php +++ b/Command/DebugGatewayCommand.php @@ -16,13 +16,8 @@ #[AsCommand(name: 'debug:payum:gateway', aliases: ['payum:gateway:debug'])] class DebugGatewayCommand extends Command { - protected static $defaultName = 'debug:payum:gateway'; - - protected Payum $payum; - - public function __construct(Payum $payum) + public function __construct(protected Payum $payum) { - $this->payum = $payum; parent::__construct(); } @@ -32,8 +27,6 @@ public function __construct(Payum $payum) protected function configure(): void { $this - ->setName(static::$defaultName) - ->setAliases(['payum:gateway:debug']) ->addArgument('gateway-name', InputArgument::OPTIONAL, 'The gateway name you want to get information about.') ->addOption('show-supports', null, InputOption::VALUE_NONE, 'Show what actions supports.') ; @@ -127,7 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - return 0; + return Command::SUCCESS; } protected function getMethodCode(\ReflectionMethod $reflectionMethod): array @@ -142,7 +135,7 @@ protected function getMethodCode(\ReflectionMethod $reflectionMethod): array return array_values($methodCodeLines); } - private function findProperGatewayName(InputInterface $input, OutputInterface $output, array $gateways, string $name) + private function findProperGatewayName(InputInterface $input, OutputInterface $output, array $gateways, string $name): string { $helperSet = $this->getHelperSet(); if (!$helperSet->has('question') || isset($gateways[$name]) || !$input->isInteractive()) { diff --git a/Command/StatusCommand.php b/Command/StatusCommand.php index c7f0287..0e5ec01 100644 --- a/Command/StatusCommand.php +++ b/Command/StatusCommand.php @@ -14,13 +14,8 @@ #[AsCommand(name: 'payum:status', description: 'Allows to get a payment status.')] class StatusCommand extends Command { - protected static $defaultName = 'payum:status'; - - protected Payum $payum; - - public function __construct(Payum $payum) + public function __construct(protected Payum $payum) { - $this->payum = $payum; parent::__construct(); } @@ -30,7 +25,6 @@ public function __construct(Payum $payum) protected function configure(): void { $this - ->setName(static::$defaultName) ->setDescription('Allows to get a payment status.') ->addArgument('gateway-name', InputArgument::REQUIRED, 'The gateway name') ->addOption('model-class', null, InputOption::VALUE_REQUIRED, 'The model class') @@ -61,6 +55,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(sprintf('Status: %s', $status->getValue())); - return 0; + return Command::SUCCESS; } } diff --git a/Controller/AuthorizeController.php b/Controller/AuthorizeController.php index b4d5bf6..5965e39 100644 --- a/Controller/AuthorizeController.php +++ b/Controller/AuthorizeController.php @@ -9,12 +9,12 @@ class AuthorizeController extends PayumController { public function doAction(Request $request): RedirectResponse { - $token = $this->getPayum()->getHttpRequestVerifier()->verify($request); + $token = $this->payum->getHttpRequestVerifier()->verify($request); - $gateway = $this->getPayum()->getGateway($token->getGatewayName()); + $gateway = $this->payum->getGateway($token->getGatewayName()); $gateway->execute(new Authorize($token)); - $this->getPayum()->getHttpRequestVerifier()->invalidate($token); + $this->payum->getHttpRequestVerifier()->invalidate($token); return $this->redirect($token->getAfterUrl()); } diff --git a/Controller/CancelController.php b/Controller/CancelController.php index 002c1d4..e1c1ff8 100644 --- a/Controller/CancelController.php +++ b/Controller/CancelController.php @@ -12,12 +12,12 @@ class CancelController extends PayumController */ public function doAction(Request $request): Response { - $token = $this->getPayum()->getHttpRequestVerifier()->verify($request); + $token = $this->payum->getHttpRequestVerifier()->verify($request); - $gateway = $this->getPayum()->getGateway($token->getGatewayName()); + $gateway = $this->payum->getGateway($token->getGatewayName()); $gateway->execute(new Cancel($token)); - $this->getPayum()->getHttpRequestVerifier()->invalidate($token); + $this->payum->getHttpRequestVerifier()->invalidate($token); return $token->getAfterUrl() ? $this->redirect($token->getAfterUrl()) : diff --git a/Controller/CaptureController.php b/Controller/CaptureController.php index ff6d7a8..d3a3153 100644 --- a/Controller/CaptureController.php +++ b/Controller/CaptureController.php @@ -37,12 +37,12 @@ public function doSessionTokenAction(Request $request): RedirectResponse public function doAction(Request $request): RedirectResponse { - $token = $this->getPayum()->getHttpRequestVerifier()->verify($request); + $token = $this->payum->getHttpRequestVerifier()->verify($request); - $gateway = $this->getPayum()->getGateway($token->getGatewayName()); + $gateway = $this->payum->getGateway($token->getGatewayName()); $gateway->execute(new Capture($token)); - $this->getPayum()->getHttpRequestVerifier()->invalidate($token); + $this->payum->getHttpRequestVerifier()->invalidate($token); return $this->redirect($token->getAfterUrl()); } diff --git a/Controller/NotifyController.php b/Controller/NotifyController.php index 15a4870..723b0c0 100644 --- a/Controller/NotifyController.php +++ b/Controller/NotifyController.php @@ -9,7 +9,7 @@ class NotifyController extends PayumController { public function doUnsafeAction(Request $request): Response { - $gateway = $this->getPayum()->getGateway($request->get('gateway')); + $gateway = $this->payum->getGateway($request->get('gateway')); $gateway->execute(new Notify(null)); @@ -18,9 +18,9 @@ public function doUnsafeAction(Request $request): Response public function doAction(Request $request): Response { - $token = $this->getPayum()->getHttpRequestVerifier()->verify($request); + $token = $this->payum->getHttpRequestVerifier()->verify($request); - $gateway = $this->getPayum()->getGateway($token->getGatewayName()); + $gateway = $this->payum->getGateway($token->getGatewayName()); $gateway->execute(new Notify($token)); diff --git a/Controller/PayoutController.php b/Controller/PayoutController.php index ca211e2..fac6c70 100644 --- a/Controller/PayoutController.php +++ b/Controller/PayoutController.php @@ -9,12 +9,12 @@ class PayoutController extends PayumController { public function doAction(Request $request): RedirectResponse { - $token = $this->getPayum()->getHttpRequestVerifier()->verify($request); + $token = $this->payum->getHttpRequestVerifier()->verify($request); - $gateway = $this->getPayum()->getGateway($token->getGatewayName()); + $gateway = $this->payum->getGateway($token->getGatewayName()); $gateway->execute(new Payout($token)); - $this->getPayum()->getHttpRequestVerifier()->invalidate($token); + $this->payum->getHttpRequestVerifier()->invalidate($token); return $this->redirect($token->getAfterUrl()); } diff --git a/Controller/PayumController.php b/Controller/PayumController.php index 09a2323..db49428 100644 --- a/Controller/PayumController.php +++ b/Controller/PayumController.php @@ -3,86 +3,12 @@ use Payum\Bundle\PayumBundle\Traits\ControllerTrait; use Payum\Core\Payum; -use Payum\Core\Security\GenericTokenFactoryInterface; -use Payum\Core\Security\HttpRequestVerifierInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; abstract class PayumController extends AbstractController { use ControllerTrait; - protected ?Payum $payum = null; - - public function __construct(?Payum $payum = null) - { - if ($payum === null) { - @trigger_error( - sprintf( - '%s requires an instance of %s asd the first argument. Not passing this object is deprecated and it will be required in payum/payum-bundle 3.0.', - __METHOD__, - Payum::class - ), - E_USER_DEPRECATED - ); - } - - $this->payum = $payum; - } - - /** - * @deprecated since 2.5 and will be removed in 3.0. Use $this->>payum instead. - */ - protected function getPayum() - { - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); - - if (!str_starts_with($backtrace[1]['class'], 'Payum\\Bundle\\PayumBundle')) { - // Only trigger deprecation if called from outside the bundle - @trigger_error( - sprintf( - 'The method %s is deprecated since 2.5 and will be removed in 3.0. Use $this->payum instead', - __METHOD__, - ), - E_USER_DEPRECATED - ); - } - - return $this->payum ?? $this->container->get('payum'); - } - - /** - * @deprecated will be removed in 3.0. - * - * @return HttpRequestVerifierInterface - */ - protected function getHttpRequestVerifier() - { - @trigger_error( - sprintf( - 'The method %s is deprecated since 2.5 and will be removed in 3.0. Use $this->payum->getHttpRequestVerifier() instead', - __METHOD__, - ), - E_USER_DEPRECATED - ); - - return $this->getPayum()->getHttpRequestVerifier(); - } - - /** - * @deprecated will be removed in 3.0. - * - * @return GenericTokenFactoryInterface - */ - protected function getTokenFactory() - { - @trigger_error( - sprintf( - 'The method %s is deprecated since 2.5 and will be removed in 3.0. Use $this->payum->getTokenFactory() instead', - __METHOD__, - ), - E_USER_DEPRECATED - ); - - return $this->getPayum()->getTokenFactory(); - } + public function __construct(protected Payum $payum) + {} } diff --git a/Controller/RefundController.php b/Controller/RefundController.php index b1bfb7f..6993bcd 100644 --- a/Controller/RefundController.php +++ b/Controller/RefundController.php @@ -12,12 +12,12 @@ class RefundController extends PayumController */ public function doAction(Request $request): Response { - $token = $this->getPayum()->getHttpRequestVerifier()->verify($request); + $token = $this->payum->getHttpRequestVerifier()->verify($request); - $gateway = $this->getPayum()->getGateway($token->getGatewayName()); + $gateway = $this->payum->getGateway($token->getGatewayName()); $gateway->execute(new Refund($token)); - $this->getPayum()->getHttpRequestVerifier()->invalidate($token); + $this->payum->getHttpRequestVerifier()->invalidate($token); return $token->getAfterUrl() ? $this->redirect($token->getAfterUrl()) : diff --git a/Controller/SyncController.php b/Controller/SyncController.php index 3051b54..2011635 100644 --- a/Controller/SyncController.php +++ b/Controller/SyncController.php @@ -9,13 +9,13 @@ class SyncController extends PayumController { public function doAction(Request $request): RedirectResponse { - $token = $this->getPayum()->getHttpRequestVerifier()->verify($request); + $token = $this->payum->getHttpRequestVerifier()->verify($request); - $gateway = $this->getPayum()->getGateway($token->getGatewayName()); + $gateway = $this->payum->getGateway($token->getGatewayName()); $gateway->execute(new Sync($token)); - $this->getPayum()->getHttpRequestVerifier()->invalidate($token); + $this->payum->getHttpRequestVerifier()->invalidate($token); return $this->redirect($token->getAfterUrl()); } diff --git a/DependencyInjection/Compiler/BuildGatewayFactoriesPass.php b/DependencyInjection/Compiler/BuildGatewayFactoriesPass.php index 5e8f8c2..6bf4316 100644 --- a/DependencyInjection/Compiler/BuildGatewayFactoriesPass.php +++ b/DependencyInjection/Compiler/BuildGatewayFactoriesPass.php @@ -4,7 +4,6 @@ use Payum\Core\Exception\LogicException; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; class BuildGatewayFactoriesPass implements CompilerPassInterface { diff --git a/DependencyInjection/Factory/Storage/AbstractStorageFactory.php b/DependencyInjection/Factory/Storage/AbstractStorageFactory.php index 0b4e514..bfe407a 100644 --- a/DependencyInjection/Factory/Storage/AbstractStorageFactory.php +++ b/DependencyInjection/Factory/Storage/AbstractStorageFactory.php @@ -10,7 +10,7 @@ abstract class AbstractStorageFactory implements StorageFactoryInterface /** * {@inheritDoc} */ - public function create(ContainerBuilder $container, $modelClass, array $config): string + public function create(ContainerBuilder $container, string $modelClass, array $config): string { $storageId = sprintf('payum.storage.%s', strtolower(str_replace(array('\\\\', '\\'), '_', $modelClass))); diff --git a/DependencyInjection/Factory/Storage/StorageFactoryInterface.php b/DependencyInjection/Factory/Storage/StorageFactoryInterface.php index dc3e897..befaefe 100644 --- a/DependencyInjection/Factory/Storage/StorageFactoryInterface.php +++ b/DependencyInjection/Factory/Storage/StorageFactoryInterface.php @@ -7,10 +7,9 @@ interface StorageFactoryInterface { /** - * @param string $modelClass * @return string The payment serviceId */ - public function create(ContainerBuilder $container, $modelClass, array $config); + public function create(ContainerBuilder $container, string $modelClass, array $config): string; /** * The storage name, @@ -18,8 +17,5 @@ public function create(ContainerBuilder $container, $modelClass, array $config); */ public function getName(); - /** - * @return void - */ - public function addConfiguration(ArrayNodeDefinition $builder); + public function addConfiguration(ArrayNodeDefinition $builder): void; } diff --git a/DependencyInjection/PayumExtension.php b/DependencyInjection/PayumExtension.php index 4c06271..3067bb0 100644 --- a/DependencyInjection/PayumExtension.php +++ b/DependencyInjection/PayumExtension.php @@ -11,7 +11,6 @@ use Payum\Core\Registry\DynamicRegistry; use Payum\Core\Storage\CryptoStorageDecorator; use Sonata\AdminBundle\Admin\AbstractAdmin; -use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; diff --git a/Tests/Controller/AuthorizeControllerTest.php b/Tests/Controller/AuthorizeControllerTest.php index fa66778..6e614a5 100644 --- a/Tests/Controller/AuthorizeControllerTest.php +++ b/Tests/Controller/AuthorizeControllerTest.php @@ -5,7 +5,6 @@ use Payum\Core\GatewayInterface; use Payum\Core\Request\Authorize; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\RedirectResponse; class AuthorizeControllerTest extends AbstractControllerTest diff --git a/Tests/Controller/CancelControllerTest.php b/Tests/Controller/CancelControllerTest.php index 5714ceb..be4fff5 100644 --- a/Tests/Controller/CancelControllerTest.php +++ b/Tests/Controller/CancelControllerTest.php @@ -5,7 +5,6 @@ use Payum\Core\GatewayInterface; use Payum\Core\Request\Cancel; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; diff --git a/Tests/Controller/NotifyControllerTest.php b/Tests/Controller/NotifyControllerTest.php index e8f7db3..ebde7f5 100644 --- a/Tests/Controller/NotifyControllerTest.php +++ b/Tests/Controller/NotifyControllerTest.php @@ -11,7 +11,6 @@ use Payum\Core\Storage\StorageInterface; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/Tests/Controller/PayoutControllerTest.php b/Tests/Controller/PayoutControllerTest.php index 48bd5ad..f163450 100644 --- a/Tests/Controller/PayoutControllerTest.php +++ b/Tests/Controller/PayoutControllerTest.php @@ -5,7 +5,6 @@ use Payum\Core\GatewayInterface; use Payum\Core\Request\Payout; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\RedirectResponse; class PayoutControllerTest extends AbstractControllerTest diff --git a/Tests/Controller/RefundControllerTest.php b/Tests/Controller/RefundControllerTest.php index 5cf688c..f6f783f 100644 --- a/Tests/Controller/RefundControllerTest.php +++ b/Tests/Controller/RefundControllerTest.php @@ -6,7 +6,6 @@ use Payum\Core\GatewayInterface; use Payum\Core\Request\Refund; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; diff --git a/Tests/DependencyInjection/Compiler/BuildGatewayFactoriesBuilderPassTest.php b/Tests/DependencyInjection/Compiler/BuildGatewayFactoriesBuilderPassTest.php index 7bf9c5c..870825a 100644 --- a/Tests/DependencyInjection/Compiler/BuildGatewayFactoriesBuilderPassTest.php +++ b/Tests/DependencyInjection/Compiler/BuildGatewayFactoriesBuilderPassTest.php @@ -1,9 +1,7 @@ getMockForAbstractClass(AbstractStorageFactory::class); } diff --git a/Tests/DependencyInjection/Factory/CustomStorageFactoryTest.php b/Tests/DependencyInjection/Factory/CustomStorageFactoryTest.php index 733a4b5..f888150 100644 --- a/Tests/DependencyInjection/Factory/CustomStorageFactoryTest.php +++ b/Tests/DependencyInjection/Factory/CustomStorageFactoryTest.php @@ -156,7 +156,7 @@ public function shouldCreateServiceDefinition(): void /** * @return MockObject|\Symfony\Component\DependencyInjection\ContainerBuilder */ - protected function createContainerBuilderMock() + protected function createContainerBuilderMock(): ContainerBuilder|MockObject { return $this->createMock(ContainerBuilder::class); } diff --git a/Tests/DependencyInjection/Factory/Propel1StorageFactoryTest.php b/Tests/DependencyInjection/Factory/Propel1StorageFactoryTest.php index abea51a..7875178 100644 --- a/Tests/DependencyInjection/Factory/Propel1StorageFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Propel1StorageFactoryTest.php @@ -3,8 +3,6 @@ namespace Payum\Bundle\PayumBundle\Tests\DependencyInjection\Factory; use Payum\Bundle\PayumBundle\DependencyInjection\Factory\Storage\Propel1StorageFactory; -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\Processor; class Propel1StorageFactoryTest extends \PHPUnit\Framework\TestCase { diff --git a/Tests/DependencyInjection/Factory/Propel2StorageFactoryTest.php b/Tests/DependencyInjection/Factory/Propel2StorageFactoryTest.php index a0c80b1..d4f2c35 100644 --- a/Tests/DependencyInjection/Factory/Propel2StorageFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Propel2StorageFactoryTest.php @@ -3,8 +3,6 @@ namespace Payum\Bundle\PayumBundle\Tests\DependencyInjection\Factory; use Payum\Bundle\PayumBundle\DependencyInjection\Factory\Storage\Propel2StorageFactory; -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\Processor; class Propel2StorageFactoryTest extends \PHPUnit\Framework\TestCase { diff --git a/Tests/DependencyInjection/MainConfigurationTest.php b/Tests/DependencyInjection/MainConfigurationTest.php index d1b97d8..a0a1d14 100644 --- a/Tests/DependencyInjection/MainConfigurationTest.php +++ b/Tests/DependencyInjection/MainConfigurationTest.php @@ -710,7 +710,7 @@ public function shouldAllowPutAnythingToGatewaysV2AndNotPerformAnyValidations(): class FooStorageFactory implements StorageFactoryInterface { - public function create(ContainerBuilder $container, $modelClass, array $config): string + public function create(ContainerBuilder $container, string $modelClass, array $config): string { return 'aStorageId'; } @@ -732,7 +732,7 @@ public function addConfiguration(ArrayNodeDefinition $builder): void class BarStorageFactory implements StorageFactoryInterface { - public function create(ContainerBuilder $container, $modelClass, array $config): string + public function create(ContainerBuilder $container, string $modelClass, array $config): string { return 'serviceId'; } diff --git a/Tests/DependencyInjection/PayumExtensionTest.php b/Tests/DependencyInjection/PayumExtensionTest.php index 2a74d43..190fd8f 100644 --- a/Tests/DependencyInjection/PayumExtensionTest.php +++ b/Tests/DependencyInjection/PayumExtensionTest.php @@ -297,7 +297,7 @@ public function shouldAddGatewaysToBuilder(): void class FeeStorageFactory implements StorageFactoryInterface { - public function create(ContainerBuilder $container, $modelClass, array $config): string + public function create(ContainerBuilder $container, string $modelClass, array $config): string { return 'aStorageId'; } diff --git a/Tests/EventListener/ReplyToHttpResponseListenerTest.php b/Tests/EventListener/ReplyToHttpResponseListenerTest.php index 934bfc6..363b058 100644 --- a/Tests/EventListener/ReplyToHttpResponseListenerTest.php +++ b/Tests/EventListener/ReplyToHttpResponseListenerTest.php @@ -115,7 +115,7 @@ public function shouldCallAllowCustomResponseCode(): void /** * @return MockObject|ReplyToSymfonyResponseConverter */ - protected function createReplyToSymfonyResponseConverterMock() + protected function createReplyToSymfonyResponseConverterMock(): MockObject|ReplyToSymfonyResponseConverter { return $this->createMock(ReplyToSymfonyResponseConverter::class); } @@ -123,17 +123,13 @@ protected function createReplyToSymfonyResponseConverterMock() /** * @return HttpKernelInterface|MockObject */ - protected function createHttpKernelMock() + protected function createHttpKernelMock(): HttpKernelInterface|MockObject { return $this->createMock(HttpKernelInterface::class); } private function getRequestType(): int { - if (defined(HttpKernelInterface::class . '::MAIN_REQUEST')) { - return HttpKernelInterface::MAIN_REQUEST; - } - - return HttpKernelInterface::MASTER_REQUEST; + return HttpKernelInterface::MAIN_REQUEST; } } diff --git a/Tests/Functional/Command/DebugGatewayCommandTest.php b/Tests/Functional/Command/DebugGatewayCommandTest.php index 4d685ea..476a663 100644 --- a/Tests/Functional/Command/DebugGatewayCommandTest.php +++ b/Tests/Functional/Command/DebugGatewayCommandTest.php @@ -113,7 +113,7 @@ protected function executeConsole(Command $command, array $arguments = [], array return $commandTester->getDisplay(); } - protected function getInputStream($input) + protected function getInputStream($input): bool { $stream = fopen('php://memory', 'r+', false); fwrite($stream, $input); diff --git a/Tests/Functional/DependencyInjection/PayumExtensionTest.php b/Tests/Functional/DependencyInjection/PayumExtensionTest.php index 2103f92..58fa106 100644 --- a/Tests/Functional/DependencyInjection/PayumExtensionTest.php +++ b/Tests/Functional/DependencyInjection/PayumExtensionTest.php @@ -1,7 +1,6 @@ client = static::createClient(); - - if (method_exists(get_parent_class(self::class), 'getContainer')) { - static::$container = parent::getContainer(); - } else { - static::$container = static::$kernel->getContainer(); - } - } - - protected static function getContainer(): ContainerInterface - { - if (method_exists(get_parent_class(self::class), 'getContainer')) { - return parent::getContainer(); - } - - return self::$container; } public static function getKernelClass(): string diff --git a/Tests/Functional/app/AppKernel.php b/Tests/Functional/app/AppKernel.php index 2ff7ea8..64c53ee 100644 --- a/Tests/Functional/app/AppKernel.php +++ b/Tests/Functional/app/AppKernel.php @@ -1,29 +1,43 @@ load(__DIR__ . '/config/config.yml'); + + $loader->load(__DIR__ . '/config/config_sf' . Kernel::MAJOR_VERSION . '.yml'); } -} else { - class AppKernel extends AppKernelShared + + public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response { - public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response - { - return parent::handle($request, $type, false); - } + return parent::handle($request, $type, false); } } diff --git a/Tests/Functional/app/AppKernelShared.php b/Tests/Functional/app/AppKernelShared.php deleted file mode 100644 index f846204..0000000 --- a/Tests/Functional/app/AppKernelShared.php +++ /dev/null @@ -1,38 +0,0 @@ -load(__DIR__ . '/config/config.yml'); - - $loader->load(__DIR__ . '/config/config_sf' . Kernel::MAJOR_VERSION . '.yml'); - } -} diff --git a/Tests/Functional/app/config/config_sf4.yml b/Tests/Functional/app/config/config_sf4.yml deleted file mode 100644 index 094e00c..0000000 --- a/Tests/Functional/app/config/config_sf4.yml +++ /dev/null @@ -1,4 +0,0 @@ -framework: - session: - storage_id: 'session.storage.mock_file' - validation: { enable_annotations: false } diff --git a/Tests/Functional/app/config/config_sf6.yml b/Tests/Functional/app/config/config_sf6.yml index 23ffbdc..199e1e3 100644 --- a/Tests/Functional/app/config/config_sf6.yml +++ b/Tests/Functional/app/config/config_sf6.yml @@ -5,3 +5,4 @@ framework: cookie_samesite: lax storage_factory_id: session.storage.factory.mock_file validation: { enable_annotations: false } + http_method_override: false diff --git a/Tests/Sonata/GatewayConfigAdminTest.php b/Tests/Sonata/GatewayConfigAdminTest.php index c63a6aa..4fe42e7 100644 --- a/Tests/Sonata/GatewayConfigAdminTest.php +++ b/Tests/Sonata/GatewayConfigAdminTest.php @@ -42,7 +42,7 @@ public function shouldAllowSetFormFactory(): void $admin->setFormFactory($formFactoryMock); - $this->assertAttributeSame($formFactoryMock, 'formFactory', $admin); + $this->assertSame($formFactoryMock, $admin->getFormBuilder()); } } diff --git a/Traits/ControllerTrait.php b/Traits/ControllerTrait.php index 5fb20ba..3251f21 100644 --- a/Traits/ControllerTrait.php +++ b/Traits/ControllerTrait.php @@ -4,27 +4,14 @@ namespace Payum\Bundle\PayumBundle\Traits; use Payum\Core\Payum; -use Symfony\Component\HttpKernel\Kernel; use function array_merge; -if (Kernel::MAJOR_VERSION === 6) { - trait ControllerTrait +trait ControllerTrait +{ + public static function getSubscribedServices(): array { - public static function getSubscribedServices(): array - { - return array_merge(parent::getSubscribedServices(), [ - 'payum' => Payum::class, - ]); - } - } -} else { - trait ControllerTrait - { - public static function getSubscribedServices() - { - return array_merge(parent::getSubscribedServices(), [ - 'payum' => Payum::class, - ]); - } + return array_merge(parent::getSubscribedServices(), [ + 'payum' => Payum::class, + ]); } } diff --git a/composer.json b/composer.json index 5e72cba..efc9ccd 100644 --- a/composer.json +++ b/composer.json @@ -37,16 +37,15 @@ } ], "require": { - "php": "^7.4 || ^8.0", + "php": "^8.0", "payum/core": "^1.7.2", - "symfony/framework-bundle": "^4.4 || ^5.4 || ^6.0", - "symfony/form": "^4.4.20 || ^5.4 || ^6.0", - "symfony/validator": "^4.4 || ^5.4 || ^6.0", - "symfony/security-csrf": "^4.4 || ^5.4 || ^6.0", - "symfony/polyfill-php80": "^1.26" + "symfony/framework-bundle": "^5.4 || ^6.0", + "symfony/form": "^5.4 || ^6.0", + "symfony/validator": "^5.4 || ^6.0", + "symfony/security-csrf": "^5.4 || ^6.0" }, "require-dev": { - "defuse/php-encryption": "^2", + "defuse/php-encryption": "^2.3", "doctrine/orm": "^2.8", "omnipay/common": "^3@dev", "omnipay/dummy": "^3@alpha", @@ -59,13 +58,13 @@ "phpunit/phpunit": "^9.5", "psr/log": "^1 || ^2", "stripe/stripe-php": "~7.0", - "symfony/browser-kit": "^4.4 || ^5.4 || ^6.0", - "symfony/expression-language": "^4.4 || ^5.4 || ^6.0", - "symfony/phpunit-bridge": "^4.4 || ^5.4 || ^6.0", - "symfony/templating": "^4.4 || ^5.4 || ^6.0", - "symfony/twig-bundle": "^4.4 || ^5.4 || ^6.0", - "symfony/web-profiler-bundle": "^4.4 || ^5.4 || ^6.0", - "symfony/yaml": "^4.4 || ^5.4 || ^6.0", + "symfony/browser-kit": "^5.4 || ^6.0", + "symfony/expression-language": "^5.4 || ^6.0", + "symfony/phpunit-bridge": "^6.0", + "symfony/templating": "^5.4 || ^6.0", + "symfony/twig-bundle": "^5.4 || ^6.0", + "symfony/web-profiler-bundle": "^5.4 || ^6.0", + "symfony/yaml": "^5.4 || ^6.0", "twig/twig": "^2.0 || ^3.0" }, "suggest": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4aa666b..bb228b5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,18 +2,12 @@ - ./Tests + ./Tests From 2e6c4d0a87d0e43ce1b60798602a775bf3da0610 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 30 Aug 2022 17:41:02 +0200 Subject: [PATCH 2/7] feat: drop support of symfony 4, drop support of php 7.4, remove deprecated functions --- .github/workflows/tests.yaml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d4a1914..3a6b0bb 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -14,18 +14,10 @@ jobs: fail-fast: false matrix: include: - - php: 7.4 - symfony: 4.4.* - - php: 7.4 - symfony: 5.4.* - - php: 8.0 - symfony: 4.4.* - php: 8.0 symfony: 5.4.* - php: 8.0 symfony: 6.0.* - - php: 8.1 - symfony: 4.4.* - php: 8.1 symfony: 5.4.* - php: 8.1 @@ -59,7 +51,7 @@ jobs: - name: Install Symfony Flex run: | - composer require symfony/flex:^1 --no-update + composer require symfony/flex:^2 --no-update composer config --no-plugins allow-plugins.symfony/flex true - name: Install dependencies From 46ee575bc62c8abcc830884b293b9a25f21933f9 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Wed, 31 Aug 2022 09:45:35 +0200 Subject: [PATCH 3/7] feat: drop support of symfony 4, drop support of php 7.4, remove deprecated functions --- CHANGELOG.md | 8 ++++- Command/CreateCaptureTokenCommand.php | 2 +- Command/CreateNotifyTokenCommand.php | 2 +- Command/DebugGatewayCommand.php | 13 ++++++- Command/StatusCommand.php | 2 +- .../Compiler/BuildConfigsPass.php | 3 ++ .../Storage/AbstractStorageFactory.php | 3 ++ .../Factory/Storage/CustomStorageFactory.php | 3 ++ .../Storage/DoctrineStorageFactory.php | 3 ++ .../Storage/FilesystemStorageFactory.php | 3 ++ .../Factory/Storage/Propel1StorageFactory.php | 3 ++ .../Factory/Storage/Propel2StorageFactory.php | 3 ++ .../Storage/StorageFactoryInterface.php | 3 +- DependencyInjection/PayumExtension.php | 9 +++++ EventListener/ReplyToHttpResponseListener.php | 2 +- Profiler/PayumCollector.php | 12 +++++++ Resources/doc/configure-payment-in-backend.md | 14 +++----- Resources/doc/custom_purchase_examples.md | 14 +++----- .../authorize_net_aim.md | 6 ++-- .../doc/custom_purchase_examples/be2bill.md | 6 ++-- .../be2bill_onsite.md | 8 ++--- .../klarna_checkout.md | 8 ++--- .../klarna_invoice.md | 6 ++-- .../doc/custom_purchase_examples/payex.md | 6 ++-- .../paypal_express_checkout.md | 6 ++-- .../paypal_pro_checkout.md | 6 ++-- .../paypal_via_omnipay.md | 6 ++-- .../stripe_checkout.md | 6 ++-- .../doc/custom_purchase_examples/stripe_js.md | 6 ++-- .../stripe_via_omnipay.md | 6 ++-- Resources/doc/get_it_started.md | 20 ++++------- Resources/doc/iso4217-or-currency-details.md | 2 +- Resources/doc/storages.md | 34 ++++++------------- composer.json | 4 +++ phpstan.neon | 14 ++++++++ 35 files changed, 152 insertions(+), 100 deletions(-) create mode 100644 phpstan.neon diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cbae57..1cb48e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,14 @@ # Changelog +## 3.0.0 (2022-09-xx) + +* Support for Symfony <5.4 dropped +* Support for PHP < 8 dropped +* remove deprecated functions getPayum, getHttpRequestVerifier and getTokenFactory in PayumController + ## 2.5.0 (2022-07-xx) -* Support for Symfony 5.0 - 5.3 dropped +* Support for Symfony 4.0 - 4.3 dropped * Added support for Symfony 6.0 * Minimum Payum Core dependency updated to 1.7.2 diff --git a/Command/CreateCaptureTokenCommand.php b/Command/CreateCaptureTokenCommand.php index 6513a5d..7d2958e 100644 --- a/Command/CreateCaptureTokenCommand.php +++ b/Command/CreateCaptureTokenCommand.php @@ -43,7 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $model = null; if ($modelClass && $modelId) { - if (false === $model = $this->payum->getStorage($modelClass)->find($modelId)) { + if (!$model = $this->payum->getStorage($modelClass)->find($modelId)) { throw new RuntimeException(sprintf( 'Cannot find model with class %s and id %s.', $modelClass, diff --git a/Command/CreateNotifyTokenCommand.php b/Command/CreateNotifyTokenCommand.php index 1f0f150..99dc322 100644 --- a/Command/CreateNotifyTokenCommand.php +++ b/Command/CreateNotifyTokenCommand.php @@ -41,7 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $model = null; if ($modelClass && $modelId) { - if (false === $model = $this->payum->getStorage($modelClass)->find($modelId)) { + if (!$model = $this->payum->getStorage($modelClass)->find($modelId)) { throw new RuntimeException(sprintf( 'Cannot find model with class %s and id %s.', $modelClass, diff --git a/Command/DebugGatewayCommand.php b/Command/DebugGatewayCommand.php index c91b12c..cf17638 100644 --- a/Command/DebugGatewayCommand.php +++ b/Command/DebugGatewayCommand.php @@ -3,6 +3,7 @@ use Payum\Core\Extension\StorageExtension; use Payum\Core\Gateway; +use Payum\Core\GatewayInterface; use Payum\Core\Payum; use Payum\Core\Storage\AbstractStorage; use Symfony\Component\Console\Attribute\AsCommand; @@ -55,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(''); $output->writeln(sprintf('%s (%s):', $name, get_class($gateway))); - if (false === $gateway instanceof Gateway) { + if (!$gateway instanceof Gateway) { continue; } @@ -123,6 +124,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int return Command::SUCCESS; } + /** + * @return array + */ protected function getMethodCode(\ReflectionMethod $reflectionMethod): array { $file = file($reflectionMethod->getFileName()); @@ -135,6 +139,9 @@ protected function getMethodCode(\ReflectionMethod $reflectionMethod): array return array_values($methodCodeLines); } + /** + * @param array $gateways + */ private function findProperGatewayName(InputInterface $input, OutputInterface $output, array $gateways, string $name): string { $helperSet = $this->getHelperSet(); @@ -152,6 +159,10 @@ private function findProperGatewayName(InputInterface $input, OutputInterface $o return $this->getHelper('question')->ask($input, $output, $question); } + /** + * @param array $gateways + * @return array + */ private function findGatewaysContaining(array $gateways, string $name): array { $threshold = 1e3; diff --git a/Command/StatusCommand.php b/Command/StatusCommand.php index 0e5ec01..cb72382 100644 --- a/Command/StatusCommand.php +++ b/Command/StatusCommand.php @@ -42,7 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $modelId = $input->getOption('model-id'); $storage = $this->payum->getStorage($modelClass); - if (false === $model = $storage->find($modelId)) { + if (!$model = $storage->find($modelId)) { throw new RuntimeException(sprintf( 'Cannot find model with class %s and id %s.', $modelClass, diff --git a/DependencyInjection/Compiler/BuildConfigsPass.php b/DependencyInjection/Compiler/BuildConfigsPass.php index 28e7c13..1ccbada 100644 --- a/DependencyInjection/Compiler/BuildConfigsPass.php +++ b/DependencyInjection/Compiler/BuildConfigsPass.php @@ -42,6 +42,9 @@ public function process(ContainerBuilder $container): void } } + /** + * @return array[] + */ protected function processTagData(array $tagData, string $namePrefix, string $prependKey): array { $coreGatewayFactoryConfig = []; diff --git a/DependencyInjection/Factory/Storage/AbstractStorageFactory.php b/DependencyInjection/Factory/Storage/AbstractStorageFactory.php index bfe407a..549e997 100644 --- a/DependencyInjection/Factory/Storage/AbstractStorageFactory.php +++ b/DependencyInjection/Factory/Storage/AbstractStorageFactory.php @@ -26,5 +26,8 @@ public function addConfiguration(ArrayNodeDefinition $builder): void { } + /** + * @param array $config + */ abstract protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): Definition; } diff --git a/DependencyInjection/Factory/Storage/CustomStorageFactory.php b/DependencyInjection/Factory/Storage/CustomStorageFactory.php index 5691046..28e415a 100644 --- a/DependencyInjection/Factory/Storage/CustomStorageFactory.php +++ b/DependencyInjection/Factory/Storage/CustomStorageFactory.php @@ -15,6 +15,9 @@ public function getName(): string return 'custom'; } + /** + * @param array $config + */ protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition { return new ChildDefinition($config['service']); diff --git a/DependencyInjection/Factory/Storage/DoctrineStorageFactory.php b/DependencyInjection/Factory/Storage/DoctrineStorageFactory.php index 50264a1..a2edff0 100644 --- a/DependencyInjection/Factory/Storage/DoctrineStorageFactory.php +++ b/DependencyInjection/Factory/Storage/DoctrineStorageFactory.php @@ -30,6 +30,9 @@ public function addConfiguration(ArrayNodeDefinition $builder): void ->end(); } + /** + * @param array $config + */ protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage')); diff --git a/DependencyInjection/Factory/Storage/FilesystemStorageFactory.php b/DependencyInjection/Factory/Storage/FilesystemStorageFactory.php index 1ec38e2..9f7d436 100644 --- a/DependencyInjection/Factory/Storage/FilesystemStorageFactory.php +++ b/DependencyInjection/Factory/Storage/FilesystemStorageFactory.php @@ -27,6 +27,9 @@ public function addConfiguration(ArrayNodeDefinition $builder): void ->end(); } + /** + * @param array $config + */ protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage')); diff --git a/DependencyInjection/Factory/Storage/Propel1StorageFactory.php b/DependencyInjection/Factory/Storage/Propel1StorageFactory.php index 6cd9fb2..154bf17 100644 --- a/DependencyInjection/Factory/Storage/Propel1StorageFactory.php +++ b/DependencyInjection/Factory/Storage/Propel1StorageFactory.php @@ -16,6 +16,9 @@ public function getName(): string return "propel1"; } + /** + * @param array $config + */ protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage')); diff --git a/DependencyInjection/Factory/Storage/Propel2StorageFactory.php b/DependencyInjection/Factory/Storage/Propel2StorageFactory.php index ca29b40..b83c254 100644 --- a/DependencyInjection/Factory/Storage/Propel2StorageFactory.php +++ b/DependencyInjection/Factory/Storage/Propel2StorageFactory.php @@ -16,6 +16,9 @@ public function getName(): string return "propel2"; } + /** + * @param array $config + */ protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage')); diff --git a/DependencyInjection/Factory/Storage/StorageFactoryInterface.php b/DependencyInjection/Factory/Storage/StorageFactoryInterface.php index befaefe..d05aba8 100644 --- a/DependencyInjection/Factory/Storage/StorageFactoryInterface.php +++ b/DependencyInjection/Factory/Storage/StorageFactoryInterface.php @@ -7,6 +7,7 @@ interface StorageFactoryInterface { /** + * @param array $config * @return string The payment serviceId */ public function create(ContainerBuilder $container, string $modelClass, array $config): string; @@ -15,7 +16,7 @@ public function create(ContainerBuilder $container, string $modelClass, array $c * The storage name, * For example filesystem, doctrine, propel etc. */ - public function getName(); + public function getName(): string; public function addConfiguration(ArrayNodeDefinition $builder): void; } diff --git a/DependencyInjection/PayumExtension.php b/DependencyInjection/PayumExtension.php index 3067bb0..1cbceed 100644 --- a/DependencyInjection/PayumExtension.php +++ b/DependencyInjection/PayumExtension.php @@ -168,6 +168,9 @@ protected function loadStorages(array $config, ContainerBuilder $container): voi } } + /** + * @param array $securityConfig + */ protected function loadSecurity(array $securityConfig, ContainerBuilder $container): void { foreach ($securityConfig['token_storage'] as $tokenClass => $tokenStorageConfig) { @@ -183,6 +186,9 @@ protected function loadSecurity(array $securityConfig, ContainerBuilder $contain } } + /** + * @param array $dynamicGatewaysConfig + */ protected function loadDynamicGateways(array $dynamicGatewaysConfig, ContainerBuilder $container): void { $configClass = null; @@ -278,6 +284,9 @@ public function getConfiguration(array $config, ContainerBuilder $container): Ma return new MainConfiguration($this->storagesFactories); } + /** + * @param array $storageConfig + */ protected function findSelectedStorageFactoryNameInStorageConfig(array $storageConfig): string { foreach ($storageConfig as $name => $value) { diff --git a/EventListener/ReplyToHttpResponseListener.php b/EventListener/ReplyToHttpResponseListener.php index 6019471..4246c14 100644 --- a/EventListener/ReplyToHttpResponseListener.php +++ b/EventListener/ReplyToHttpResponseListener.php @@ -20,7 +20,7 @@ public function onKernelException(ExceptionEvent $event): void return; } - /** @var $throwable ReplyInterface */ + /** @var ReplyInterface $throwable */ $throwable = $event->getThrowable(); $response = $this->replyToSymfonyResponseConverter->convert($throwable); diff --git a/Profiler/PayumCollector.php b/Profiler/PayumCollector.php index 42f59d4..b57f386 100644 --- a/Profiler/PayumCollector.php +++ b/Profiler/PayumCollector.php @@ -141,6 +141,9 @@ public function reset(): void $this->data = []; } + /** + * @param array $contextData + */ protected function formatAction(array $contextData): string { return sprintf( @@ -151,6 +154,9 @@ protected function formatAction(array $contextData): string ); } + /** + * @param array $contextData + */ protected function formatReply(array $contextData): string { return sprintf( @@ -160,6 +166,9 @@ protected function formatReply(array $contextData): string ); } + /** + * @param array $contextData + */ protected function formatException(array $contextData): string { return sprintf( @@ -169,6 +178,9 @@ protected function formatException(array $contextData): string ); } + /** + * @param array $contextData + */ protected function formatRequest(array $contextData): string { return sprintf( diff --git a/Resources/doc/configure-payment-in-backend.md b/Resources/doc/configure-payment-in-backend.md index 6109017..38e60cc 100644 --- a/Resources/doc/configure-payment-in-backend.md +++ b/Resources/doc/configure-payment-in-backend.md @@ -20,17 +20,13 @@ namespace Acme\PaymentBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Payum\Core\Model\GatewayConfig as BaseGatewayConfig; -/** - * @ORM\Table - * @ORM\Entity - */ +#[ORM\Table] +#[ORM\Entity] class GatewayConfig extends BaseGatewayConfig { - /** - * @ORM\Column(name="id", type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="IDENTITY") - */ + #[ORM\Column] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: "IDENTITY")] protected int $id; } ``` diff --git a/Resources/doc/custom_purchase_examples.md b/Resources/doc/custom_purchase_examples.md index a557049..06f2c6e 100644 --- a/Resources/doc/custom_purchase_examples.md +++ b/Resources/doc/custom_purchase_examples.md @@ -9,17 +9,13 @@ namespace Acme\PaymentBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Payum\Core\Model\ArrayObject; -/** - * @ORM\Table - * @ORM\Entity - */ +#[ORM\Table] +#[ORM\Entity] class PaymentDetails extends ArrayObject { - /** - * @ORM\Column(name="id", type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="IDENTITY") - */ + #[ORM\Column] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: "IDENTITY")] protected int $id; } ``` diff --git a/Resources/doc/custom_purchase_examples/authorize_net_aim.md b/Resources/doc/custom_purchase_examples/authorize_net_aim.md index be042ba..4e811bf 100644 --- a/Resources/doc/custom_purchase_examples/authorize_net_aim.md +++ b/Resources/doc/custom_purchase_examples/authorize_net_aim.md @@ -46,11 +46,11 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function prepareAuthorizeNetPaymentAction(Request $request) + public function prepareAuthorizeNetPaymentAction(Request $request, Payum $payum) { $gatewayName = 'your_gateway_name'; - $storage = $this->get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails $details */ $details = $storage->create(); @@ -59,7 +59,7 @@ class PaymentController extends Controller $details['clientemail'] = 'user@email.com'; $storage->update($details); - $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_gateway_done' // the route to redirect after capture diff --git a/Resources/doc/custom_purchase_examples/be2bill.md b/Resources/doc/custom_purchase_examples/be2bill.md index 8e8b438..ad3e538 100644 --- a/Resources/doc/custom_purchase_examples/be2bill.md +++ b/Resources/doc/custom_purchase_examples/be2bill.md @@ -47,11 +47,11 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function prepareBe2BillPaymentAction(Request $request) + public function prepareBe2BillPaymentAction(Request $request, Payum $payum) { $gatewayName = 'your_gateway_name'; - $storage = $this->get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails */ $details = $storage->create(); @@ -65,7 +65,7 @@ class PaymentController extends Controller $details['ORDERID'] = 'orderId'; $storage->update($details); - $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; diff --git a/Resources/doc/custom_purchase_examples/be2bill_onsite.md b/Resources/doc/custom_purchase_examples/be2bill_onsite.md index ec387b1..512e879 100644 --- a/Resources/doc/custom_purchase_examples/be2bill_onsite.md +++ b/Resources/doc/custom_purchase_examples/be2bill_onsite.md @@ -48,13 +48,13 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function prepareBe2BillPaymentAction(Request $request) + public function prepareBe2BillPaymentAction(Request $request, Payum $payum) { $gatewayName = 'your_gateway_name'; - $storage = $this->getPayum()->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); - /** @var PaymentDetails */ + /** @var PaymentDetails $details */ $details = $storage->create(); //be2bill amount format is cents: for example: 100.05 (EUR). will be 10005. $details['AMOUNT'] = 10005; @@ -63,7 +63,7 @@ class PaymentController extends Controller $details['ORDERID'] = 'orderId'.uniqid(); $storage->update($details); - $captureToken = $this->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; diff --git a/Resources/doc/custom_purchase_examples/klarna_checkout.md b/Resources/doc/custom_purchase_examples/klarna_checkout.md index d4cb217..9b849d4 100644 --- a/Resources/doc/custom_purchase_examples/klarna_checkout.md +++ b/Resources/doc/custom_purchase_examples/klarna_checkout.md @@ -46,11 +46,11 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function preparePaypalExpressCheckoutPaymentAction() + public function preparePaypalExpressCheckoutPaymentAction(Payum $payum) { $paymentName = 'your_gateway_name'; - $storage = $this->get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails $details */ $details = $storage->create(); @@ -59,7 +59,7 @@ class PaymentController extends Controller $details['locale'] = 'sv-se'; $storage->update($details); - $captureToken = $this->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' @@ -69,7 +69,7 @@ class PaymentController extends Controller 'terms_uri' => 'https://example.com/terms', 'checkout_uri' => 'https://example.com/fuck', 'confirmation_uri' => $captureToken->getTargetUrl(), - 'push_uri' => $this->getTokenFactory()->createNotifyToken($gatewayName, $details)->getTargetUrl() + 'push_uri' => $payum->getTokenFactory()->createNotifyToken($gatewayName, $details)->getTargetUrl() ); $details['cart'] = array( 'items' => array( diff --git a/Resources/doc/custom_purchase_examples/klarna_invoice.md b/Resources/doc/custom_purchase_examples/klarna_invoice.md index ea8b6bd..b799c2a 100644 --- a/Resources/doc/custom_purchase_examples/klarna_invoice.md +++ b/Resources/doc/custom_purchase_examples/klarna_invoice.md @@ -46,11 +46,11 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function prepareKlarnaInvoiceAction() + public function prepareKlarnaInvoiceAction(Payum $payum) { $gatewayName = 'your_gateway_name'; - $storage = $this->get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails $details */ $payment = $payum->getPayment($paymentName); @@ -78,7 +78,7 @@ class PaymentController extends Controller ); $storage->update($details); - $captureToken = $this->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' diff --git a/Resources/doc/custom_purchase_examples/payex.md b/Resources/doc/custom_purchase_examples/payex.md index b9cb337..4904667 100644 --- a/Resources/doc/custom_purchase_examples/payex.md +++ b/Resources/doc/custom_purchase_examples/payex.md @@ -46,11 +46,11 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function preparePayexPaymentAction() + public function preparePayexPaymentAction(Payum $payum) { $gatewayName = 'your_gateway_name'; - $storage = $this->getPayum()->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails $details */ $details = $storage->create(); @@ -70,7 +70,7 @@ class PaymentController extends Controller $details['clientLanguage'] = 'en-US'; $storage->update($details); - $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; diff --git a/Resources/doc/custom_purchase_examples/paypal_express_checkout.md b/Resources/doc/custom_purchase_examples/paypal_express_checkout.md index a610f3d..1c75633 100644 --- a/Resources/doc/custom_purchase_examples/paypal_express_checkout.md +++ b/Resources/doc/custom_purchase_examples/paypal_express_checkout.md @@ -47,11 +47,11 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function preparePaypalExpressCheckoutPaymentAction() + public function preparePaypalExpressCheckoutPaymentAction(Payum $payum) { $gatewayName = 'your_gateway_name'; - $storage = $this->get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails $details */ $details = $storage->create(); @@ -59,7 +59,7 @@ class PaymentController extends Controller $details['PAYMENTREQUEST_0_AMT'] = 1.23; $storage->update($details); - $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; diff --git a/Resources/doc/custom_purchase_examples/paypal_pro_checkout.md b/Resources/doc/custom_purchase_examples/paypal_pro_checkout.md index 4dbd3ee..6fc22ec 100644 --- a/Resources/doc/custom_purchase_examples/paypal_pro_checkout.md +++ b/Resources/doc/custom_purchase_examples/paypal_pro_checkout.md @@ -51,11 +51,11 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function preparePaypalProCheckoutPaymentAction(Request $request) + public function preparePaypalProCheckoutPaymentAction(Request $request, Payum $payum) { $gatewayName = 'your_gateway_name'; - $storage = $this->get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails $details */ $details = $storage->create(); @@ -63,7 +63,7 @@ class PaymentController extends Controller $details['currency'] = 'USD'; $storage->update($details); - $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; diff --git a/Resources/doc/custom_purchase_examples/paypal_via_omnipay.md b/Resources/doc/custom_purchase_examples/paypal_via_omnipay.md index ff3a572..1e59403 100644 --- a/Resources/doc/custom_purchase_examples/paypal_via_omnipay.md +++ b/Resources/doc/custom_purchase_examples/paypal_via_omnipay.md @@ -53,11 +53,11 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function preparePaypalPaymentAction(Request $request) + public function preparePaypalPaymentAction(Request $request, Payum $payum) { $gatewayName = 'your_gateway_name'; - $storage = $this->get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails */ $details = $storage->create(); @@ -65,7 +65,7 @@ class PaymentController extends Controller $storage->update($details); - $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; diff --git a/Resources/doc/custom_purchase_examples/stripe_checkout.md b/Resources/doc/custom_purchase_examples/stripe_checkout.md index 5915280..4a116af 100644 --- a/Resources/doc/custom_purchase_examples/stripe_checkout.md +++ b/Resources/doc/custom_purchase_examples/stripe_checkout.md @@ -47,11 +47,11 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function prepareStripeJsPaymentAction(Request $request) + public function prepareStripeJsPaymentAction(Request $request, Payum $payum) { $gatewayName = 'your_gateway_name'; - $storage = $this->getPayum()->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var PaymentDetails $details */ $details = $storage->create(); @@ -60,7 +60,7 @@ class PaymentController extends Controller $details["description"] = 'a description'; $storage->update($details); - $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; diff --git a/Resources/doc/custom_purchase_examples/stripe_js.md b/Resources/doc/custom_purchase_examples/stripe_js.md index 5147e9a..dd1919c 100644 --- a/Resources/doc/custom_purchase_examples/stripe_js.md +++ b/Resources/doc/custom_purchase_examples/stripe_js.md @@ -47,11 +47,11 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function prepareStripeJsPaymentAction(Request $request) + public function prepareStripeJsPaymentAction(Request $request, Payum $payum) { $gatewayName = 'your_gateway_name'; - $storage = $this->getPayum()->getStorage('Acme\GatewayBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\GatewayBundle\Entity\PaymentDetails'); /** @var PaymentDetails $details */ $details = $storage->create(); @@ -60,7 +60,7 @@ class PaymentController extends Controller $details["description"] = 'a description'; $storage->update($details); - $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; diff --git a/Resources/doc/custom_purchase_examples/stripe_via_omnipay.md b/Resources/doc/custom_purchase_examples/stripe_via_omnipay.md index f87a349..2d15f96 100644 --- a/Resources/doc/custom_purchase_examples/stripe_via_omnipay.md +++ b/Resources/doc/custom_purchase_examples/stripe_via_omnipay.md @@ -51,11 +51,11 @@ use Symfony\Component\HttpFoundation\Request; class PaymentController extends Controller { - public function prepareStripePaymentAction(Request $request) + public function prepareStripePaymentAction(Request $request, Payum $payum) { $gatewayName = 'your_gateway_name'; - $storage = $this->get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); + $storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails */ $details = $storage->create(); @@ -63,7 +63,7 @@ class PaymentController extends Controller $storage->update($details); - $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( + $captureToken = $payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; diff --git a/Resources/doc/get_it_started.md b/Resources/doc/get_it_started.md index e408a5d..91b0b8a 100644 --- a/Resources/doc/get_it_started.md +++ b/Resources/doc/get_it_started.md @@ -46,10 +46,8 @@ namespace Acme\PaymentBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Payum\Core\Model\Token; -/** - * @ORM\Table - * @ORM\Entity - */ +#[ORM\Table] +#[ORM\Entity] class PaymentToken extends Token { } @@ -62,17 +60,13 @@ namespace Acme\PaymentBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Payum\Core\Model\Payment as BasePayment; -/** - * @ORM\Table - * @ORM\Entity - */ +#[ORM\Table] +#[ORM\Entity] class Payment extends BasePayment { - /** - * @ORM\Column(name="id", type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="IDENTITY") - */ + #[ORM\Column] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: "IDENTITY")] protected int $id; } ``` diff --git a/Resources/doc/iso4217-or-currency-details.md b/Resources/doc/iso4217-or-currency-details.md index c0b5d32..a5ee32d 100644 --- a/Resources/doc/iso4217-or-currency-details.md +++ b/Resources/doc/iso4217-or-currency-details.md @@ -55,7 +55,7 @@ echo $currency->getCountry(); // US * [The architecture](https://github.com/Payum/Payum/blob/master/docs/the-architecture.md). * [Supported gateways](https://github.com/Payum/Payum/blob/master/docs/supported-gateways.md). * [Storages](storages.md). -* [Capture script](get-it-started.md). +* [Capture script](get_it_started.md). * [Authorize](authorize.md). * [Done script](purchase_done_action.md). diff --git a/Resources/doc/storages.md b/Resources/doc/storages.md index 1c1466f..d306d52 100644 --- a/Resources/doc/storages.md +++ b/Resources/doc/storages.md @@ -11,10 +11,8 @@ namespace Acme\PaymentBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Payum\Core\Model\Token; -/** - * @ORM\Table - * @ORM\Entity - */ +#[ORM\Table] +#[ORM\Entity] class PaymentToken extends Token { } @@ -27,17 +25,13 @@ namespace Acme\PaymentBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Payum\Core\Model\ArrayObject; -/** - * @ORM\Table - * @ORM\Entity - */ +#[ORM\Table] +#[ORM\Entity] class PaymentDetails extends ArrayObject { - /** - * @ORM\Column(name="id", type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="IDENTITY") - */ + #[ORM\Column] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: "IDENTITY")] protected int $id; } ``` @@ -85,9 +79,7 @@ namespace Acme\PaymentBundle\Document; use Doctrine\ODM\MongoDB\Mapping\Annotations as Mongo; use Payum\Core\Model\Token; -/** - * @Mongo\Document - */ +#[Mongo\Document] class PaymentToken extends Token { } @@ -100,14 +92,10 @@ namespace Acme\PaymentBundle\Document; use Doctrine\ODM\MongoDB\Mapping\Annotations as Mongo; use Payum\Core\Model\ArrayObject; -/** - * @Mongo\Document - */ +#[Mongo\Document] class PaymentDetails extends ArrayObject { - /** - * @Mongo\Id - */ + #[Mongo\Id] protected int $id; } ``` @@ -147,7 +135,7 @@ _**Note**: You should use commented path if you install payum/payum package._ ## Propel. -Firstly, you will need to build your schema schema. You can either use your own schema or you can copy the schema into your resources\config file from Payum\Core\Bridge\Propel\Resources\config\schema.xml +Firstly, you will need to build your schema. You can either use your own schema or you can copy the schema into your resources\config file from Payum\Core\Bridge\Propel\Resources\config\schema.xml Once this has been done you will need to implement the required classes ```php diff --git a/composer.json b/composer.json index efc9ccd..21ec090 100644 --- a/composer.json +++ b/composer.json @@ -55,6 +55,7 @@ "payum/stripe": "^1.7", "payum/omnipay-v3-bridge": "^1@alpha", "php-http/guzzle7-adapter": "^1.0", + "phpstan/phpstan": "^1.8", "phpunit/phpunit": "^9.5", "psr/log": "^1 || ^2", "stripe/stripe-php": "~7.0", @@ -76,6 +77,9 @@ "autoload-dev": { "psr-4": { "Payum\\Bundle\\PayumBundle\\Tests\\": "Tests/" } }, + "scripts": { + "phpstan": "env COLUMNS=200 phpstan" + }, "extra": { "branch-alias": { "dev-master": "2.5-dev" diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..60e8c07 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,14 @@ +#includes: + #- phpstan-baseline.neon + +parameters: + paths: + - Command + - Controller + - DependencyInjection + - EventListener + - Form + - Profiler + - Resources + - Traits + level: 6 From e0025e6e54f011cc45c1470b2ef29ea70b64cbb0 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 31 Aug 2022 16:01:06 +0200 Subject: [PATCH 4/7] Update DependencyInjection/Compiler/BuildConfigsPass.php Co-authored-by: Pierre du Plessis --- DependencyInjection/Compiler/BuildConfigsPass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/Compiler/BuildConfigsPass.php b/DependencyInjection/Compiler/BuildConfigsPass.php index 1ccbada..652ded8 100644 --- a/DependencyInjection/Compiler/BuildConfigsPass.php +++ b/DependencyInjection/Compiler/BuildConfigsPass.php @@ -43,7 +43,7 @@ public function process(ContainerBuilder $container): void } /** - * @return array[] + * @return list */ protected function processTagData(array $tagData, string $namePrefix, string $prependKey): array { From 8a45607abb06a3dcbfdf4d51922e6ece19d1a15a Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 31 Aug 2022 16:01:13 +0200 Subject: [PATCH 5/7] Update Command/DebugGatewayCommand.php Co-authored-by: Pierre du Plessis --- Command/DebugGatewayCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Command/DebugGatewayCommand.php b/Command/DebugGatewayCommand.php index cf17638..9f204de 100644 --- a/Command/DebugGatewayCommand.php +++ b/Command/DebugGatewayCommand.php @@ -125,7 +125,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } /** - * @return array + * @return list */ protected function getMethodCode(\ReflectionMethod $reflectionMethod): array { From 1d8d66cc921e7e2d871d314e22bd9104f58c919b Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 31 Aug 2022 16:01:19 +0200 Subject: [PATCH 6/7] Update Command/DebugGatewayCommand.php Co-authored-by: Pierre du Plessis --- Command/DebugGatewayCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Command/DebugGatewayCommand.php b/Command/DebugGatewayCommand.php index 9f204de..db7a915 100644 --- a/Command/DebugGatewayCommand.php +++ b/Command/DebugGatewayCommand.php @@ -161,7 +161,7 @@ private function findProperGatewayName(InputInterface $input, OutputInterface $o /** * @param array $gateways - * @return array + * @return list */ private function findGatewaysContaining(array $gateways, string $name): array { From 2cf17469fd047dffc8c964fb14b82accaa62e06d Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Wed, 31 Aug 2022 16:24:21 +0200 Subject: [PATCH 7/7] feat: drop support of symfony < 6.1, drop support of php < 8.1, remove deprecated functions --- .github/workflows/tests.yaml | 8 ----- CHANGELOG.md | 6 ++-- Command/CreateCaptureTokenCommand.php | 2 +- Command/CreateNotifyTokenCommand.php | 2 +- Tests/Controller/AbstractControllerTest.php | 11 ++----- .../Factory/AbstractStorageFactoryTest.php | 5 +--- .../Command/DebugGatewayCommandTest.php | 6 +++- .../Type/CreditCardExpirationDateTypeTest.php | 12 ++++---- .../Form/Type/CreditCardTypeTest.php | 12 ++++---- .../Form/Type/GatewayConfigTypeTest.php | 12 ++++---- Tests/Functional/app/AppKernel.php | 2 -- Tests/Functional/app/config/config.yml | 7 +++++ Tests/Functional/app/config/config_sf5.yml | 7 ----- Tests/Functional/app/config/config_sf6.yml | 8 ----- composer.json | 29 +++++++++---------- 15 files changed, 50 insertions(+), 79 deletions(-) delete mode 100644 Tests/Functional/app/config/config_sf5.yml delete mode 100644 Tests/Functional/app/config/config_sf6.yml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3a6b0bb..9e03d0f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -14,14 +14,6 @@ jobs: fail-fast: false matrix: include: - - php: 8.0 - symfony: 5.4.* - - php: 8.0 - symfony: 6.0.* - - php: 8.1 - symfony: 5.4.* - - php: 8.1 - symfony: 6.0.* - php: 8.1 symfony: 6.1.* diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cb48e9..5b8cf02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,13 @@ ## 3.0.0 (2022-09-xx) -* Support for Symfony <5.4 dropped -* Support for PHP < 8 dropped +* Support for Symfony < 6.1 dropped +* Support for PHP < 8.1 dropped * remove deprecated functions getPayum, getHttpRequestVerifier and getTokenFactory in PayumController ## 2.5.0 (2022-07-xx) -* Support for Symfony 4.0 - 4.3 dropped +* Support for Symfony 5.0 - 5.3 dropped * Added support for Symfony 6.0 * Minimum Payum Core dependency updated to 1.7.2 diff --git a/Command/CreateCaptureTokenCommand.php b/Command/CreateCaptureTokenCommand.php index 7d2958e..d03d38e 100644 --- a/Command/CreateCaptureTokenCommand.php +++ b/Command/CreateCaptureTokenCommand.php @@ -13,7 +13,7 @@ #[AsCommand(name: 'payum:security:create-capture-token')] class CreateCaptureTokenCommand extends Command { - public function __construct(private Payum $payum) + public function __construct(private readonly Payum $payum) { parent::__construct(); } diff --git a/Command/CreateNotifyTokenCommand.php b/Command/CreateNotifyTokenCommand.php index 99dc322..6a0f1db 100644 --- a/Command/CreateNotifyTokenCommand.php +++ b/Command/CreateNotifyTokenCommand.php @@ -13,7 +13,7 @@ #[AsCommand(name: 'payum:security:create-notify-token')] class CreateNotifyTokenCommand extends Command { - public function __construct(private Payum $payum) + public function __construct(private readonly Payum $payum) { parent::__construct(); } diff --git a/Tests/Controller/AbstractControllerTest.php b/Tests/Controller/AbstractControllerTest.php index 9677a11..646dcd4 100644 --- a/Tests/Controller/AbstractControllerTest.php +++ b/Tests/Controller/AbstractControllerTest.php @@ -20,14 +20,9 @@ abstract class AbstractControllerTest extends TestCase protected Token $token; - /** @var RegistryInterface&MockObject */ - protected $httpRequestVerifierMock; - - /** @var GatewayInterface&MockObject */ - protected $gatewayMock; - - /** @var RegistryInterface&MockObject */ - protected $registryMock; + protected HttpRequestVerifierInterface&MockObject $httpRequestVerifierMock; + protected GatewayInterface&MockObject $gatewayMock; + protected RegistryInterface&MockObject $registryMock; protected Payum $payum; protected Request $request; diff --git a/Tests/DependencyInjection/Factory/AbstractStorageFactoryTest.php b/Tests/DependencyInjection/Factory/AbstractStorageFactoryTest.php index 92ef4db..6102f49 100644 --- a/Tests/DependencyInjection/Factory/AbstractStorageFactoryTest.php +++ b/Tests/DependencyInjection/Factory/AbstractStorageFactoryTest.php @@ -90,10 +90,7 @@ protected function assertDefinitionContainsMethodCall(Definition $serviceDefinit )); } - /** - * @return AbstractStorageFactory|MockObject - */ - protected function createAbstractStorageFactory(): AbstractStorageFactory|MockObject + protected function createAbstractStorageFactory(): AbstractStorageFactory&MockObject { return $this->getMockForAbstractClass(AbstractStorageFactory::class); } diff --git a/Tests/Functional/Command/DebugGatewayCommandTest.php b/Tests/Functional/Command/DebugGatewayCommandTest.php index 476a663..dab6085 100644 --- a/Tests/Functional/Command/DebugGatewayCommandTest.php +++ b/Tests/Functional/Command/DebugGatewayCommandTest.php @@ -113,7 +113,11 @@ protected function executeConsole(Command $command, array $arguments = [], array return $commandTester->getDisplay(); } - protected function getInputStream($input): bool + /** + * @return resource|false + * @noinspection PhpMissingReturnTypeInspection + */ + protected function getInputStream($input) { $stream = fopen('php://memory', 'r+', false); fwrite($stream, $input); diff --git a/Tests/Functional/Form/Type/CreditCardExpirationDateTypeTest.php b/Tests/Functional/Form/Type/CreditCardExpirationDateTypeTest.php index b68c2de..0a52edc 100644 --- a/Tests/Functional/Form/Type/CreditCardExpirationDateTypeTest.php +++ b/Tests/Functional/Form/Type/CreditCardExpirationDateTypeTest.php @@ -28,13 +28,11 @@ protected function setUp(): void */ public function couldBeCreatedByFormFactory(): void { - if (Kernel::MAJOR_VERSION === 6) { - /** @var RequestStack $requestStack */ - $requestStack = self::getContainer()->get(RequestStack::class); - $request = Request::createFromGlobals(); - $request->setSession(new Session(new MockArraySessionStorage())); - $requestStack->push($request); - } + /** @var RequestStack $requestStack */ + $requestStack = self::getContainer()->get(RequestStack::class); + $request = Request::createFromGlobals(); + $request->setSession(new Session(new MockArraySessionStorage())); + $requestStack->push($request); $form = $this->formFactory->create(CreditCardExpirationDateType::class); $view = $form->createView(); diff --git a/Tests/Functional/Form/Type/CreditCardTypeTest.php b/Tests/Functional/Form/Type/CreditCardTypeTest.php index ad84cb3..21c4d8c 100644 --- a/Tests/Functional/Form/Type/CreditCardTypeTest.php +++ b/Tests/Functional/Form/Type/CreditCardTypeTest.php @@ -29,13 +29,11 @@ protected function setUp(): void */ public function couldBeCreatedByFormFactory(): void { - if (Kernel::MAJOR_VERSION === 6) { - /** @var RequestStack $requestStack */ - $requestStack = self::getContainer()->get(RequestStack::class); - $request = Request::createFromGlobals(); - $request->setSession(new Session(new MockArraySessionStorage())); - $requestStack->push($request); - } + /** @var RequestStack $requestStack */ + $requestStack = self::getContainer()->get(RequestStack::class); + $request = Request::createFromGlobals(); + $request->setSession(new Session(new MockArraySessionStorage())); + $requestStack->push($request); $form = $this->formFactory->create(CreditCardType::class); $view = $form->createView(); diff --git a/Tests/Functional/Form/Type/GatewayConfigTypeTest.php b/Tests/Functional/Form/Type/GatewayConfigTypeTest.php index 63ff63e..6ab7f4d 100644 --- a/Tests/Functional/Form/Type/GatewayConfigTypeTest.php +++ b/Tests/Functional/Form/Type/GatewayConfigTypeTest.php @@ -29,13 +29,11 @@ protected function setUp(): void */ public function couldBeCreatedByFormFactory(): void { - if (Kernel::MAJOR_VERSION === 6) { - /** @var RequestStack $requestStack */ - $requestStack = self::getContainer()->get(RequestStack::class); - $request = Request::createFromGlobals(); - $request->setSession(new Session(new MockArraySessionStorage())); - $requestStack->push($request); - } + /** @var RequestStack $requestStack */ + $requestStack = self::getContainer()->get(RequestStack::class); + $request = Request::createFromGlobals(); + $request->setSession(new Session(new MockArraySessionStorage())); + $requestStack->push($request); $form = $this->formFactory->create(GatewayConfigType::class, null, [ 'data_class' => GatewayConfig::class, diff --git a/Tests/Functional/app/AppKernel.php b/Tests/Functional/app/AppKernel.php index 64c53ee..f6be51d 100644 --- a/Tests/Functional/app/AppKernel.php +++ b/Tests/Functional/app/AppKernel.php @@ -32,8 +32,6 @@ public function getLogDir(): string public function registerContainerConfiguration(LoaderInterface $loader): void { $loader->load(__DIR__ . '/config/config.yml'); - - $loader->load(__DIR__ . '/config/config_sf' . Kernel::MAJOR_VERSION . '.yml'); } public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response diff --git a/Tests/Functional/app/config/config.yml b/Tests/Functional/app/config/config.yml index 7c01d92..bda5b6c 100644 --- a/Tests/Functional/app/config/config.yml +++ b/Tests/Functional/app/config/config.yml @@ -12,6 +12,13 @@ framework: form: true csrf_protection: true assets: false + session: + handler_id: null + cookie_secure: auto + cookie_samesite: lax + storage_factory_id: session.storage.factory.mock_file + validation: { enable_annotations: false } + http_method_override: false payum: storages: diff --git a/Tests/Functional/app/config/config_sf5.yml b/Tests/Functional/app/config/config_sf5.yml deleted file mode 100644 index 23ffbdc..0000000 --- a/Tests/Functional/app/config/config_sf5.yml +++ /dev/null @@ -1,7 +0,0 @@ -framework: - session: - handler_id: null - cookie_secure: auto - cookie_samesite: lax - storage_factory_id: session.storage.factory.mock_file - validation: { enable_annotations: false } diff --git a/Tests/Functional/app/config/config_sf6.yml b/Tests/Functional/app/config/config_sf6.yml deleted file mode 100644 index 199e1e3..0000000 --- a/Tests/Functional/app/config/config_sf6.yml +++ /dev/null @@ -1,8 +0,0 @@ -framework: - session: - handler_id: null - cookie_secure: auto - cookie_samesite: lax - storage_factory_id: session.storage.factory.mock_file - validation: { enable_annotations: false } - http_method_override: false diff --git a/composer.json b/composer.json index 21ec090..24ef698 100644 --- a/composer.json +++ b/composer.json @@ -37,16 +37,16 @@ } ], "require": { - "php": "^8.0", - "payum/core": "^1.7.2", - "symfony/framework-bundle": "^5.4 || ^6.0", - "symfony/form": "^5.4 || ^6.0", - "symfony/validator": "^5.4 || ^6.0", - "symfony/security-csrf": "^5.4 || ^6.0" + "php": "^8.1", + "payum/core": "^1.7.3", + "symfony/framework-bundle": "^6.1", + "symfony/form": "^6.1", + "symfony/validator": "^6.1", + "symfony/security-csrf": "^6.1" }, "require-dev": { "defuse/php-encryption": "^2.3", - "doctrine/orm": "^2.8", + "doctrine/orm": "^2.9", "omnipay/common": "^3@dev", "omnipay/dummy": "^3@alpha", "omnipay/paypal": "^3@dev", @@ -57,15 +57,14 @@ "php-http/guzzle7-adapter": "^1.0", "phpstan/phpstan": "^1.8", "phpunit/phpunit": "^9.5", - "psr/log": "^1 || ^2", "stripe/stripe-php": "~7.0", - "symfony/browser-kit": "^5.4 || ^6.0", - "symfony/expression-language": "^5.4 || ^6.0", - "symfony/phpunit-bridge": "^6.0", - "symfony/templating": "^5.4 || ^6.0", - "symfony/twig-bundle": "^5.4 || ^6.0", - "symfony/web-profiler-bundle": "^5.4 || ^6.0", - "symfony/yaml": "^5.4 || ^6.0", + "symfony/browser-kit": "^6.1", + "symfony/expression-language": "^6.1", + "symfony/phpunit-bridge": "^6.1", + "symfony/templating": "^6.1", + "symfony/twig-bundle": "^6.1", + "symfony/web-profiler-bundle": "^6.1", + "symfony/yaml": "^6.1", "twig/twig": "^2.0 || ^3.0" }, "suggest": {