[CS][DX] Refactor

This commit is contained in:
Sylius Bot 2022-05-09 02:42:53 +00:00 committed by GitHub
parent d0184f8819
commit 6ab6ef9f1d
103 changed files with 348 additions and 183 deletions

View file

@ -23,13 +23,13 @@ use Sylius\Bundle\CoreBundle\CatalogPromotion\Calculator\PercentageDiscountPrice
use Sylius\Bundle\CoreBundle\CatalogPromotion\Checker\InForProductScopeVariantChecker;
use Sylius\Bundle\CoreBundle\CatalogPromotion\Checker\InForTaxonsScopeVariantChecker;
use Sylius\Bundle\CoreBundle\CatalogPromotion\Checker\InForVariantsScopeVariantChecker;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\CatalogPromotionInterface;
use Sylius\Component\Promotion\Event\CatalogPromotionCreated;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Promotion\Event\CatalogPromotionCreated;
use Symfony\Component\Messenger\MessageBusInterface;
use Webmozart\Assert\Assert;
@ -214,7 +214,7 @@ final class ManagingCatalogPromotionsContext implements Context
$actions = [[
'type' => PercentageDiscountPriceCalculator::TYPE,
'configuration' => [
'amount' => $amount
'amount' => $amount,
],
]];
@ -230,7 +230,7 @@ final class ManagingCatalogPromotionsContext implements Context
'type' => FixedDiscountPriceCalculator::TYPE,
'configuration' => [
$channel->getCode() => [
'amount' => $amount
'amount' => $amount,
],
],
]];
@ -248,7 +248,7 @@ final class ManagingCatalogPromotionsContext implements Context
$additionalAction = [[
'type' => PercentageDiscountPriceCalculator::TYPE,
'configuration' => [
'amount' => $amount
'amount' => $amount,
],
]];
@ -304,7 +304,7 @@ final class ManagingCatalogPromotionsContext implements Context
$actions = [[
'type' => PercentageDiscountPriceCalculator::TYPE,
'configuration' => [
'amount' => 'text'
'amount' => 'text',
],
]];
@ -326,7 +326,7 @@ final class ManagingCatalogPromotionsContext implements Context
{
$this->client->updateRequestData([
'startDate' => (new \DateTime('yesterday'))->format('Y-m-d H:i:s'),
'endDate' => (new \DateTime('tomorrow'))->format('Y-m-d H:i:s')
'endDate' => (new \DateTime('tomorrow'))->format('Y-m-d H:i:s'),
]);
}
@ -366,7 +366,7 @@ final class ManagingCatalogPromotionsContext implements Context
'variants' => [
$firstVariant->getCode(),
$secondVariant->getCode(),
]
],
],
]];
@ -397,7 +397,7 @@ final class ManagingCatalogPromotionsContext implements Context
'taxons' => [
'BAD_TAXON',
'EVEN_WORSE_TAXON',
]
],
],
]];
@ -428,7 +428,7 @@ final class ManagingCatalogPromotionsContext implements Context
'products' => [
'BAD_PRODUCT',
'EVEN_WORSE_PRODUCT',
]
],
],
]];
@ -443,7 +443,7 @@ final class ManagingCatalogPromotionsContext implements Context
$scopes = [[
'type' => InForTaxonsScopeVariantChecker::TYPE,
'configuration' => [
'taxons' => [$taxon->getCode()]
'taxons' => [$taxon->getCode()],
],
]];
@ -458,7 +458,7 @@ final class ManagingCatalogPromotionsContext implements Context
$scopes = [[
'type' => InForProductScopeVariantChecker::TYPE,
'configuration' => [
'products' => [$product->getCode()]
'products' => [$product->getCode()],
],
]];
@ -514,7 +514,7 @@ final class ManagingCatalogPromotionsContext implements Context
'configuration' => [
'variants' => [
$productVariant->getCode(),
]
],
],
]];
@ -536,7 +536,7 @@ final class ManagingCatalogPromotionsContext implements Context
$content['scopes'][0]['type'] = InForTaxonsScopeVariantChecker::TYPE;
$content['scopes'][0]['configuration']['taxons'] = [$taxon->getCode()];
$this->client->setRequestData($content);;
$this->client->setRequestData($content);
$this->client->update();
}
@ -555,7 +555,7 @@ final class ManagingCatalogPromotionsContext implements Context
$content['scopes'][0]['type'] = InForProductScopeVariantChecker::TYPE;
$content['scopes'][0]['configuration']['products'] = [$product->getCode()];
$this->client->setRequestData($content);;
$this->client->setRequestData($content);
$this->client->update();
}
@ -668,7 +668,7 @@ final class ManagingCatalogPromotionsContext implements Context
$scopes = [[
'type' => 'nonexistent_scope',
'configuration' => [
'config' => 'config'
'config' => 'config',
],
]];
@ -980,7 +980,9 @@ final class ManagingCatalogPromotionsContext implements Context
),
sprintf(
'Cannot find catalog promotions with name "%s" operating between "%s" and "%s" in the list',
$catalogPromotion->getName(), $startDate, $endDate
$catalogPromotion->getName(),
$startDate,
$endDate
)
);
}
@ -1001,7 +1003,8 @@ final class ManagingCatalogPromotionsContext implements Context
),
sprintf(
'Cannot find catalog promotions with name "%s" and priority "%s" in the list',
$catalogPromotion->getName(), $priority
$catalogPromotion->getName(),
$priority
)
);
}
@ -1020,12 +1023,14 @@ final class ManagingCatalogPromotionsContext implements Context
[
'name' => $catalogPromotion->getName(),
'startDate' => (new \DateTime('yesterday'))->format('Y-m-d H:i:s'),
'endDate' => (new \DateTime('tomorrow'))->format('Y-m-d H:i:s')
'endDate' => (new \DateTime('tomorrow'))->format('Y-m-d H:i:s'),
]
),
sprintf(
'Cannot find catalog promotions with name "%s" operating between "%s" and "%s" in the list',
$catalogPromotion->getName(), (new \DateTime('yesterday'))->format('Y-m-d H:i:s'), (new \DateTime('tomorrow'))->format('Y-m-d H:i:s')
$catalogPromotion->getName(),
(new \DateTime('yesterday'))->format('Y-m-d H:i:s'),
(new \DateTime('tomorrow'))->format('Y-m-d H:i:s')
)
);
}
@ -1589,18 +1594,18 @@ final class ManagingCatalogPromotionsContext implements Context
'exclusive' => $exclusive,
'translations' => ['en_US' => [
'locale' => 'en_US',
'label' => $name
'label' => $name,
]],
'actions' => [[
'type' => PercentageDiscountPriceCalculator::TYPE,
'configuration' => [
'amount' => $discount
'amount' => $discount,
],
]],
'scopes' => [[
'type' => InForProductScopeVariantChecker::TYPE,
'configuration' => [
'products' => [$product->getCode()]
'products' => [$product->getCode()],
],
]],
]);

