diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d4a19142..9e03d0f9 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -14,22 +14,6 @@ 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 - symfony: 6.0.* - php: 8.1 symfony: 6.1.* @@ -59,7 +43,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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cbae576..5b8cf022 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 3.0.0 (2022-09-xx) + +* 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 5.0 - 5.3 dropped diff --git a/Command/CreateCaptureTokenCommand.php b/Command/CreateCaptureTokenCommand.php index d2208094..d03d38ee 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 readonly 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') @@ -50,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, @@ -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 4021137a..6a0f1dbc 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 readonly 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') @@ -48,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, @@ -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 4f14bbb0..db7a9154 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; @@ -16,13 +17,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 +28,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.') ; @@ -62,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; } @@ -127,9 +121,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - return 0; + return Command::SUCCESS; } + /** + * @return list + */ protected function getMethodCode(\ReflectionMethod $reflectionMethod): array { $file = file($reflectionMethod->getFileName()); @@ -142,7 +139,10 @@ protected function getMethodCode(\ReflectionMethod $reflectionMethod): array return array_values($methodCodeLines); } - private function findProperGatewayName(InputInterface $input, OutputInterface $output, array $gateways, string $name) + /** + * @param array $gateways + */ + private function findProperGatewayName(InputInterface $input, OutputInterface $output, array $gateways, string $name): string { $helperSet = $this->getHelperSet(); if (!$helperSet->has('question') || isset($gateways[$name]) || !$input->isInteractive()) { @@ -159,6 +159,10 @@ private function findProperGatewayName(InputInterface $input, OutputInterface $o return $this->getHelper('question')->ask($input, $output, $question); } + /** + * @param array $gateways + * @return list + */ private function findGatewaysContaining(array $gateways, string $name): array { $threshold = 1e3; diff --git a/Command/StatusCommand.php b/Command/StatusCommand.php index c7f02876..cb723827 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') @@ -48,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, @@ -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 b4d5bf68..5965e39a 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 002c1d47..e1c1ff8d 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 ff6d7a81..d3a3153c 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 15a4870c..723b0c0f 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 ca211e23..fac6c70e 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 09a23238..db494283 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 b1bfb7fe..6993bcd9 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 3051b542..2011635d 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/BuildConfigsPass.php b/DependencyInjection/Compiler/BuildConfigsPass.php index 28e7c13d..652ded87 100644 --- a/DependencyInjection/Compiler/BuildConfigsPass.php +++ b/DependencyInjection/Compiler/BuildConfigsPass.php @@ -42,6 +42,9 @@ public function process(ContainerBuilder $container): void } } + /** + * @return list + */ protected function processTagData(array $tagData, string $namePrefix, string $prependKey): array { $coreGatewayFactoryConfig = []; diff --git a/DependencyInjection/Compiler/BuildGatewayFactoriesPass.php b/DependencyInjection/Compiler/BuildGatewayFactoriesPass.php index 5e8f8c24..6bf4316b 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 0b4e514a..549e997f 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))); @@ -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 56910465..28e415a4 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 50264a1f..a2edff01 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 1ec38e2a..9f7d4364 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 6cd9fb21..154bf171 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 ca29b406..b83c2542 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 dc3e897c..d05aba89 100644 --- a/DependencyInjection/Factory/Storage/StorageFactoryInterface.php +++ b/DependencyInjection/Factory/Storage/StorageFactoryInterface.php @@ -7,19 +7,16 @@ interface StorageFactoryInterface { /** - * @param string $modelClass + * @param array $config * @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, * For example filesystem, doctrine, propel etc. */ - public function getName(); + public function getName(): string; - /** - * @return void - */ - public function addConfiguration(ArrayNodeDefinition $builder); + public function addConfiguration(ArrayNodeDefinition $builder): void; } diff --git a/DependencyInjection/PayumExtension.php b/DependencyInjection/PayumExtension.php index 4c062718..1cbceed4 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; @@ -169,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) { @@ -184,6 +186,9 @@ protected function loadSecurity(array $securityConfig, ContainerBuilder $contain } } + /** + * @param array $dynamicGatewaysConfig + */ protected function loadDynamicGateways(array $dynamicGatewaysConfig, ContainerBuilder $container): void { $configClass = null; @@ -279,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 6019471e..4246c14b 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 42f59d4c..b57f3866 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 61090170..38e60cca 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 a557049a..06f2c6e9 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 be042ba7..4e811bf5 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 8e8b438d..ad3e538f 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 ec387b1b..512e8793 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 d4cb217d..9b849d42 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 ea8b6bd5..b799c2ae 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 b9cb3375..4904667a 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 a610f3d1..1c756337 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 4dbd3ee4..6fc22ecb 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 ff3a5729..1e594039 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 5915280b..4a116af7 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 5147e9a7..dd1919ca 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 f87a3496..2d15f96d 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 e408a5dd..91b0b8a5 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 c0b5d321..a5ee32d6 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 1c1466fc..d306d527 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/Tests/Controller/AbstractControllerTest.php b/Tests/Controller/AbstractControllerTest.php index 9677a113..646dcd48 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/Controller/AuthorizeControllerTest.php b/Tests/Controller/AuthorizeControllerTest.php index fa667789..6e614a59 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 5714cebf..be4fff50 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 e8f7db3e..ebde7f5e 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 48bd5ad1..f1634501 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 5cf688c3..f6f783fe 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 7bf9c5c2..870825a7 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 733a4b5e..f888150f 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 abea51ae..78751787 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 a0c80b17..d4f2c350 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 d1b97d8b..a0a1d14d 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 2a74d43a..190fd8f3 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 934bfc64..363b058f 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 4d685eac..dab6085f 100644 --- a/Tests/Functional/Command/DebugGatewayCommandTest.php +++ b/Tests/Functional/Command/DebugGatewayCommandTest.php @@ -113,6 +113,10 @@ protected function executeConsole(Command $command, array $arguments = [], array return $commandTester->getDisplay(); } + /** + * @return resource|false + * @noinspection PhpMissingReturnTypeInspection + */ protected function getInputStream($input) { $stream = fopen('php://memory', 'r+', false); diff --git a/Tests/Functional/DependencyInjection/PayumExtensionTest.php b/Tests/Functional/DependencyInjection/PayumExtensionTest.php index 2103f92f..58fa1069 100644 --- a/Tests/Functional/DependencyInjection/PayumExtensionTest.php +++ b/Tests/Functional/DependencyInjection/PayumExtensionTest.php @@ -1,7 +1,6 @@ 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 ad84cb39..21c4d8c9 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 63ff63ed..6ab7f4d9 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/WebTestCase.php b/Tests/Functional/WebTestCase.php index 4eb3f10a..ee081df3 100644 --- a/Tests/Functional/WebTestCase.php +++ b/Tests/Functional/WebTestCase.php @@ -3,40 +3,16 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase; -use Symfony\Component\DependencyInjection\ContainerInterface; -use function get_parent_class; -use function method_exists; abstract class WebTestCase extends BaseWebTestCase { protected KernelBrowser $client; - /** - * @var $container ContainerInterface - * @deprecated since version 2.5. use getContainer() instead - */ - protected static $container; - protected function setUp(): void { parent::setUp(); $this->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 2ff7ea81..f6be51d4 100644 --- a/Tests/Functional/app/AppKernel.php +++ b/Tests/Functional/app/AppKernel.php @@ -1,29 +1,41 @@ load(__DIR__ . '/config/config.yml'); + } + + 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 f846204d..00000000 --- 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.yml b/Tests/Functional/app/config/config.yml index 7c01d920..bda5b6c5 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_sf4.yml b/Tests/Functional/app/config/config_sf4.yml deleted file mode 100644 index 094e00c7..00000000 --- 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_sf5.yml b/Tests/Functional/app/config/config_sf5.yml deleted file mode 100644 index 23ffbdc7..00000000 --- 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 23ffbdc7..00000000 --- a/Tests/Functional/app/config/config_sf6.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/Sonata/GatewayConfigAdminTest.php b/Tests/Sonata/GatewayConfigAdminTest.php index c63a6aa8..4fe42e78 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 5fb20ba8..3251f21e 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 5e72cba5..24ef6983 100644 --- a/composer.json +++ b/composer.json @@ -37,17 +37,16 @@ } ], "require": { - "php": "^7.4 || ^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" + "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", - "doctrine/orm": "^2.8", + "defuse/php-encryption": "^2.3", + "doctrine/orm": "^2.9", "omnipay/common": "^3@dev", "omnipay/dummy": "^3@alpha", "omnipay/paypal": "^3@dev", @@ -56,16 +55,16 @@ "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", - "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": "^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": { @@ -77,6 +76,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 00000000..60e8c07d --- /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 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4aa666be..bb228b5d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,18 +2,12 @@ - ./Tests + ./Tests