Skip to content

Commit

Permalink
Merge pull request #435 from Rafikooo/1.6-update-ci-amend
Browse files Browse the repository at this point in the history
Drop `Sylius ~1.12.0`, Update CI Definition & Fix Build
  • Loading branch information
GSadee authored Nov 6, 2024
2 parents 1aad843 + b7dfd00 commit ef5a7d7
Show file tree
Hide file tree
Showing 83 changed files with 345 additions and 411 deletions.
34 changes: 14 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
cron: "0 1 * * 6" # Run at 1am every Saturday
workflow_dispatch: ~

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
Expand All @@ -25,7 +29,7 @@ jobs:
matrix:
php: ["8.1", "8.2"]
symfony: ["^5.4.21", "^6.4"]
sylius: ["~1.12.0", "~1.13.0",]
sylius: ["~1.13.0"]
node: ["20.x"]
mysql: ["8.0"]
wkhtmltopdf: ["0.12.6-1"]
Expand All @@ -40,14 +44,6 @@ jobs:
mysql: "8.0"
wkhtmltopdf: "0.12.6-1"
state_machine_adapter: "symfony_workflow"
-
php: "8.2"
symfony: "^6.4"
sylius: "~1.12.0"
node: "20.x"
mysql: "8.0"
wkhtmltopdf: false
state_machine_adapter: "winzou_state_machine"
-
php: "8.2"
symfony: "^6.4"
Expand All @@ -57,10 +53,6 @@ jobs:
wkhtmltopdf: false
state_machine_adapter: "symfony_workflow"

exclude:
-
sylius: "~1.12.0"
state_machine_adapter: "symfony_workflow"

env:
APP_ENV: test
Expand Down Expand Up @@ -140,11 +132,11 @@ jobs:
-
name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

-
name: Cache Composer
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
Expand All @@ -171,11 +163,11 @@ jobs:
-
name: Get Yarn cache directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

-
name: Cache Yarn
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
Expand Down Expand Up @@ -247,9 +239,11 @@ jobs:

-
name: Upload Behat logs
uses: actions/upload-artifact@v2
if: failure()
uses: actions/upload-artifact@v4
with:
name: Behat logs
name: "Behat logs - ${{ matrix.sylius }}-${{ github.run_id }}-${{ github.run_number }}"
path: etc/build/
if-no-files-found: ignore
compression-level: 6
overwrite: true
include-hidden-files: false
5 changes: 5 additions & 0 deletions UPGRADE-1.6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### UPGRADE FROM 1.5.X TO 1.6.0