View file

@ -66,8 +66,8 @@ final class ManagingProductVariantsContext implements Context
$this->client->addRequestData('channelPricings', [
$channel->getCode() => [
'price' => $price,
'channelCode' => $channel->getCode()
]
'channelCode' => $channel->getCode(),
],
]);
}
@ -203,8 +203,8 @@ final class ManagingProductVariantsContext implements Context
$this->client->addRequestData('channelPricings', [
$channel->getCode() => [
'price' => $price,
'channelCode' => $channel->getCode()
]
'channelCode' => $channel->getCode(),
],
]);
$this->client->create();

View file

@ -19,7 +19,6 @@ use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\AdminUserInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Product\Model\ProductOption;

View file

@ -830,7 +830,6 @@ final class CartContext implements Context
return;
}
}
throw new \InvalidArgumentException('Invalid item data');

View file

@ -16,8 +16,6 @@ namespace Sylius\Behat\Context\Api\Shop;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Component\Currency\Model\CurrencyInterface;
use Webmozart\Assert\Assert;
final class CurrencyContext implements Context
{

View file

@ -72,7 +72,7 @@ final class HomepageContext implements Context
{
$response = json_decode($this->taxonsClient->getLastResponse()->getContent(), true);
Assert::keyExists($response, 'hydra:member');
$menuItems = array_column($response['hydra:member'], 'name');
$menuItems = array_column($response['hydra:member'], 'name');
Assert::notEmpty($menuItems);
Assert::allOneOf($menuItems, $expectedMenuItems);

View file

@ -38,7 +38,7 @@ final class LocaleContext implements Context
*/
public function iGetAvailableLocales(): void
{
$this->client->index();
$this->client->index();
}
/**

View file

@ -31,7 +31,6 @@ use Webmozart\Assert\Assert;
final class ProductContext implements Context
{
public function __construct(
private ApiClientInterface $client,
private ApiClientInterface $productVariantClient,

View file

@ -17,7 +17,6 @@ use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Webmozart\Assert\Assert;

View file

@ -15,10 +15,8 @@ namespace Sylius\Behat\Context\Api\Shop;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\Request;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Symfony\Component\HttpFoundation\Request as HttpRequest;
use Webmozart\Assert\Assert;
final class PromotionContext implements Context

View file

@ -26,14 +26,14 @@ use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface;
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\CatalogPromotionInterface;
use Sylius\Component\Promotion\Event\CatalogPromotionCreated;
use Sylius\Component\Promotion\Model\CatalogPromotionScopeInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Promotion\Event\CatalogPromotionCreated;
use Sylius\Component\Promotion\Event\CatalogPromotionUpdated;
use Sylius\Component\Promotion\Model\CatalogPromotionActionInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionScopeInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionTransitions;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Symfony\Component\Messenger\MessageBusInterface;
@ -262,7 +262,7 @@ final class CatalogPromotionContext implements Context
]],
[[
'type' => FixedDiscountPriceCalculator::TYPE,
'configuration' => [$channel->getCode() => ['amount' => $discount/100]],
'configuration' => [$channel->getCode() => ['amount' => $discount / 100]],
]]
);
@ -290,7 +290,7 @@ final class CatalogPromotionContext implements Context
]],
[[
'type' => FixedDiscountPriceCalculator::TYPE,
'configuration' => [$channel->getCode() => ['amount' => $discount/100]],
'configuration' => [$channel->getCode() => ['amount' => $discount / 100]],
]]
);
@ -318,7 +318,7 @@ final class CatalogPromotionContext implements Context
]],
[[
'type' => FixedDiscountPriceCalculator::TYPE,
'configuration' => [$channel->getCode() => ['amount' => $discount/100]],
'configuration' => [$channel->getCode() => ['amount' => $discount / 100]],
]]
);
@ -469,7 +469,7 @@ final class CatalogPromotionContext implements Context
null,
[
$firstChannel->getCode(),
$secondChannel->getCode()
$secondChannel->getCode(),
],
[[
'type' => InForVariantsScopeVariantChecker::TYPE,
@ -663,7 +663,7 @@ final class CatalogPromotionContext implements Context
]],
[[
'type' => FixedDiscountPriceCalculator::TYPE,
'configuration' => [$channel->getCode() => ['amount' => $discount/100]],
'configuration' => [$channel->getCode() => ['amount' => $discount / 100]],
]],
$priority
);
@ -693,7 +693,7 @@ final class CatalogPromotionContext implements Context
]],
[[
'type' => FixedDiscountPriceCalculator::TYPE,
'configuration' => [$channel->getCode() => ['amount' => $discount/100]],
'configuration' => [$channel->getCode() => ['amount' => $discount / 100]],
]],
$priority,
);

View file

@ -22,12 +22,12 @@ use Sylius\Behat\Page\Admin\CatalogPromotion\UpdatePageInterface;
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface;
use Sylius\Behat\Service\NotificationCheckerInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\CatalogPromotionInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Webmozart\Assert\Assert;
final class ManagingCatalogPromotionsContext implements Context
@ -233,7 +233,7 @@ final class ManagingCatalogPromotionsContext implements Context
*/
public function iAddScopeThatAppliesOnVariants(ProductVariantInterface ...$variants): void
{
$variantCodes = array_map(function(ProductVariantInterface $variant) {
$variantCodes = array_map(function (ProductVariantInterface $variant) {
return $variant->getCode();
}, $variants);
@ -247,7 +247,7 @@ final class ManagingCatalogPromotionsContext implements Context
*/
public function iAddScopeThatAppliesOnTaxons(TaxonInterface ...$taxons): void
{
$taxonsCodes = array_map(function(TaxonInterface $taxon) {
$taxonsCodes = array_map(function (TaxonInterface $taxon) {
return $taxon->getCode();
}, $taxons);
@ -686,7 +686,9 @@ final class ManagingCatalogPromotionsContext implements Context
$this->indexPage->isSingleResourceOnPage(['name' => $name, 'startDate' => $startDate, 'endDate' => $endDate]),
sprintf(
'Cannot find catalog promotions with name "%s" operating between "%s" and "%s" in the list',
$name, $startDate, $endDate
$name,
$startDate,
$endDate
)
);
}
@ -700,7 +702,8 @@ final class ManagingCatalogPromotionsContext implements Context
$this->indexPage->isSingleResourceOnPage(['name' => $name, 'priority' => $priority]),
sprintf(
'Cannot find catalog promotions with name "%s" and priority %s in the list',
$name, $priority
$name,
$priority
)
);
}
@ -973,7 +976,7 @@ final class ManagingCatalogPromotionsContext implements Context
$this->iBrowseCatalogPromotions();
Assert::true(
$this->indexPage->isSingleResourceOnPage(['code' => $catalogPromotion->getCode(), 'name' => $name,])
$this->indexPage->isSingleResourceOnPage(['code' => $catalogPromotion->getCode(), 'name' => $name])
);
}

View file

@ -17,7 +17,6 @@ use Behat\Behat\Context\Context;
use Sylius\Behat\Page\Admin\ProductVariant\UpdatePageInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Webmozart\Assert\Assert;
final class ManagingProductVariantsPricesContext implements Context
{

View file

@ -597,7 +597,7 @@ final class ProductContext implements Context
): void {
$this->showPage->selectVariant($variant->getName());
Assert::same(sizeof($this->showPage->getCatalogPromotions()), 1);
Assert::same(count($this->showPage->getCatalogPromotions()), 1);
Assert::same($this->showPage->getCatalogPromotionName(), $promotionName);
Assert::same($this->showPage->getPrice(), $price);
Assert::same($this->showPage->getOriginalPrice(), $originalPrice);

View file

@ -25,7 +25,7 @@ final class SprintfResponseEscaper
str_replace(
'%',
'%%',
json_encode(json_decode($response->getContent(), true), JSON_PRETTY_PRINT)
json_encode(json_decode($response->getContent(), true), \JSON_PRETTY_PRINT)
)
);
}

View file

@ -39,7 +39,7 @@ final class CatalogPromotionActionTypeExtension extends AbstractTypeExtension
->add('type', ChoiceType::class, [
'label' => 'sylius.ui.type',
'choices' => $this->actionTypes,
'choice_attr' => function(?string $type) use ($builder): array {
'choice_attr' => function (?string $type) use ($builder): array {
return [
'data-configuration' => $this->twig->render(
'@SyliusAdmin/CatalogPromotion/_action.html.twig',
@ -48,9 +48,9 @@ final class CatalogPromotionActionTypeExtension extends AbstractTypeExtension
$this->actionConfigurationTypes[$type],
['label' => false, 'csrf_protection' => false]
)->getForm()->createView()]
)
),
];
}
},
])
;
}

