Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maintenance][Refactor] Bump plugin to 1.14 #331

Merged
merged 12 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,32 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.1", "8.2"]
php: ["8.3"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the single builds for PHP 8.1 and 8.2 should stay

symfony: ["^5.4.21", "^6.4"]
sylius: ["~1.12.0", "~1.13.0",]
sylius: ["~1.13.0", "1.14.x-dev"]
node: ["20.x"]
mysql: ["8.0"]
mysql: ["8.4"]
wkhtmltopdf: ["0.12.6-1"]
state_machine_adapter: [ "winzou_state_machine", "symfony_workflow" ]
state_machine_adapter: [ "symfony_workflow" ]

include:
-
php: "8.3"
symfony: "^6.4"
sylius: "~1.13.0"
sylius: "1.14.x-dev"
node: "20.x"
mysql: "8.0"
wkhtmltopdf: "0.12.6-1"
mysql: "8.4"
wkhtmltopdf: false
state_machine_adapter: "symfony_workflow"

-
php: "8.2"
php: "8.3"
symfony: "^6.4"
sylius: "~1.12.0"
sylius: "1.14.x-dev"
node: "20.x"
mysql: "8.0"
wkhtmltopdf: false
mysql: "8.4"
wkhtmltopdf: "0.12.6-1"
state_machine_adapter: "winzou_state_machine"
-
php: "8.2"
symfony: "^6.4"
sylius: "~1.13.0"
node: "20.x"
mysql: "8.0"
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 @@ -185,14 +174,23 @@ jobs:
name: Load fixtures in test application
run: (cd tests/Application && bin/console sylius:fixtures:load -n)

-
name: Validate composer.json
run: composer validate --ansi --strict --no-check-all
# Restore before InvoicingPlugin 1.0 release
# run: composer validate --ansi --strict --no-check-publish

-
name: Run ECS
run: vendor/bin/ecs check src/ spec/

-
name: Run security check
run: symfony security:check

-
name: Run analysis
run: composer analyse
if: matrix.sylius != '~1.12.0'
name: Run PHPStan
run: vendor/bin/phpstan analyse -c phpstan.neon -l max src/

-
name: Run PHPSpec
Expand Down
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### UPGRADE FROM 0.25.X TO 1.0.0

1. Support for Sylius 1.14 has been added, it is now the recommended Sylius version to use with InvoicingPlugin.
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 [Sylius 1.14](https://github.com/Sylius/Sylius/blob/1.14/UPGRADE-1.14.md).

### UPGRADE FROM 0.24.X TO 0.25.0

1. Support for Sylius 1.13 has been added, it is now the recommended Sylius version to use with InvoicingPlugin.
Expand Down
29 changes: 13 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"require": {
"php": "^8.1",
"knplabs/knp-snappy-bundle": "^1.8",
"ramsey/uuid": "^3.9 || ^4.0",
"ramsey/uuid": "^4.0",
"sylius/grid-bundle": "^1.9",
"sylius/resource-bundle": "^1.9",
"sylius/sylius": "~1.12.0 || ~1.13.0",
"symfony/config": "^5.4 || ^6.4",
"sylius/sylius": "~1.13.0 || ~1.14.x-dev",
"symfony/config": "^5.4.21 || ^6.4",
"symfony/dependency-injection": "^5.4.21 || ^6.4",
"symfony/form": "^5.4.21 || ^6.4",
"symfony/framework-bundle": "^5.4.21 || ^6.4",
Expand Down Expand Up @@ -43,13 +43,13 @@
"phpstan/phpstan-webmozart-assert": "^1.2",
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sylius-labs/coding-standard": "~4.0.0",
"sylius-labs/coding-standard": "^4.4",
"symfony/browser-kit": "^5.4.21 || ^6.4",
"symfony/debug-bundle": "^5.4.21 || ^6.4",
"symfony/dotenv": "^5.4.21 || ^6.4",
"symfony/intl": "^5.4 || ^6.0",
"symfony/webpack-encore-bundle": "^1.15",
"symfony/web-profiler-bundle": "^5.4.21 || ^6.4"
"symfony/intl": "^5.4.21 || ^6.0",
"symfony/web-profiler-bundle": "^5.4.21 || ^6.4",
"symfony/webpack-encore-bundle": "^1.15"
},
"autoload": {
"psr-4": {
Expand All @@ -64,24 +64,21 @@
}
},
"scripts": {
"analyse": [
"@composer validate --strict",
"vendor/bin/phpstan analyse -c phpstan.neon -l max",
"vendor/bin/ecs check src/ spec/"
GSadee marked this conversation as resolved.
Show resolved Hide resolved
],
"fix": [
"vendor/bin/ecs check --fix src/ spec/"
]
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
}
},
"conflict": {
"behat/mink-selenium2-driver": ">=1.7.0"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"symfony/flex": true,
"dealerdirect/phpcodesniffer-composer-installer": false,
"php-http/discovery": true,
"phpstan/extension-installer": true,
"symfony/flex": true,
"symfony/thanks": false
}
},
Expand Down
57 changes: 41 additions & 16 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,52 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

