Skip to content

Commit 9759d28

Browse files
authored
Merge pull request #21 from mkalkowski83/feature/upgrade-to-sylius1.4
Upgrade plugin to Sylius 1.4
2 parents ebbe1a0 + a8c0501 commit 9759d28

25 files changed

+96
-148
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"phpstan/phpstan-webmozart-assert": "^0.10",
3737
"phpunit/phpunit": "^6.5",
3838
"sensiolabs/security-checker": "^5.0",
39-
"sylius-labs/coding-standard": "^2.0",
39+
"sylius-labs/coding-standard": "^3.0",
4040
"symfony/browser-kit": "^3.4|^4.1",
4141
"symfony/debug-bundle": "^3.4|^4.1",
4242
"symfony/dotenv": "^4.2",

composer.lock

+18-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

easy-coding-standard.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
imports:
2+
- { resource: 'vendor/sylius-labs/coding-standard/easy-coding-standard.yml' }

src/Action/CaptureAction.php

-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ public function __construct(OpenPayUBridgeInterface $openPayUBridge)
4747
}
4848

4949
/**
50-
* @param mixed $api
51-
*
5250
* @throws UnsupportedApiException if the given Api is not supported.
5351
*/
5452
public function setApi($api): void

src/Action/ConvertPaymentAction.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ final class ConvertPaymentAction implements ActionInterface, GatewayAwareInterfa
2626
use GatewayAwareTrait;
2727

2828
/**
29-
* {@inheritDoc}
29+
* {@inheritdoc}
3030
*
3131
* @param Convert $request
3232
*/
3333
public function execute($request): void
3434
{
3535
RequestNotSupportedException::assertSupports($this, $request);
3636

37-
/** @var $payment PaymentInterface */
37+
/** @var PaymentInterface $payment */
3838
$payment = $request->getSource();
3939
$details = ArrayObject::ensureArrayObject($payment->getDetails());
4040

@@ -51,7 +51,7 @@ public function execute($request): void
5151
}
5252

5353
/**
54-
* {@inheritDoc}
54+
* {@inheritdoc}
5555
*/
5656
public function supports($request): bool
5757
{

src/Action/NotifyAction.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public function __construct(OpenPayUBridgeInterface $openPayUBridge)
4040
}
4141