View file

@ -29,7 +29,7 @@ final class CatalogPromotionScopeTypeExtension extends AbstractTypeExtension
{
foreach ($scopeConfigurationTypes as $type => $formType) {
$this->scopeConfigurationTypes[$type] = $formType::class;
$this->scopeTypes['sylius.form.catalog_promotion.scope.'.$type] = $type;
$this->scopeTypes['sylius.form.catalog_promotion.scope.' . $type] = $type;
}
}
@ -39,15 +39,14 @@ final class CatalogPromotionScopeTypeExtension extends AbstractTypeExtension
->add('type', ChoiceType::class, [
'label' => 'sylius.ui.type',
'choices' => $this->scopeTypes,
'choice_attr' => function(?string $type) use ($builder): array {
'choice_attr' => function (?string $type) use ($builder): array {
return [
'data-configuration' =>
$this->twig->render(
'@SyliusAdmin/CatalogPromotion/Scope/'.$type.'.html.twig',
['field' => $builder->create('configuration', $this->scopeConfigurationTypes[$type])->getForm()->createView()]
)
'data-configuration' => $this->twig->render(
'@SyliusAdmin/CatalogPromotion/Scope/' . $type . '.html.twig',
['field' => $builder->create('configuration', $this->scopeConfigurationTypes[$type])->getForm()->createView()]
),
];
}
},
])
;
}

View file