1. Support for Sylius 1.12 has been dropped, upgrade your application to [Sylius 1.13](https://github.com/Sylius/Sylius/blob/1.13/UPGRADE-1.13.md).
or to [Sylius 1.14](https://github.com/Sylius/Sylius/blob/1.14/UPGRADE-1.14.md).

5 changes: 5 additions & 0 deletions behat.yml.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This file is part of the Sylius package.
# (c) Sylius Sp. z o.o.

imports:
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml
- tests/Behat/Resources/suites.yml
Expand Down Expand Up @@ -61,3 +64,5 @@ default:
FriendsOfBehat\ExcludeSpecificationsExtension:
features:
- features/pdf_generation_disabled

SyliusLabs\SuiteTagsExtension: ~
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"myclabs/php-enum": "^1.7",
"php-http/message-factory": "^1.1",
"sylius/resource-bundle": "^1.9",
"sylius/sylius": "~1.12.0 || ~1.13.0",
"sylius/sylius": "~1.13.0",
"symfony/messenger": "^5.4.21 || ^6.4"
},
"require-dev": {
Expand All @@ -49,6 +49,7 @@
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sylius-labs/coding-standard": "^4.2",
"sylius-labs/suite-tags-extension": "~0.1",
"symfony/browser-kit": "^5.4.21 || ^6.4",
"symfony/debug-bundle": "^5.4.21 || ^6.4",
"symfony/dotenv": "^5.4.21 || ^6.4",
Expand Down
11 changes: 4 additions & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,25 @@ parameters:
paths:
- src

checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false

excludePaths:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'

# Test dependencies
- 'tests/Application/app/**.php'
- 'tests/Application/src/**.php'

# BC compatibility
- 'src/Converter/OrderItemUnitLineItemsConverter.php'
- 'src/Converter/RequestToOrderItemUnitRefundConverter.php'
- 'src/Converter/RequestToShipmentRefundConverter.php'
- 'src/Converter/ShipmentLineItemsConverter.php'
- 'src/Provider/RemainingTotalProvider.php'

ignoreErrors:
- '/Method Sylius\\RefundPlugin\\Entity\\CustomerBillingData::id\(\) has no return type specified./'
- '/Call to an undefined method [a-zA-Z\\]+::createQueryBuilder\(\)./'
- '/Method Sylius\\RefundPlugin\\[a-zA-Z\\]+::getFlashBag\(\) should return Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface but returns Symfony\\Component\\HttpFoundation\\Session\\SessionBagInterface\./'
- '/Method Sylius\\RefundPlugin\\Entity\\CustomerBillingData::getId\(\) has no return type specified./'
- '/Method Sylius\\RefundPlugin\\Entity\\CustomerBillingData::id\(\) has no return type specified./'
- '/Method Sylius\\RefundPlugin\\Entity\\CustomerBillingData::setId\(\) has parameter \$id with no type specified./'
- '/Method Sylius\\RefundPlugin\\Entity\\CustomerBillingDataInterface::id\(\) has no return type specified./'
- '/Method Sylius\\RefundPlugin\\Entity\\CustomerBillingDataInterface::setId\(\) has parameter \$id with no type specified./'
- '/Method Sylius\\RefundPlugin\\[a-zA-Z\\]+::getFlashBag\(\) should return Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface but returns Symfony\\Component\\HttpFoundation\\Session\\SessionBagInterface\./'
- '/Call to an undefined method [a-zA-Z\\]+::createQueryBuilder\(\)./'
6 changes: 3 additions & 3 deletions src/Action/Admin/DownloadCreditMemoAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
final class DownloadCreditMemoAction
{
public function __construct(
private CreditMemoFileResolverInterface $creditMemoFileResolver,
private CreditMemoFileResponseBuilderInterface $creditMemoFileResponseBuilder,
private bool $hasEnabledPdfFileGenerator,
private readonly CreditMemoFileResolverInterface $creditMemoFileResolver,
private readonly CreditMemoFileResponseBuilderInterface $creditMemoFileResponseBuilder,
private readonly bool $hasEnabledPdfFileGenerator,
) {
}

Expand Down
13 changes: 7 additions & 6 deletions src/Action/Admin/OrderRefundsListAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@

final class OrderRefundsListAction
{
/** @param OrderRepositoryInterface<OrderInterface> $orderRepository */
public function __construct(
private OrderRepositoryInterface $orderRepository,
private OrderRefundingAvailabilityCheckerInterface $orderRefundsListAvailabilityChecker,
private RefundPaymentMethodsProviderInterface $refundPaymentMethodsProvider,
private Environment $twig,
private SessionInterface | RequestStack $requestStackOrSession,
private UrlGeneratorInterface $router,
private readonly OrderRepositoryInterface $orderRepository,
private readonly OrderRefundingAvailabilityCheckerInterface $orderRefundsListAvailabilityChecker,
private readonly RefundPaymentMethodsProviderInterface $refundPaymentMethodsProvider,
private readonly Environment $twig,
private readonly SessionInterface | RequestStack $requestStackOrSession,
private readonly UrlGeneratorInterface $router,
) {
if ($this->requestStackOrSession instanceof SessionInterface) {
trigger_deprecation('sylius/refund-plugin', '1.3', sprintf('Passing an instance of %s as constructor argument for %s is deprecated as of Sylius Refund Plugin 1.3 and will be removed in 2.0. Pass an instance of %s instead.', SessionInterface::class, self::class, RequestStack::class));
Expand Down
12 changes: 6 additions & 6 deletions src/Action/Admin/RefundUnitsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
final class RefundUnitsAction
{
public function __construct(
private MessageBusInterface $commandBus,
private SessionInterface|RequestStack $requestStackOrSession,
private UrlGeneratorInterface $router,
private RequestCommandCreatorInterface|RefundUnitsCommandCreatorInterface $commandCreator,
private LoggerInterface $logger,
private CsrfTokenManagerInterface $csrfTokenManager,
private readonly MessageBusInterface $commandBus,
private readonly SessionInterface|RequestStack $requestStackOrSession,
private readonly UrlGeneratorInterface $router,
private readonly RequestCommandCreatorInterface|RefundUnitsCommandCreatorInterface $commandCreator,
private readonly LoggerInterface $logger,
private readonly CsrfTokenManagerInterface $csrfTokenManager,
) {
if ($this->requestStackOrSession instanceof SessionInterface) {
trigger_deprecation('sylius/refund-plugin', '1.3', sprintf('Passing an instance of %s as constructor argument for %s is deprecated as of Sylius Refund Plugin 1.3 and will be removed in 2.0. Pass an instance of %s instead.', SessionInterface::class, self::class, RequestStack::class));
Expand Down
8 changes: 4 additions & 4 deletions src/Action/Admin/SendCreditMemoAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
final class SendCreditMemoAction
{
public function __construct(
private MessageBusInterface $commandBus,
private RepositoryInterface $creditMemoRepository,
private SessionInterface | RequestStack $requestStackOrSession,
private UrlGeneratorInterface $router,
private readonly MessageBusInterface $commandBus,
private readonly RepositoryInterface $creditMemoRepository,
private readonly SessionInterface | RequestStack $requestStackOrSession,
private readonly UrlGeneratorInterface $router,
) {
if ($this->requestStackOrSession instanceof SessionInterface) {
trigger_deprecation('sylius/refund-plugin', '1.3', sprintf('Passing an instance of %s as constructor argument for %s is deprecated as of Sylius Refund Plugin 1.3 and will be removed in 2.0. Pass an instance of %s instead.', SessionInterface::class, self::class, RequestStack::class));
Expand Down
14 changes: 9 additions & 5 deletions src/Action/CompleteRefundPaymentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@

final class CompleteRefundPaymentAction
{
/**
* @param ObjectRepository<RefundPaymentInterface> $refundPaymentRepository
* @param OrderRepositoryInterface<OrderInterface> $orderRepository
*/
public function __construct(
private SessionInterface | RequestStack $requestStackOrSession,
private ObjectRepository $refundPaymentRepository,
private OrderRepositoryInterface $orderRepository,
private RefundPaymentCompletedStateApplierInterface $refundPaymentCompletedStateApplier,
private RouterInterface $router,
private readonly SessionInterface | RequestStack $requestStackOrSession,
private readonly ObjectRepository $refundPaymentRepository,
private readonly OrderRepositoryInterface $orderRepository,
private readonly RefundPaymentCompletedStateApplierInterface $refundPaymentCompletedStateApplier,
private readonly RouterInterface $router,
) {
if ($this->requestStackOrSession instanceof SessionInterface) {
trigger_deprecation('sylius/refund-plugin', '1.3', sprintf('Passing an instance of %s as constructor argument for %s is deprecated as of Sylius Refund Plugin 1.3 and will be removed in 2.0. Pass an instance of %s instead.', SessionInterface::class, self::class, RequestStack::class));
Expand Down
8 changes: 4 additions & 4 deletions src/Action/Shop/DownloadCreditMemoAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
final class DownloadCreditMemoAction
{
public function __construct(
private CreditMemoFileResolverInterface $creditMemoFileResolver,
private CreditMemoCustomerRelationCheckerInterface $creditMemoCustomerRelationChecker,
private CreditMemoFileResponseBuilderInterface $creditMemoFileResponseBuilder,
private bool $hasEnabledPdfFileGenerator,
private readonly CreditMemoFileResolverInterface $creditMemoFileResolver,
private readonly CreditMemoCustomerRelationCheckerInterface $creditMemoCustomerRelationChecker,
private readonly CreditMemoFileResponseBuilderInterface $creditMemoFileResponseBuilder,
private readonly bool $hasEnabledPdfFileGenerator,
) {
}

Expand Down
5 changes: 1 addition & 4 deletions src/Calculator/UnitRefundTotalCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@

final class UnitRefundTotalCalculator implements UnitRefundTotalCalculatorInterface
{
private RemainingTotalProviderInterface $remainingTotalProvider;

public function __construct(RemainingTotalProviderInterface $remainingTotalProvider)
public function __construct(private readonly RemainingTotalProviderInterface $remainingTotalProvider)
{
$this->remainingTotalProvider = $remainingTotalProvider;
}

public function calculateForUnitWithIdAndType(int $id, RefundTypeInterface $refundType, ?float $amount = null): int
Expand Down
10 changes: 2 additions & 8 deletions src/Checker/CreditMemoCustomerRelationChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,10 @@

final class CreditMemoCustomerRelationChecker implements CreditMemoCustomerRelationCheckerInterface
{
private CustomerContextInterface $customerContext;

private RepositoryInterface $creditMemoRepository;

public function __construct(
CustomerContextInterface $customerContext,
RepositoryInterface $creditMemoRepository,
private readonly CustomerContextInterface $customerContext,
private readonly RepositoryInterface $creditMemoRepository,
) {
$this->customerContext = $customerContext;
$this->creditMemoRepository = $creditMemoRepository;
}

public function check(string $creditMemoId): void
Expand Down
5 changes: 1 addition & 4 deletions src/Checker/OrderFullyRefundedTotalChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@

final class OrderFullyRefundedTotalChecker implements OrderFullyRefundedTotalCheckerInterface
{
private OrderRefundedTotalProviderInterface $orderRefundedTotalProvider;

public function __construct(OrderRefundedTotalProviderInterface $orderRefundedTotalProvider)
public function __construct(private readonly OrderRefundedTotalProviderInterface $orderRefundedTotalProvider)
{
$this->orderRefundedTotalProvider = $orderRefundedTotalProvider;
}

public function isOrderFullyRefunded(OrderInterface $order): bool
Expand Down
6 changes: 2 additions & 4 deletions src/Checker/OrderRefundingAvailabilityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

final class OrderRefundingAvailabilityChecker implements OrderRefundingAvailabilityCheckerInterface
{
private OrderRepositoryInterface $orderRepository;

public function __construct(OrderRepositoryInterface $orderRepository)
/** @param OrderRepositoryInterface<OrderInterface> $orderRepository */
public function __construct(private readonly OrderRepositoryInterface $orderRepository)
{
$this->orderRepository = $orderRepository;
}

public function __invoke(string $orderNumber): bool
Expand Down
13 changes: 6 additions & 7 deletions src/Checker/OrderRefundsListAvailabilityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\OrderPaymentStates;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Webmozart\Assert\Assert;

final class OrderRefundsListAvailabilityChecker implements OrderRefundingAvailabilityCheckerInterface
{
private OrderRepositoryInterface $orderRepository;

public function __construct(OrderRepositoryInterface $orderRepository)
/** @param OrderRepositoryInterface<OrderInterface> $orderRepository */
public function __construct(private readonly OrderRepositoryInterface $orderRepository)
{
$this->orderRepository = $orderRepository;
}

public function __invoke(string $orderNumber): bool
{
/** @var OrderInterface $order */
/** @var OrderInterface|null $order */
$order = $this->orderRepository->findOneByNumber($orderNumber);
Assert::notNull($order);
if ($order === null) {
throw new \InvalidArgumentException(sprintf('Order with number "%s" does not exist.', $orderNumber));
}

return
in_array($order->getPaymentState(), [
Expand Down
5 changes: 1 addition & 4 deletions src/Checker/UnitRefundingAvailabilityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@

final class UnitRefundingAvailabilityChecker implements UnitRefundingAvailabilityCheckerInterface
{
private RemainingTotalProviderInterface $remainingTotalProvider;

public function __construct(RemainingTotalProviderInterface $remainingTotalProvider)
public function __construct(private readonly RemainingTotalProviderInterface $remainingTotalProvider)
{
$this->remainingTotalProvider = $remainingTotalProvider;
}

public function __invoke(int $unitId, RefundTypeInterface $refundType): bool
Expand Down
8 changes: 7 additions & 1 deletion src/Command/GenerateCreditMemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@

class GenerateCreditMemo
{
/** @var ShipmentRefund[] */
private array $shipments = [];

/**
* @param array|UnitRefundInterface[] $units
* @param string|array<string, string> $comment
*/
public function __construct(
private string $orderNumber,
private int $total,
/** @var array|UnitRefundInterface[] */
private array $units,
private readonly array $units,
private string|array $comment,
) {
$args = func_get_args();
Expand All @@ -35,6 +40,7 @@ public function __construct(
throw new \InvalidArgumentException('The 5th argument must be present.');
}

/** @phpstan-ignore-next-line */
$this->shipments = $comment;
$this->comment = $args[4];

Expand Down
Loading

0 comments on commit ef5a7d7

Please sign in to comment.