Skip to content

Commit

Permalink
Merge branch '1.11'
Browse files Browse the repository at this point in the history
* 1.11:
  [Maintenance][CI] Add "Refactor" workflow
  [DX] General refactor
  • Loading branch information
lchrusciel committed May 4, 2022
2 parents f348326 + bcf70f4 commit f4f80e1
Show file tree
Hide file tree
Showing 239 changed files with 679 additions and 1,170 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/refactor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Refactor

on:
schedule:
-
cron: "0 2 * * MON" # Run at 2am every Monday
workflow_dispatch: ~

jobs:
coding-standard:
runs-on: ubuntu-latest

name: "Coding standard refactor"

timeout-minutes: 5

strategy:
fail-fast: false
matrix:
branch: ["1.10", "1.11", "master"]

steps:
-
uses: actions/checkout@v3
with:
ref: ${{ matrix.branch }}

-
name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0 # the lowest PHP version working with ECS

-
name: Install PHP dependencies
run: composer update --no-interaction --no-scripts

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

-
name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
commit-message: '[CS][DX] Refactor'
author: Sylius Bot <[email protected]>
title: '[CS][DX] Refactor'
body: |
This PR has been generated automatically.
For more details see [refactor.yml](/Sylius/Sylius/blob/master/.github/workflows/refactor.yml).
labels: |
DX
Enhancement
branch: coding-standard/refactor-${{ matrix.branch }}
delete-branch: true
base: ${{ matrix.branch }}
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ public function iShouldBeNotifiedThatItHasBeenSuccessfullyDeleted(): void
{
Assert::true(
$this->responseChecker->isDeletionSuccessful(
$this->client->getLastResponse()
),
$this->client->getLastResponse()
),
'Customer group could not be deleted'
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Sylius/Behat/Context/Api/Admin/ManagingOrdersContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ public function iShouldSeeASingleOrderFromCustomer(CustomerInterface $customer):
{
Assert::true(
$this->responseChecker->hasItemWithValue(
$this->client->getLastResponse(),
'customer',
$this->iriConverter->getIriFromItem($customer)
),
$this->client->getLastResponse(),
'customer',
$this->iriConverter->getIriFromItem($customer)
),
sprintf('There is no order for customer %s', $customer->getEmail())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public function iShouldBeNotifiedThatItHasBeenSuccessfullyDeleted(): void
{
Assert::true(
$this->responseChecker->isDeletionSuccessful(
$this->client->getLastResponse()
),
$this->client->getLastResponse()
),
'Product association type could not be deleted'
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Context/Api/Admin/ManagingZonesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ public function iShouldBeNotifiedThatItHasBeenSuccessfullyDeleted(): void
{
Assert::true(
$this->responseChecker->isDeletionSuccessful(
$this->client->getLastResponse()
),
$this->client->getLastResponse()
),
'Zone could not be deleted'
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Sylius/Behat/Context/Api/Shop/AddressContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ public function iShouldBeNotifiedThatTheProvinceNeedsToBeSpecified(): void
{
Assert::true(
$this->responseChecker->hasViolationWithMessage(
$this->client->getLastResponse(),
'Please select proper province.'
)
$this->client->getLastResponse(),
'Please select proper province.'
)
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Sylius/Behat/Context/Cli/CancelUnpaidOrdersContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

namespace Sylius\Behat\Context\Cli;

use Behat\Behat\Context\Context;
use Sylius\Component\Core\OrderPaymentStates;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Webmozart\Assert\Assert;
use Behat\Behat\Context\Context;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Webmozart\Assert\Assert;

final class CancelUnpaidOrdersContext implements Context
{
Expand Down Expand Up @@ -64,6 +64,6 @@ public function onlyOrderWithNumberShouldBeCanceled(string $orderNumber): void
*/
public function shouldBeInformedThatUnpaidOrdersHaveBeenCanceled(): void
{
Assert::contains($this->commandTester->getDisplay(), "Unpaid orders have been canceled");
Assert::contains($this->commandTester->getDisplay(), 'Unpaid orders have been canceled');
}
}
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Cli/InstallerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

namespace Sylius\Behat\Context\Cli;

use Symfony\Component\Console\Command\Command;
use Behat\Behat\Context\Context;
use Sylius\Bundle\CoreBundle\Command\InstallSampleDataCommand;
use Sylius\Bundle\CoreBundle\Command\SetupCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\KernelInterface;
use Webmozart\Assert\Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

namespace Sylius\Behat\Context\Cli;

use Symfony\Component\Console\Command\Command;
use Behat\Behat\Context\Context;
use Sylius\Bundle\CoreBundle\Command\SetupCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\KernelInterface;
use Webmozart\Assert\Assert;
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Context/Setup/ProductAttributeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

namespace Sylius\Behat\Context\Setup;

use Faker\Generator;
use Faker\Factory;
use Behat\Behat\Context\Context;
use Doctrine\Persistence\ObjectManager;
use Faker\Factory;
use Faker\Generator;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Attribute\AttributeType\SelectAttributeType;
use Sylius\Component\Attribute\Factory\AttributeFactoryInterface;
Expand Down
10 changes: 5 additions & 5 deletions src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ public function itShouldBeShippedTo(
* @Then the order should be billed to :customerName, :street, :postcode, :city, :countryName
*/
public function itShouldBeBilledToCustomerAtAddress(
string $customerName,
string $street,
string $postcode,
string $city,
string $countryName
string $customerName,
string $street,
string $postcode,
string $city,
string $countryName
) {
$this->itShouldBeBilledTo(null, $customerName, $street, $postcode, $city, $countryName);
}
Expand Down
1 change: 0 additions & 1 deletion src/Sylius/Behat/Context/Ui/Shop/LoginContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace Sylius\Behat\Context\Ui\Shop;

use Behat\Behat\Context\Context;
use FriendsOfBehat\PageObjectExtension\Page\UnexpectedPageException;
use Sylius\Behat\Element\Shop\Account\RegisterElementInterface;
use Sylius\Behat\NotificationType;
use Sylius\Behat\Page\Shop\Account\LoginPageInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Ui/Shop/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function iCheckListOfProductsForTaxon(TaxonInterface $taxon): void
*/
public function iTryToBrowseProductsFromTaxonWithATrailingSlashInThePath(TaxonInterface $taxon): void
{
$this->indexPage->tryToOpen(['slug' => $taxon->getSlug().'/']);
$this->indexPage->tryToOpen(['slug' => $taxon->getSlug() . '/']);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Sylius/Behat/Element/Product/ShowPage/VariantsElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ private function hasProductWithGivenNameCodePriceAndCurrentStock(
$variantContent = $variant->getParent()->find(
'css',
sprintf(
'.variants-accordion__content.%s',
explode(' ', $variant->getAttribute('class'))[1]
)
'.variants-accordion__content.%s',
explode(' ', $variant->getAttribute('class'))[1]
)
);

if (
Expand Down
1 change: 1 addition & 0 deletions src/Sylius/Behat/Page/ErrorPageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Sylius\Behat\Page;

use Behat\Mink\Exception\ElementNotFoundException;

interface ErrorPageInterface
{
public function getCode(): int;
Expand Down
1 change: 1 addition & 0 deletions src/Sylius/Behat/Page/Shop/Cart/SummaryPageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface SummaryPageInterface extends PageInterface
public function getGrandTotal(): string;

public function getBaseGrandTotal(): string;

public function getIncludedTaxTotal(): string;

public function getExcludedTaxTotal(): string;
Expand Down
1 change: 1 addition & 0 deletions src/Sylius/Behat/Service/SessionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private function saveAndRestartSession(string $newSessionName): void
$previousSessionName = $this->mink->getDefaultSessionName();

$this->sharedStorage->set('behat_previous_session_name', $previousSessionName);

try {
$token = $this->securityService->getCurrentToken();
$this->sharedStorage->set($this->getKeyForToken($previousSessionName), $token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function configureOptions(OptionsResolver $resolver): void
$countries = array_filter($countries, $options['choice_filter']);
}

usort($countries, static fn(CountryInterface $firstCountry, CountryInterface $secondCountry): int => $firstCountry->getName() <=> $secondCountry->getName());
usort($countries, static fn (CountryInterface $firstCountry, CountryInterface $secondCountry): int => $firstCountry->getName() <=> $secondCountry->getName());

return $countries;
})
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Bundle/AddressingBundle/Form/Type/ZoneType.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
];

if ($zone->getType() === ZoneInterface::TYPE_ZONE) {
$entryOptions['entry_options']['choice_filter'] = static fn(?ZoneInterface $subZone): bool => $subZone !== null && $zone->getId() !== $subZone->getId();
$entryOptions['entry_options']['choice_filter'] = static fn (?ZoneInterface $subZone): bool => $subZone !== null && $zone->getId() !== $subZone->getId();
}

$event->getForm()->add('members', CollectionType::class, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Sylius\Bundle\AddressingBundle\Tests\Form\Type;

use Prophecy\Prophecy\ObjectProphecy;
use PHPUnit\Framework\Assert;
use Prophecy\Prophecy\ObjectProphecy;
use Prophecy\Prophecy\ProphecyInterface;
use Sylius\Bundle\AddressingBundle\Form\Type\CountryChoiceType;
use Sylius\Component\Addressing\Model\CountryInterface;
Expand Down Expand Up @@ -110,14 +110,14 @@ public function it_returns_filtered_out_countries(): void
$this->poland->reveal(),
]);

$this->assertChoicesLabels(['Poland'], ['choice_filter' => static fn(?CountryInterface $country): bool => $country !== null && $country->getName() === 'Poland']);
$this->assertChoicesLabels(['Poland'], ['choice_filter' => static fn (?CountryInterface $country): bool => $country !== null && $country->getName() === 'Poland']);
}

private function assertChoicesLabels(array $expectedLabels, array $formConfiguration = []): void
{
$form = $this->factory->create(CountryChoiceType::class, null, $formConfiguration);
$view = $form->createView();

Assert::assertSame($expectedLabels, array_map(static fn(ChoiceView $choiceView): string => $choiceView->label, $view->vars['choices']));
Assert::assertSame($expectedLabels, array_map(static fn (ChoiceView $choiceView): string => $choiceView->label, $view->vars['choices']));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Sylius\Bundle\AddressingBundle\Tests\Form\Type;

use Prophecy\Prophecy\ObjectProphecy;
use PHPUnit\Framework\Assert;
use Prophecy\Prophecy\ObjectProphecy;
use Prophecy\Prophecy\ProphecyInterface;
use Sylius\Bundle\AddressingBundle\Form\Type\ZoneChoiceType;
use Sylius\Component\Addressing\Model\Scope as AddressingScope;
Expand Down Expand Up @@ -136,6 +136,6 @@ private function assertChoicesLabels(array $expectedLabels, array $formConfigura
$form = $this->factory->create(ZoneChoiceType::class, null, $formConfiguration);
$view = $form->createView();

Assert::assertSame($expectedLabels, array_map(fn(ChoiceView $choiceView): string => $choiceView->label, $view->vars['choices']));
Assert::assertSame($expectedLabels, array_map(fn (ChoiceView $choiceView): string => $choiceView->label, $view->vars['choices']));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Sylius\Bundle\AddressingBundle\Validator\Constraints\ProvinceAddressConstraintValidator;
use Sylius\Component\Addressing\Model\AddressInterface;
use Sylius\Component\Addressing\Model\Country;
use Sylius\Component\Addressing\Model\CountryInterface;
use Sylius\Component\Addressing\Model\Province;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Component\Validator\Constraint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function its_services_are_initializable(): void

$services = $container->getServiceIds();

$services = array_filter($services, fn(string $serviceId): bool => str_starts_with($serviceId, 'sylius.'));
$services = array_filter($services, fn (string $serviceId): bool => str_starts_with($serviceId, 'sylius.'));

foreach ($services as $id) {
Assert::assertNotNull($container->get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Psr7\Uri;
use Http\Message\MessageFactory;
use Psr\Http\Message\UriInterface;
use Sylius\Bundle\CoreBundle\Application\Kernel;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

namespace Sylius\Bundle\AdminBundle\Tests\Controller;

use Prophecy\Prophecy\ObjectProphecy;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use Http\Message\MessageFactory;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\Prophecy\ObjectProphecy;
use Prophecy\Prophecy\ProphecyInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private function getAmount(OrderItemInterface $orderItem, bool $neutral): int
{
$total = array_reduce(
$orderItem->getAdjustmentsRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->toArray(),
static fn(int $total, BaseAdjustmentInterface $adjustment) => $neutral === $adjustment->isNeutral() ? $total + $adjustment->getAmount() : $total,
static fn (int $total, BaseAdjustmentInterface $adjustment) => $neutral === $adjustment->isNeutral() ? $total + $adjustment->getAmount() : $total,
0
);

Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Bundle/AdminBundle/Twig/ShopExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(private bool $isShopEnabled)
public function getFunctions(): array
{
return [
new TwigFunction('is_shop_enabled', fn(): bool => $this->isShopEnabled),
new TwigFunction('is_shop_enabled', fn (): bool => $this->isShopEnabled),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
/** @experimental */
class ChangePaymentMethod implements OrderTokenValueAwareInterface, SubresourceIdAwareInterface, IriToIdentifierConversionAwareInterface
{
/**
* @var string|null
*/
/** @var string|null */
public $orderTokenValue;

/**
* @psalm-immutable
*
* @var string|null
*/
public $paymentId;

/**
* @psalm-immutable
*
* @var string
*/
public $paymentMethodCode;
Expand Down
Loading

0 comments on commit f4f80e1

Please sign in to comment.