@ -46,6 +46,7 @@ final class MergingExtractorResourceMetadataFactory implements ResourceMetadataF
public function create(string $resourceClass): ResourceMetadata
{
$parentResourceMetadata = null;
try {
$parentResourceMetadata = $this->decorated->create($resourceClass);
} catch (ResourceClassNotFoundException) {

View file

@ -22,7 +22,7 @@ use Sylius\Bundle\ApiBundle\Command\ShopUserIdAwareInterface;
class ResendVerificationEmail implements ShopUserIdAwareInterface, ChannelCodeAwareInterface, LocaleCodeAwareInterface, IriToIdentifierConversionAwareInterface
{
/** @var string|int|null */
public $shopUserId = null;
public $shopUserId;
/**
* @psalm-immutable

View file

@ -13,8 +13,8 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Command\Cart;
use Sylius\Bundle\ApiBundle\Command\CustomerEmailAwareInterface;
use Sylius\Bundle\ApiBundle\Command\ChannelCodeAwareInterface;
use Sylius\Bundle\ApiBundle\Command\CustomerEmailAwareInterface;
/** @experimental */
class PickupCart implements ChannelCodeAwareInterface, CustomerEmailAwareInterface
@ -33,9 +33,7 @@ class PickupCart implements ChannelCodeAwareInterface, CustomerEmailAwareInterfa
/** @var string|null */
private $channelCode;
/**
* @var string|null
*/
/** @var string|null */
public $email;
public function __construct(?string $tokenValue = null, ?string $localeCode = null)

View file

@ -17,5 +17,6 @@ namespace Sylius\Bundle\ApiBundle\Command;
interface CustomerEmailAwareInterface extends CommandAwareDataTransformerInterface
{
public function getEmail(): ?string;
public function setEmail(?string $email): void;
}

View file

@ -61,7 +61,7 @@ final class FixedDiscountActionValidator implements ActionValidatorInterface
{
return
!isset($channelConfiguration['amount']) ||
!is_integer($channelConfiguration['amount']) ||
!is_int($channelConfiguration['amount']) ||
$channelConfiguration['amount'] < 0
;
}

View file

@ -42,7 +42,7 @@ final class PercentageDiscountActionValidator implements ActionValidatorInterfac
return;
}
if (!is_float($configuration['amount']) && !is_integer($configuration['amount'])) {
if (!is_float($configuration['amount']) && !is_int($configuration['amount'])) {
$context->buildViolation($constraint->notNumberOrEmpty)->atPath('configuration.amount')->addViolation();
return;

View file

@ -90,8 +90,7 @@ final class AcceptLanguageHeaderDocumentationNormalizerSpec extends ObjectBehavi
RepositoryInterface $localeRepository,
LocaleInterface $locale1,
LocaleInterface $locale2
): void
{
): void {
$docs = [
'paths' => [
'/api/v2/admin/addresses/{id}' => [
@ -99,7 +98,7 @@ final class AcceptLanguageHeaderDocumentationNormalizerSpec extends ObjectBehavi
[
'parameters' => [],
],
)
),
],
],
];
@ -130,7 +129,7 @@ final class AcceptLanguageHeaderDocumentationNormalizerSpec extends ObjectBehavi
'description' => 'Locales in this enum are all locales defined in the shop and only enabled ones will work in the given channel in the shop.',
'schema' => [
'type' => 'string',
'enum' => ['en_US', 'de_DE']
'enum' => ['en_US', 'de_DE'],
],
],
],

View file

@ -11,15 +11,6 @@
declare(strict_types=1);
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\ApiBundle\Application\Tests;
use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;

View file

@ -25,16 +25,17 @@ final class ActionBasedDiscountApplicator implements ActionBasedDiscountApplicat
public function __construct(
private CatalogPromotionPriceCalculatorInterface $priceCalculator,
private iterable $discountApplicatorCriteria
) {}
) {
}
public function applyDiscountOnChannelPricing(
CatalogPromotionInterface $catalogPromotion,
CatalogPromotionActionInterface $action,
ChannelPricingInterface $channelPricing
): void {
/** @var DiscountApplicationCriteriaInterface $applicatorCriterion */
/** @var DiscountApplicationCriteriaInterface $applicatorCriterion */
foreach ($this->discountApplicatorCriteria as $applicatorCriterion) {
if (!$applicatorCriterion->isApplicable($catalogPromotion, ['channelPricing' => $channelPricing, 'action'=> $action])) {
if (!$applicatorCriterion->isApplicable($catalogPromotion, ['channelPricing' => $channelPricing, 'action' => $action])) {
return;
}
}

View file

@ -25,7 +25,8 @@ final class CatalogPromotionApplicator implements CatalogPromotionApplicatorInte
private ActionBasedDiscountApplicatorInterface $actionBasedDiscountApplicator,
private ProductVariantForCatalogPromotionEligibilityInterface $checker,
private CatalogPromotionEligibilityCheckerInterface $catalogPromotionEligibilityChecker
) {}
) {
}
public function applyOnVariant(
ProductVariantInterface $variant,

View file

@ -27,7 +27,7 @@ final class PercentageDiscountPriceCalculator implements ActionBasedPriceCalcula
public function calculate(ChannelPricingInterface $channelPricing, CatalogPromotionActionInterface $action): int
{
$price = (int)($channelPricing->getPrice() - ($channelPricing->getPrice() * $action->getConfiguration()['amount']));
$price = (int) ($channelPricing->getPrice() - ($channelPricing->getPrice() * $action->getConfiguration()['amount']));
$minimumPrice = $this->provideMinimumPrice($channelPricing);
if ($price < $minimumPrice) {

View file

@ -30,8 +30,9 @@ final class InForTaxonsScopeVariantChecker implements VariantInScopeCheckerInter
/** @var ProductInterface $product */
$product = $productVariant->getProduct();
return $product->getTaxons()->exists(
fn($key, TaxonInterface $taxon): bool => \in_array($taxon->getCode(), $scope->getConfiguration()['taxons'], true)
fn ($key, TaxonInterface $taxon): bool => \in_array($taxon->getCode(), $scope->getConfiguration()['taxons'], true)
);
}
}

View file

@ -14,8 +14,8 @@ declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\CatalogPromotion\Checker;
use Sylius\Component\Core\Model\CatalogPromotionInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Core\Model\CatalogPromotionScopeInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Symfony\Component\DependencyInjection\ServiceLocator;
final class ProductVariantForCatalogPromotionEligibility implements ProductVariantForCatalogPromotionEligibilityInterface

View file

@ -14,8 +14,8 @@ declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\CatalogPromotion\DiscountApplicationCriteria;
use Sylius\Bundle\PromotionBundle\DiscountApplicationCriteria\DiscountApplicationCriteriaInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionInterface;
use Sylius\Component\Core\Model\ChannelPricingInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionInterface;
use Webmozart\Assert\Assert;
final class MinimumPriceCriteria implements DiscountApplicationCriteriaInterface

View file

@ -15,7 +15,6 @@ namespace Sylius\Bundle\CoreBundle\CatalogPromotion\Listener;
use Sylius\Component\Promotion\Event\CatalogPromotionFailed;
use Sylius\Component\Promotion\Event\CatalogPromotionUpdated;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent;
use Symfony\Component\Messenger\MessageBusInterface;
@ -39,9 +38,9 @@ final class CatalogPromotionUpdateFailedMessageListener
private function isWorkerMessageValid(WorkerMessageFailedEvent $event): bool
{
return (
return
$event->willRetry() === false &&
$event->getEnvelope()->getMessage() instanceof CatalogPromotionUpdated
);
;
}
}

