Skip to content

Commit

Permalink
refactor Sylius#13908 [DX] General refactor using ECS (coldic3)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.10 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.10
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | Sylius#13819
| License         | MIT

Commits
-------

26139f2 [DX] General refactor
  • Loading branch information
lchrusciel authored Apr 29, 2022
2 parents ea775bf + 26139f2 commit d2fd6d4
Show file tree
Hide file tree
Showing 276 changed files with 844 additions and 1,225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,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 @@ -127,10 +127,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 @@ -145,8 +145,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 @@ -405,8 +405,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 @@ -384,9 +384,9 @@ public function iShouldBeNotifiedThatTheProvinceNeedsToBeSpecified(): void
{
Assert::true(
$this->responseChecker->hasViolationWithMessage(
$this->addressClient->getLastResponse(),
'Please select proper province.'
)
$this->addressClient->getLastResponse(),
'Please select proper province.'
)
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Sylius/Behat/Context/Api/Shop/ChannelContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public function iShouldShopUsingTheCurrency(string $currencyCode): void
{
Assert::same(
$this->responseChecker->getValue(
$this->client->getLastResponse(),
'baseCurrency'
)['code'],
$this->client->getLastResponse(),
'baseCurrency'
)['code'],
$currencyCode
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Api/Shop/LoginContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

namespace Sylius\Behat\Context\Api\Shop;

use Sylius\Behat\Client\RequestInterface;
use ApiPlatform\Core\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ApiSecurityClientInterface;
use Sylius\Behat\Client\Request;
use Sylius\Behat\Client\RequestInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\CustomerInterface;
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 @@ -218,7 +218,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 @@ -65,7 +65,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 @@ -71,7 +71,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 => 0 === strpos($serviceId, 'sylius.'));
$services = array_filter($services, fn (string $serviceId): bool => 0 === strpos($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 @@ -28,7 +28,7 @@ public function __construct(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 @@ -19,19 +19,19 @@
/** @experimental */
class ChangePaymentMethod implements OrderTokenValueAwareInterface, SubresourceIdAwareInterface
{
/**
* @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 d2fd6d4

Please sign in to comment.