4242
/**
43-
* @param mixed $api
44-
*
4543
* @throws UnsupportedApiException if the given Api is not supported.
4644
*/
4745
public function setApi($api): void
@@ -84,7 +82,7 @@ public function execute($request): void
8482
$response = $result->getResponse();
8583
if ($response->order->orderId) {
8684
/** @var OpenPayU_Result $order */
87-
$order = $this->openPayUBridge->retrieve($response->order->orderId);
85+
$order = $this->openPayUBridge->retrieve($response->order->orderId);
8886
if (OpenPayUBridgeInterface::SUCCESS_API_STATUS === $order->getStatus()) {
8987
if (PaymentInterface::STATE_COMPLETED !== $payment->getState()) {
9088
$status = $order->getResponse()->orders[0]->status;
@@ -103,7 +101,7 @@ public function execute($request): void
103101
}
104102

105103
/**
106-
* {@inheritDoc}
104+
* {@inheritdoc}
107105
*/
108106
public function supports($request): bool
109107
{

src/Action/StatusAction.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public function __construct(OpenPayUBridgeInterface $openPayUBridge)
3232
}
3333

3434
/**
35-
* @param mixed $api
36-
*
3735
* @throws UnsupportedApiException if the given Api is not supported.
3836
*/
3937
public function setApi($api): void
@@ -52,7 +50,7 @@ public function setApi($api): void
5250
}
5351

5452
/**
55-
* {@inheritDoc}
53+
* {@inheritdoc}
5654
*/
5755
public function execute($request): void
5856
{
@@ -65,26 +63,31 @@ public function execute($request): void
6563

6664
if ((null === $status || OpenPayUBridgeInterface::NEW_API_STATUS === $status) && null !== $orderId) {
6765
$request->markNew();
66+
6867
return;
6968
}
7069

7170
if (OpenPayUBridgeInterface::PENDING_API_STATUS === $status) {
7271
$request->markPending();
72+
7373
return;
7474
}
7575

7676
if (OpenPayUBridgeInterface::CANCELED_API_STATUS === $status) {
7777
$request->markCanceled();
78+
7879
return;
7980
}
8081

8182
if (OpenPayUBridgeInterface::WAITING_FOR_CONFIRMATION_PAYMENT_STATUS === $status) {
8283
$request->markSuspended();
84+
8385
return;
8486
}
8587

8688
if (OpenPayUBridgeInterface::COMPLETED_API_STATUS === $status) {
8789
$request->markCaptured();
90+
8891
return;
8992
}
9093

src/BitBagSyliusPayUPlugin.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file was created by the developers from BitBag.
57
* Feel free to contact us once you face any issues or want to start
@@ -13,10 +15,7 @@
1315
use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait;
1416
use Symfony\Component\HttpKernel\Bundle\Bundle;
1517

16-
/**
17-
* @author Mikołaj Król <mikolaj.krol@bitbag.pl>
18-
*/
1918
final class BitBagSyliusPayUPlugin extends Bundle
2019
{
2120
use SyliusPluginTrait;
22-
}
21+
}

src/Bridge/OpenPayUBridge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function setAuthorizationData(
3838

3939
public function create(array $order): ?OpenPayU_Result
4040
{
41-
/** @var null|OpenPayU_Result $result */
41+
/** @var OpenPayU_Result|null $result */
4242
$result = OpenPayU_Order::create($order);
4343

4444
return $result;

src/Bridge/OpenPayUBridgeInterface.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616

1717
interface OpenPayUBridgeInterface
1818
{
19-
public const SANDBOX_ENVIRONMENT = 'sandbox';
20-
public const SECURE_ENVIRONMENT = 'secure';
21-
22-
public const NEW_API_STATUS = 'NEW';
23-
public const PENDING_API_STATUS = 'PENDING';
24-
public const COMPLETED_API_STATUS = 'COMPLETED';
25-
public const SUCCESS_API_STATUS = 'SUCCESS';
26-
public const CANCELED_API_STATUS = 'CANCELED';
27-
public const COMPLETED_PAYMENT_STATUS = 'COMPLETED';
28-
public const PENDING_PAYMENT_STATUS = 'PENDING';
29-
public const CANCELED_PAYMENT_STATUS = 'CANCELED';
19+
public const SANDBOX_ENVIRONMENT = 'sandbox';
20+
public const SECURE_ENVIRONMENT = 'secure';
21+
22+
public const NEW_API_STATUS = 'NEW';
23+
public const PENDING_API_STATUS = 'PENDING';
24+
public const COMPLETED_API_STATUS = 'COMPLETED';
25+
public const SUCCESS_API_STATUS = 'SUCCESS';
26+
public const CANCELED_API_STATUS = 'CANCELED';
27+
public const COMPLETED_PAYMENT_STATUS = 'COMPLETED';
28+
public const PENDING_PAYMENT_STATUS = 'PENDING';
29+
public const CANCELED_PAYMENT_STATUS = 'CANCELED';
3030
public const WAITING_FOR_CONFIRMATION_PAYMENT_STATUS = 'WAITING_FOR_CONFIRMATION';
31-
public const REJECTED_STATUS = 'REJECTED';
31+
public const REJECTED_STATUS = 'REJECTED';
3232

3333
public function setAuthorizationData(
3434
string $environment,

src/DependencyInjection/BitBagSyliusPayUExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class BitBagSyliusPayUExtension extends Extension
2121
{
2222
public function load(array $configs, ContainerBuilder $container): void
2323
{
24-
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
24+
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
2525
$loader->load('services.xml');
2626
}
2727
}

src/Exception/PayUException.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file was created by the developers from BitBag.
57
* Feel free to contact us once you face any issues or want to start
@@ -12,12 +14,9 @@
1214

1315
use Payum\Core\Exception\Http\HttpException;
1416

15-
/**
16-
* @author Mikołaj Król <mikolaj.krol@bitbag.pl>
17-
*/
1817
final class PayUException extends HttpException
1918
{
20-
const LABEL = 'PayUException';
19+
public const LABEL = 'PayUException';
2120

2221
public static function newInstance($status)
2322
{
@@ -35,7 +34,7 @@ public static function newInstance($status)
3534
$parts[] = '[reason phrase] ' . $status->statusDesc;
3635
}
3736

38-
$message = implode(PHP_EOL, $parts);
37+
$message = implode(\PHP_EOL, $parts);
3938

4039
return new static($message);
4140
}

src/Form/Type/PayUGatewayConfigurationType.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file was created by the developers from BitBag.
57
* Feel free to contact us once you face any issues or want to start
@@ -17,9 +19,6 @@
1719
use Symfony\Component\Form\FormBuilderInterface;
1820
use Symfony\Component\Validator\Constraints\NotBlank;
1921

20-
/**
21-
* @author Mikołaj Król <mikolaj.krol@bitbag.pl>
22-
*/
2322
final class PayUGatewayConfigurationType extends AbstractType
2423
{
2524
/**

tests/Application/Kernel.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ protected function getContainerLoader(ContainerInterface $container): LoaderInte
8686
Assert::isInstanceOf($container, ContainerBuilder::class);
8787

8888
$locator = new FileLocator($this, $this->getRootDir() . '/Resources');
89-
$resolver = new LoaderResolver(array(
89+
$resolver = new LoaderResolver([
9090
new XmlFileLoader($container, $locator),
9191
new YamlFileLoader($container, $locator),
9292
new IniFileLoader($container, $locator),
9393
new PhpFileLoader($container, $locator),
9494
new GlobFileLoader($container, $locator),
9595
new DirectoryLoader($container, $locator),
9696
new ClosureLoader($container),
97-
));
97+
]);
9898

9999
return new DelegatingLoader($resolver);
100100
}

tests/Application/bin/console

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env php
22
<?php
33

4-
use Tests\BitBag\SyliusPayUPlugin\Application\Kernel;
54
use Symfony\Bundle\FrameworkBundle\Console\Application;
65
use Symfony\Component\Console\Input\ArgvInput;
76
use Symfony\Component\Debug\Debug;
7+
use Tests\BitBag\SyliusPayUPlugin\Application\Kernel;
88

99
set_time_limit(0);
1010

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use Symfony\Component\Dotenv\Dotenv;
46

5-
require dirname(__DIR__).'../../../vendor/autoload.php';
7+
require dirname(__DIR__) . '../../../vendor/autoload.php';
68

79
// Load cached env vars if the .env.local.php file exists
810
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
9-
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
11+
if (is_array($env = @include dirname(__DIR__) . '/.env.local.php')) {
1012
$_SERVER += $env;
1113
$_ENV += $env;
1214
} elseif (!class_exists(Dotenv::class)) {
1315
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
1416
} else {
1517
// load all the .env files
16-
(new Dotenv())->loadEnv(dirname(__DIR__).'/.env');
18+
(new Dotenv())->loadEnv(dirname(__DIR__) . '/.env');
1719
}
1820

1921
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
2022
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
21-
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
23+
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0';

tests/Application/config/bundles.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
return [
46
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
57
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],

0 commit comments

Comments
 (0)