View file

@ -64,6 +64,6 @@ final class FixedDiscountActionValidator implements ActionValidatorInterface
private function isChannelConfigured(string $channelCode, array $configuration): bool
{
return (isset($configuration[$channelCode]) && isset($configuration[$channelCode]['amount']));
return isset($configuration[$channelCode]) && isset($configuration[$channelCode]['amount']);
}
}

View file

@ -60,7 +60,7 @@ final class Configuration implements ConfigurationInterface
->integerNode('batch_size')
->defaultValue(100)
->validate()
->ifTrue(fn(int $batchSize): bool => $batchSize <= 0)
->ifTrue(fn (int $batchSize): bool => $batchSize <= 0)
->thenInvalid('Expected value bigger than 0, but got %s.')
->end()
->end()

View file

@ -37,6 +37,7 @@ final class Day extends FunctionNode
public function getSql(SqlWalker $sqlWalker): string
{
$platformName = $sqlWalker->getConnection()->getDatabasePlatform()->getName();
return match ($platformName) {
'mysql' => sprintf('DAY(%s)', $sqlWalker->walkArithmeticPrimary($this->date)),
'postgresql' => sprintf('EXTRACT(DAY FROM %s)', $sqlWalker->walkArithmeticPrimary($this->date)),

View file

@ -37,6 +37,7 @@ final class Hour extends FunctionNode
public function getSql(SqlWalker $sqlWalker): string
{
$platformName = $sqlWalker->getConnection()->getDatabasePlatform()->getName();
return match ($platformName) {
'mysql' => sprintf('HOUR(%s)', $sqlWalker->walkArithmeticPrimary($this->date)),
'postgresql' => sprintf('EXTRACT(HOUR FROM %s)', $sqlWalker->walkArithmeticPrimary($this->date)),

View file

@ -37,6 +37,7 @@ final class Month extends FunctionNode
public function getSql(SqlWalker $sqlWalker): string
{
$platformName = $sqlWalker->getConnection()->getDatabasePlatform()->getName();
return match ($platformName) {
'mysql' => sprintf('MONTH(%s)', $sqlWalker->walkArithmeticPrimary($this->date)),
'postgresql' => sprintf('EXTRACT(MONTH FROM %s)', $sqlWalker->walkArithmeticPrimary($this->date)),

View file

@ -37,6 +37,7 @@ final class Week extends FunctionNode
public function getSql(SqlWalker $sqlWalker): string
{
$platformName = $sqlWalker->getConnection()->getDatabasePlatform()->getName();
return match ($platformName) {
'mysql' => sprintf('WEEK(%s)', $sqlWalker->walkArithmeticPrimary($this->date)),
'postgresql' => sprintf('EXTRACT(WEEK FROM %s)', $sqlWalker->walkArithmeticPrimary($this->date)),

View file

@ -37,6 +37,7 @@ final class Year extends FunctionNode
public function getSql(SqlWalker $sqlWalker): string
{
$platformName = $sqlWalker->getConnection()->getDatabasePlatform()->getName();
return match ($platformName) {
'mysql' => sprintf('YEAR(%s)', $sqlWalker->walkArithmeticPrimary($this->date)),
'postgresql' => sprintf('EXTRACT(YEAR FROM %s)', $sqlWalker->walkArithmeticPrimary($this->date)),

View file

@ -13,7 +13,6 @@ declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Doctrine\ORM;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Sylius\Bundle\ProductBundle\Doctrine\ORM\ProductVariantRepository as BaseProductVariantRepository;
use Sylius\Component\Core\Model\TaxonInterface;

View file

@ -16,9 +16,7 @@ namespace Sylius\Bundle\CoreBundle\Form\DataTransformer;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Core\Repository\ProductVariantRepositoryInterface;
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
use Symfony\Component\Form\DataTransformerInterface;
use Webmozart\Assert\Assert;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Form\Type\CatalogPromotionAction;

View file

@ -35,7 +35,7 @@ final class ForProductsScopeConfigurationType extends AbstractType
'choice_value' => 'code',
'resource' => 'sylius.product',
'constraints' => [
new NotBlank(['groups' => 'sylius', 'message' => 'sylius.catalog_promotion_scope.for_products.not_empty'])
new NotBlank(['groups' => 'sylius', 'message' => 'sylius.catalog_promotion_scope.for_products.not_empty']),
],
]);

View file

@ -34,7 +34,7 @@ final class ForTaxonsScopeConfigurationType extends AbstractType
'choice_value' => 'code',
'resource' => 'sylius.taxon',
'constraints' => [
new NotBlank(['groups' => 'sylius', 'message' => 'sylius.catalog_promotion_scope.for_taxons.not_empty'])
new NotBlank(['groups' => 'sylius', 'message' => 'sylius.catalog_promotion_scope.for_taxons.not_empty']),
],
]);

View file

@ -18,7 +18,6 @@ use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ChannelPricingInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;

View file

@ -14,9 +14,9 @@ declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Tests\DependencyInjection;
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
use PHPUnit\Framework\TestCase;
use Sylius\Bundle\CoreBundle\DependencyInjection\Configuration;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use PHPUnit\Framework\TestCase;
final class ConfigurationTest extends TestCase
{

View file

@ -50,9 +50,9 @@ final class CatalogPromotionActionTypeTest extends TypeTestCase
'type' => 'fixed_discount',
'configuration' => [
'WEB_US' => [
'amount' => 20
]
]
'amount' => 20,
],
],
]);
$this->assertTrue($form->isSynchronized());
@ -76,8 +76,8 @@ final class CatalogPromotionActionTypeTest extends TypeTestCase
$form->submit([
'type' => 'percentage_discount',
'configuration' => [
'amount' => 10
]
'amount' => 10,
],
]);
$this->assertTrue($form->isSynchronized());
@ -102,9 +102,9 @@ final class CatalogPromotionActionTypeTest extends TypeTestCase
'type' => 'fixed_discount',
'configuration' => [
'WEB_US' => [
'amount' => 10
]
]
'amount' => 10,
],
],
]);
$this->assertTrue($form->isSynchronized());
@ -128,8 +128,8 @@ final class CatalogPromotionActionTypeTest extends TypeTestCase
$form->submit([
'type' => 'percentage_discount',
'configuration' => [
'amount' => 10
]
'amount' => 10,
],
]);
$this->assertTrue($form->isSynchronized());
@ -153,8 +153,8 @@ final class CatalogPromotionActionTypeTest extends TypeTestCase
$form->submit([
'type' => 'percentage_discount',
'configuration' => [
'amount' => ''
]
'amount' => '',
],
]);
$this->assertTrue($form->isSynchronized());
@ -179,9 +179,9 @@ final class CatalogPromotionActionTypeTest extends TypeTestCase
'type' => 'fixed_discount',
'configuration' => [
'WEB_US' => [
'amount' => ''
]
]
'amount' => '',
],
],
]);
$this->assertTrue($form->isSynchronized());
@ -206,9 +206,9 @@ final class CatalogPromotionActionTypeTest extends TypeTestCase
'type' => 'fixed_discount',
'configuration' => [
'WEB_US' => [
'amount' => 'Not valid amount'
]
]
'amount' => 'Not valid amount',
],
],
]);
$this->assertTrue($form->isSynchronized());
@ -233,9 +233,9 @@ final class CatalogPromotionActionTypeTest extends TypeTestCase
'type' => 'fixed_discount',
'configuration' => [
'WEB_US' => [
'amount' => 20.54
]
]
'amount' => 20.54,
],
],
]);
$this->assertTrue($form->isSynchronized());
@ -259,8 +259,8 @@ final class CatalogPromotionActionTypeTest extends TypeTestCase
$form->submit([
'type' => 'percentage_discount',
'configuration' => [
'amount' => 'Not valid amount'
]
'amount' => 'Not valid amount',
],
]);
$this->assertTrue($form->isSynchronized());
@ -294,7 +294,7 @@ final class CatalogPromotionActionTypeTest extends TypeTestCase
['sylius'],
[
'percentage_discount' => new PercentageDiscountActionConfigurationType(),
'fixed_discount' => new ChannelBasedFixedDiscountActionConfigurationType()
'fixed_discount' => new ChannelBasedFixedDiscountActionConfigurationType(),
]
);
@ -306,7 +306,7 @@ final class CatalogPromotionActionTypeTest extends TypeTestCase
return [
new PreloadedExtension([$catalogPromotionActionType, $channelCollectionType], []),
new ValidatorExtension($validator)
new ValidatorExtension($validator),
];
}