use PhpCsFixer\Fixer\ClassNotation\OrderedTypesFixer;
use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use PhpCsFixer\Fixer\FunctionNotation\NullableTypeDeclarationForDefaultNullValueFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer;
use SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ContainerConfigurator $containerConfigurator): void
{
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
return static function (ECSConfig $config): void {
$config->import('vendor/sylius-labs/coding-standard/ecs.php');

$containerConfigurator->services()->set(HeaderCommentFixer::class)->call('configure', [[
'location' => 'after_open',
'header' =>
'This file is part of the Sylius package.
$config->parallel();
$config->paths(['src', 'spec']);
$config->skip([
InlineDocCommentDeclarationSniff::class . '.MissingVariable',
InlineDocCommentDeclarationSniff::class . '.NoAssignment',
VisibilityRequiredFixer::class => ['*Spec.php'],
'**/var/*',
'src/Migrations/*',
]);
$config->ruleWithConfiguration(PhpdocSeparationFixer::class, ['groups' => [['Given', 'When', 'Then']]]);
$config->ruleWithConfiguration(OrderedTypesFixer::class, ['null_adjustment' => 'always_last']);
$config->ruleWithConfiguration(NullableTypeDeclarationForDefaultNullValueFixer::class, ['use_nullable_type_declaration' => true]);
$config->ruleWithConfiguration(
HeaderCommentFixer::class,
[
'location' => 'after_open',
'comment_type' => HeaderCommentFixer::HEADER_COMMENT,
'header' => <<<TEXT
This file is part of the Sylius package.

(c) Sylius Sp. z o.o.

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.',
]]);

$containerConfigurator->parameters()->set(Option::SKIP, [
VisibilityRequiredFixer::class => ['*Spec.php'],
'**/var/*',
]);
file that was distributed with this source code.
TEXT
]
);
};
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
parameters:
level: max
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
reportUnmatchedIgnoredErrors: false

paths:
Expand All @@ -16,6 +14,8 @@ parameters:
- 'tests/Application/src/**.php'

ignoreErrors:
- identifier: missingType.generics
- identifier: missingType.iterableValue
- '/Method Sylius\\InvoicingPlugin\\Entity\\\w+::id\(\) has no return type specified\./'
- '/Method Sylius\\InvoicingPlugin\\Entity\\\w+::getId\(\) has no return type specified\./'
- '/Method Sylius\\InvoicingPlugin\\[a-zA-Z\\]+::getFlashBag\(\) should return Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface but returns Symfony\\Component\\HttpFoundation\\Session\\SessionBagInterface\./'
Expand Down
6 changes: 3 additions & 3 deletions spec/CommandHandler/SendInvoiceEmailHandlerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class SendInvoiceEmailHandlerSpec extends ObjectBehavior
function let(
InvoiceRepositoryInterface $invoiceRepository,
OrderRepositoryInterface $orderRepository,
InvoiceEmailSenderInterface $emailSender
InvoiceEmailSenderInterface $emailSender,
): void {
$this->beConstructedWith($invoiceRepository, $orderRepository, $emailSender);
}
Expand All @@ -38,7 +38,7 @@ function it_requests_an_email_with_an_invoice_to_be_sent(
InvoiceEmailSenderInterface $emailSender,
InvoiceInterface $invoice,
OrderInterface $order,
CustomerInterface $customer
CustomerInterface $customer,
): void {
$orderRepository->findOneByNumber('0000001')->willReturn($order);

Expand All @@ -58,7 +58,7 @@ function it_does_not_request_an_email_to_be_sent_if_invoice_was_not_found(
OrderRepositoryInterface $orderRepository,
InvoiceEmailSenderInterface $emailSender,
OrderInterface $order,
CustomerInterface $customer
CustomerInterface $customer,
): void {
$orderRepository->findOneByNumber('0000001')->willReturn($order);
$invoiceRepository->findOneByOrder($order)->willReturn(null);
Expand Down
6 changes: 3 additions & 3 deletions spec/Converter/OrderItemUnitsToLineItemsConverterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class OrderItemUnitsToLineItemsConverterSpec extends ObjectBehavior
function let(
TaxRatePercentageProviderInterface $taxRatePercentageProvider,
LineItemFactoryInterface $lineItemFactory,
UnitNetPriceProviderInterface $unitNetPriceProvider
UnitNetPriceProviderInterface $unitNetPriceProvider,
): void {
$this->beConstructedWith($taxRatePercentageProvider, $lineItemFactory, $unitNetPriceProvider);
}
Expand All @@ -48,7 +48,7 @@ function it_extracts_line_items_from_order_item_units(
OrderInterface $order,
OrderItemInterface $orderItem,
OrderItemUnitInterface $orderItemUnit,
ProductVariantInterface $variant
ProductVariantInterface $variant,
): void {
$lineItemFactory->createWithData('Mjolnir', 1, 6000, 5000, 5000, 500, 5500, null, 'CODE', '10%')->willReturn($lineItem);

Expand Down Expand Up @@ -83,7 +83,7 @@ function it_groups_the_same_line_items_during_extracting_order_item_units(
OrderItemUnitInterface $secondOrderItemUnit,
OrderItemUnitInterface $thirdOrderItemUnit,
ProductVariantInterface $firstVariant,
ProductVariantInterface $secondVariant
ProductVariantInterface $secondVariant,
): void {
$lineItemFactory->createWithData('Mjolnir', 1, 5000, 5000, 5000, 500, 5500, null, 'MJOLNIR', '10%')->willReturn($mjolnirLineItem);
$lineItemFactory->createWithData('Stormbreaker', 1, 8000, 8000, 8000, 1600, 9600, null, 'STORMBREAKER', '20%')->willReturn($stormbreakerLineItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function it_extracts_line_items_from_orders_shipping_adjustments(
OrderInterface $order,
AdjustmentInterface $shippingAdjustment,
AdjustmentInterface $shippingTaxAdjustment,
ShipmentInterface $shipment
ShipmentInterface $shipment,
): void {
$lineItemFactory->createWithData('UPS', 1, 800, 1000, 1000, 200, 1200, null, null, '20%')->willReturn($lineItem);

Expand Down
2 changes: 1 addition & 1 deletion spec/Converter/TaxItemsConverterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function it_extracts_tax_items_from_order(
TaxItemInterface $taxItem,
TaxRatePercentageProviderInterface $taxRatePercentageProvider,
OrderInterface $order,
AdjustmentInterface $taxAdjustment
AdjustmentInterface $taxAdjustment,
): void {
$taxItemFactory->createWithData('10%', 500)->willReturn($taxItem);

Expand Down
14 changes: 7 additions & 7 deletions spec/Creator/InvoiceCreatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ function let(
OrderRepositoryInterface $orderRepository,
InvoiceGeneratorInterface $invoiceGenerator,
InvoicePdfFileGeneratorInterface $invoicePdfFileGenerator,
InvoiceFileManagerInterface $invoiceFileManager
InvoiceFileManagerInterface $invoiceFileManager,
): void {
$this->beConstructedWith(
$invoiceRepository,
$orderRepository,
$invoiceGenerator,
$invoicePdfFileGenerator,
$invoiceFileManager
$invoiceFileManager,
);
}

Expand All @@ -57,7 +57,7 @@ function it_creates_invoice_for_order(
InvoicePdfFileGeneratorInterface $invoicePdfFileGenerator,
InvoiceFileManagerInterface $invoiceFileManager,
OrderInterface $order,
InvoiceInterface $invoice
InvoiceInterface $invoice,
): void {
$invoicePdf = new InvoicePdf('invoice.pdf', 'CONTENT');

Expand All @@ -83,15 +83,15 @@ function it_creates_invoice_without_generating_pdf_file(
InvoicePdfFileGeneratorInterface $invoicePdfFileGenerator,
InvoiceFileManagerInterface $invoiceFileManager,
OrderInterface $order,
InvoiceInterface $invoice
InvoiceInterface $invoice,
): void {
$this->beConstructedWith(
$invoiceRepository,
$orderRepository,
$invoiceGenerator,
$invoicePdfFileGenerator,
$invoiceFileManager,
false
false,
);

$orderRepository->findOneByNumber('0000001')->willReturn($order);
Expand All @@ -117,7 +117,7 @@ function it_removes_saved_invoice_file_if_database_update_fails(
InvoicePdfFileGeneratorInterface $invoicePdfFileGenerator,
InvoiceFileManagerInterface $invoiceFileManager,
OrderInterface $order,
InvoiceInterface $invoice
InvoiceInterface $invoice,
): void {
$invoicePdf = new InvoicePdf('invoice.pdf', 'CONTENT');

Expand All @@ -142,7 +142,7 @@ function it_throws_an_exception_when_invoice_was_already_created_for_given_order
OrderRepositoryInterface $orderRepository,
InvoiceGeneratorInterface $invoiceGenerator,
OrderInterface $order,
InvoiceInterface $invoice
InvoiceInterface $invoice,
): void {
$orderRepository->findOneByNumber('0000001')->willReturn($order);
$invoiceRepository->findOneByOrder($order)->willReturn($invoice);
Expand Down
4 changes: 2 additions & 2 deletions spec/Creator/MassInvoicesCreatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class MassInvoicesCreatorSpec extends ObjectBehavior
{
function let(
InvoiceCreatorInterface $invoiceCreator,
DateTimeProvider $dateTimeProvider
DateTimeProvider $dateTimeProvider,
): void {
$this->beConstructedWith($invoiceCreator, $dateTimeProvider);
}
Expand All @@ -32,7 +32,7 @@ function it_requests_invoices_creation_for_multiple_orders(
DateTimeProvider $dateTimeProvider,
OrderInterface $firstOrder,
OrderInterface $secondOrder,
OrderInterface $thirdOrder
OrderInterface $thirdOrder,
): void {
$firstOrder->getNumber()->willReturn('0000001');
$secondOrder->getNumber()->willReturn('0000002');
Expand Down
Loading