View file

@ -21,7 +21,7 @@ use Symfony\Component\Messenger\MessageBusInterface;
final class BatchedApplyCatalogPromotionsOnVariantsCommandDispatcherSpec extends ObjectBehavior
{
public function let(MessageBusInterface $messageBus,): void
public function let(MessageBusInterface $messageBus): void
{
$this->beConstructedWith($messageBus, 2);
}

View file

@ -15,9 +15,9 @@ namespace spec\Sylius\Bundle\CoreBundle\CatalogPromotion\DiscountApplicationCrit
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\PromotionBundle\DiscountApplicationCriteria\DiscountApplicationCriteriaInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionInterface;
use Sylius\Component\Core\Model\ChannelPricingInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionActionInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionInterface;
use Webmozart\Assert\InvalidArgumentException;
final class ExclusiveCriteriaSpec extends ObjectBehavior

View file

@ -15,9 +15,9 @@ namespace spec\Sylius\Bundle\CoreBundle\CatalogPromotion\DiscountApplicationCrit
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\PromotionBundle\DiscountApplicationCriteria\DiscountApplicationCriteriaInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionInterface;
use Sylius\Component\Core\Model\ChannelPricingInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionActionInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionInterface;
use Webmozart\Assert\InvalidArgumentException;
final class MinimumPriceCriteriaSpec extends ObjectBehavior

View file

@ -42,11 +42,11 @@ final class CatalogPromotionUpdateFailedMessageListenerSpec extends ObjectBehavi
);
$messageBus->dispatch(Argument::that(
function($object): bool {
return (
function ($object): bool {
return
$object->code === 'code' &&
$object instanceof CatalogPromotionFailed
);
;
}
))->willReturn(new Envelope($catalogPromotionFailed))->shouldBeCalled();

View file

@ -52,6 +52,6 @@ final class RequestHeaderBasedLocaleContext implements LocaleContextInterface
return $this->requestStack->getMainRequest();
}
return $this->requestStack->getMasterRequest();
return $this->requestStack->getMasterRequest();
}
}

View file

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace Sylius\Bundle\PayumBundle\Form\Extension;
use Payum\Core\Security\CryptedInterface;
use Payum\Core\Security\CypherInterface;
use Sylius\Bundle\PayumBundle\Form\Type\GatewayConfigType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\PromotionBundle\Criteria;

View file

@ -23,7 +23,7 @@ final class Enabled implements CriteriaInterface
$root = $queryBuilder->getRootAliases()[0];
$queryBuilder
->andWhere($root.'.enabled = :enabled')
->andWhere($root . '.enabled = :enabled')
->setParameter('enabled', true)
;

View file

@ -24,13 +24,13 @@ use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
use Sylius\Bundle\ResourceBundle\Form\Type\DefaultResourceType;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Sylius\Component\Promotion\Model\CatalogPromotion;
use Sylius\Component\Promotion\Model\CatalogPromotionAction;
use Sylius\Component\Promotion\Model\CatalogPromotionActionInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionScope;
use Sylius\Component\Promotion\Model\CatalogPromotionScopeInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionTranslation;
use Sylius\Component\Promotion\Model\CatalogPromotionTranslationInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionAction;
use Sylius\Component\Promotion\Model\CatalogPromotionActionInterface;
use Sylius\Component\Promotion\Model\Promotion;
use Sylius\Component\Promotion\Model\PromotionAction;
use Sylius\Component\Promotion\Model\PromotionActionInterface;

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\PromotionBundle\Form\Type\CatalogPromotionAction;

View file

@ -55,10 +55,10 @@ final class CatalogPromotionActionType extends AbstractResourceType
;
$builder
->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event): void {
$this->addConfigurationTypeToForm($event);
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {
$this->addConfigurationTypeToForm($event);
})
->addEventListener(FormEvents::PRE_SUBMIT, function(FormEvent $event): void {
->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event): void {
/** @var array|null $data */
$data = $event->getData();
if ($data === null) {

View file

@ -35,7 +35,7 @@ final class CatalogPromotionScopeType extends AbstractResourceType
foreach ($scopeConfigurationTypes as $type => $formType) {
$this->scopeConfigurationTypes[$type] = $formType::class;
$this->scopeTypes['sylius.form.catalog_promotion.scope.'.$type] = $type;
$this->scopeTypes['sylius.form.catalog_promotion.scope.' . $type] = $type;
}
}
@ -53,10 +53,10 @@ final class CatalogPromotionScopeType extends AbstractResourceType
;
$builder
->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event): void {
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {
$this->addScopeToForm($event);
})
->addEventListener(FormEvents::PRE_SUBMIT, function(FormEvent $event): void {
->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event): void {
$this->addScopeToForm($event);
})
;

View file

@ -90,7 +90,7 @@ final class CatalogPromotionType extends AbstractResourceType
])
;
$builder->addEventListener(FormEvents::PRE_SUBMIT, function(FormEvent $event): void {
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event): void {
$data = $event->getData();
if (isset($data['startDate']) && $data['startDate']['date'] !== '' && $data['startDate']['time'] === '') {

View file

@ -38,7 +38,7 @@ final class PromotionType extends AbstractResourceType
'label' => 'sylius.form.promotion.exclusive',
])
->add('appliesToDiscounted', CheckboxType::class, [
'label' => 'sylius.form.promotion.applies_to_discounted'
'label' => 'sylius.form.promotion.applies_to_discounted',
])
->add('usageLimit', IntegerType::class, [
'label' => 'sylius.form.promotion.usage_limit',

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\PromotionBundle\Provider;

View file

@ -42,6 +42,7 @@ final class SetCatalogPromotionActionTypesPassTest extends AbstractCompilerPassT
['custom', 'another_custom', 'second_custom']
);
}
/** @test */
public function it_throws_an_exception_if_there_is_no_type_attribute_defined(): void
{

View file

@ -42,6 +42,7 @@ final class SetCatalogPromotionScopeTypesPassTest extends AbstractCompilerPassTe
['custom', 'another_custom', 'second_custom']
);
}
/** @test */
public function it_throws_an_exception_if_there_is_no_type_attribute_defined(): void
{

View file

@ -42,7 +42,7 @@ final class CatalogPromotionActionValidator extends ConstraintValidator
}
$type = $value->getType();
if (!key_exists($type, $this->actionValidators)) {
if (!array_key_exists($type, $this->actionValidators)) {
return;
}

View file

@ -42,7 +42,7 @@ final class CatalogPromotionScopeValidator extends ConstraintValidator
}
$type = $value->getType();
if (!key_exists($type, $this->scopeValidators)) {
if (!array_key_exists($type, $this->scopeValidators)) {
return;
}

View file

@ -31,7 +31,7 @@ final class CatalogPromotionScopeValidatorSpec extends ObjectBehavior
$this->beConstructedWith(
[
'for_taxons',
'for_variants'
'for_variants',
],
[
'for_taxons' => $forTaxonsValidator,

View file

@ -18,7 +18,8 @@ use Symfony\Component\HttpFoundation\RequestStack;
final class CLIContextChecker implements CLIContextCheckerInterface
{
public function __construct(private RequestStack $requestStack)
{ }
{
}
public function isExecutedFromCLI(): bool
{

View file

@ -32,7 +32,7 @@ final class ProportionalIntegerDistributor implements ProportionalIntegerDistrib
}
}
if(array_sum($distributedAmounts) === 0) {
if (array_sum($distributedAmounts) === 0) {
return $distributedAmounts;
}

View file

@ -33,9 +33,7 @@ class ChannelPricing implements ChannelPricingInterface, \Stringable
/** @var int|null */
protected $originalPrice;
/**
* @var int
*/
/** @var int */
protected $minimumPrice = 0;
/**
@ -121,7 +119,7 @@ class ChannelPricing implements ChannelPricingInterface, \Stringable
public function addAppliedPromotion(CatalogPromotionInterface $catalogPromotion): void
{
if($this->appliedPromotions->contains($catalogPromotion)) {
if ($this->appliedPromotions->contains($catalogPromotion)) {
return;
}
@ -146,7 +144,7 @@ class ChannelPricing implements ChannelPricingInterface, \Stringable
public function hasExclusiveCatalogPromotionApplied(): bool
{
foreach ($this->appliedPromotions as $appliedPromotion) {
if($appliedPromotion->isExclusive()) {
if ($appliedPromotion->isExclusive()) {
return true;
}
}

View file

@ -13,7 +13,6 @@ declare(strict_types=1);
namespace Sylius\Component\Core\Model;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Sylius\Component\Inventory\Model\StockableInterface;
use Sylius\Component\Product\Model\ProductVariantInterface as BaseVariantInterface;

View file

@ -36,8 +36,10 @@ final class OrderPaymentProvider implements OrderPaymentProviderInterface
public function provideOrderPayment(OrderInterface $order, string $targetState): ?PaymentInterface
{
/** @var PaymentInterface $payment */
$payment = $this->paymentFactory->createWithAmountAndCurrencyCode($order->getTotal(),
$order->getCurrencyCode());
$payment = $this->paymentFactory->createWithAmountAndCurrencyCode(
$order->getTotal(),
$order->getCurrencyCode()
);
$paymentMethod = $this->getDefaultPaymentMethod($payment, $order);
$lastPayment = $this->getLastPayment($order);

View file

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Component\Core\Provider;

View file

@ -16,7 +16,7 @@ namespace Sylius\Component\Core\Resolver;
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Core\Model\OrderInterface;
final class TaxationAddressResolver Implements TaxationAddressResolverInterface
final class TaxationAddressResolver implements TaxationAddressResolverInterface
{
public function __construct(private bool $shippingAddressBasedTaxation)
{

View file

@ -57,7 +57,7 @@ class OrderShipmentTaxesApplicator implements OrderTaxesApplicatorInterface
continue;
}
$this->addAdjustment($shipment, (int)$taxAmount, $taxRate, $shippingMethod);
$this->addAdjustment($shipment, (int) $taxAmount, $taxRate, $shippingMethod);
}
}

View file

@ -30,7 +30,7 @@ final class TranslatableEntityLocaleAssigner implements TranslatableEntityLocale
if ($this->commandBasedChecker === null) {
@trigger_error(
'Not passing CommandBasedContextCheckedInterface explicitly as the third argument is deprecated since 1.11 and will be prohibited in 2.0.',
E_USER_DEPRECATED
\E_USER_DEPRECATED
);
}
}

View file

@ -14,8 +14,8 @@ declare(strict_types=1);
namespace spec\Sylius\Component\Core\Model;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Promotion\Model\CatalogPromotionScopeInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionScope;
use Sylius\Component\Promotion\Model\CatalogPromotionScopeInterface;
final class CatalogPromotionScopeSpec extends ObjectBehavior
{

View file

@ -15,7 +15,6 @@ namespace spec\Sylius\Component\Core\Model;
use Doctrine\Common\Collections\ArrayCollection;
use PhpSpec\ObjectBehavior;
use Stripe\Collection;
use Sylius\Component\Core\Model\CatalogPromotionInterface;
use Sylius\Component\Core\Model\ChannelPricingInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
@ -90,8 +89,7 @@ final class ChannelPricingSpec extends ObjectBehavior
function it_has_information_about_applied_exclusive_catalog_promotion_applied(
CatalogPromotionInterface $catalogPromotion
): void
{
): void {
$catalogPromotion->isExclusive()->willReturn(true);
$this->addAppliedPromotion($catalogPromotion);

View file

@ -16,9 +16,7 @@ namespace spec\Sylius\Component\Core\OrderProcessing;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\AdjustmentInterface;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Provider\ZoneProviderInterface;
use Sylius\Component\Order\Processor\OrderProcessorInterface;
use Sylius\Component\Registry\PrioritizedServiceRegistryInterface;
final class OrderAdjustmentsClearerSpec extends ObjectBehavior
{

View file

@ -40,7 +40,6 @@ final class ShippingChargesProcessorSpec extends ObjectBehavior
{
$order->getState()->willReturn(OrderInterface::STATE_CART);
$order->getShipments()->willReturn(new ArrayCollection([]));
$this->process($order);

View file

@ -141,11 +141,12 @@ final class ProductVariantsPricesProviderSpec extends ObjectBehavior
]));
$blackSmallTShirt->getAppliedPromotionsForChannel($channel)->willReturn(new ArrayCollection([
$winterCatalogPromotion->getWrappedObject()
$winterCatalogPromotion->getWrappedObject(),
]));
$whiteSmallTShirt->getAppliedPromotionsForChannel($channel)->willReturn(new ArrayCollection());
$blackLargeTShirt->getAppliedPromotionsForChannel($channel)->willReturn(new ArrayCollection([
$summerCatalogPromotion->getWrappedObject()]
$blackLargeTShirt->getAppliedPromotionsForChannel($channel)->willReturn(new ArrayCollection(
[
$summerCatalogPromotion->getWrappedObject(), ]
));
$whiteLargeTShirt->getAppliedPromotionsForChannel($channel)->willReturn(new ArrayCollection());

View file

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace spec\Sylius\Component\Core\Translation;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Checker\CLIContextChecker;
use Sylius\Component\Core\Checker\CLIContextCheckerInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
use Sylius\Component\Locale\Context\LocaleNotFoundException;

View file

@ -13,10 +13,10 @@ declare(strict_types=1);
namespace Sylius\Component\Promotion\Model;
use Sylius\Component\Resource\Model\TranslatableTrait;
use Sylius\Component\Resource\Model\TranslationInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Sylius\Component\Resource\Model\TranslatableTrait;
use Sylius\Component\Resource\Model\TranslationInterface;
class CatalogPromotion implements CatalogPromotionInterface
{

View file

@ -13,8 +13,8 @@ declare(strict_types=1);
namespace Sylius\Component\Promotion\Model;
use Sylius\Component\Resource\Model\CodeAwareInterface;
use Doctrine\Common\Collections\Collection;
use Sylius\Component\Resource\Model\CodeAwareInterface;
use Sylius\Component\Resource\Model\ResourceInterface;
use Sylius\Component\Resource\Model\ToggleableInterface;
use Sylius\Component\Resource\Model\TranslatableInterface;

View file

@ -13,10 +13,10 @@ declare(strict_types=1);
namespace spec\Sylius\Component\Promotion\Model;
use Doctrine\Common\Collections\Collection;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Promotion\Model\CatalogPromotionActionInterface;
use Sylius\Component\Promotion\Model\CatalogPromotionInterface;
use Doctrine\Common\Collections\Collection;
use Sylius\Component\Promotion\Model\CatalogPromotionScopeInterface;
final class CatalogPromotionSpec extends ObjectBehavior

View file

@ -31,6 +31,7 @@ final class CategoryRequirementEligibilityChecker implements ShippingMethodEligi
++$numMatches;
}
}
return match ($shippingMethod->getCategoryRequirement()) {
ShippingMethodInterface::CATEGORY_REQUIREMENT_MATCH_NONE => 0 === $numMatches,
ShippingMethodInterface::CATEGORY_REQUIREMENT_MATCH_ANY => 0 < $numMatches,

Some files were not shown because too many files have changed in this diff Show more