From 4c751ff3b479c03682b16fa818bfe2e6beca2e47 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Thu, 17 Jan 2019 10:54:44 +0100 Subject: [PATCH 1/3] [Core, Customer, Shipping, Cart] make shipping calculation less dependant on CartInterface. related to #678 --- .../Resources/config/services/shipping.yml | 4 +-- .../TaxedCarrierPriceRuleCalculator.php | 8 ++--- .../StoreBasedShippableCarriersDiscovery.php | 32 +++++++++++-------- .../Action/AdditionAmountActionProcessor.php | 17 +++++----- .../Action/DiscountAmountActionProcessor.php | 17 +++++----- .../Rule/Action/PriceActionProcessor.php | 17 +++++----- .../Condition/CategoriesConditionChecker.php | 10 +++--- .../Condition/CountriesConditionChecker.php | 2 +- .../Condition/CurrenciesConditionChecker.php | 10 +++--- .../CustomerGroupsConditionChecker.php | 12 +++---- .../Condition/CustomersConditionChecker.php | 12 +++---- .../Condition/ProductsConditionChecker.php | 2 +- .../Rule/Condition/StoresConditionChecker.php | 10 +++--- .../Rule/Condition/ZonesConditionChecker.php | 2 +- .../Customer/Model/CustomerAwareInterface.php | 26 +++++++++++++++ .../Order/Model/ProposalInterface.php | 18 ++++------- 16 files changed, 110 insertions(+), 89 deletions(-) create mode 100644 src/CoreShop/Component/Customer/Model/CustomerAwareInterface.php diff --git a/src/CoreShop/Bundle/CoreBundle/Resources/config/services/shipping.yml b/src/CoreShop/Bundle/CoreBundle/Resources/config/services/shipping.yml index 25168404a6..e2e194e61b 100644 --- a/src/CoreShop/Bundle/CoreBundle/Resources/config/services/shipping.yml +++ b/src/CoreShop/Bundle/CoreBundle/Resources/config/services/shipping.yml @@ -69,7 +69,6 @@ services: tags: - { name: coreshop.shipping_rule.action, type: discountAmount, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Shipping\Rule\Action\DiscountAmountActionConfigurationType } - coreshop.carrier.price_calculator.taxed: class: CoreShop\Component\Core\Shipping\Calculator\TaxedCarrierPriceRuleCalculator arguments: @@ -81,5 +80,6 @@ services: class: CoreShop\Component\Core\Shipping\Discover\StoreBasedShippableCarriersDiscovery decorates: coreshop.carrier.resolver arguments: + - '@coreshop.carrier.cart.store_based_resolver.inner' - '@coreshop.repository.carrier' - - '@coreshop.shipping.carrier.validator' \ No newline at end of file + - '@coreshop.shipping.carrier.validator' diff --git a/src/CoreShop/Component/Core/Shipping/Calculator/TaxedCarrierPriceRuleCalculator.php b/src/CoreShop/Component/Core/Shipping/Calculator/TaxedCarrierPriceRuleCalculator.php index 8782d6b727..ac7f91cf05 100644 --- a/src/CoreShop/Component/Core/Shipping/Calculator/TaxedCarrierPriceRuleCalculator.php +++ b/src/CoreShop/Component/Core/Shipping/Calculator/TaxedCarrierPriceRuleCalculator.php @@ -20,6 +20,7 @@ use CoreShop\Component\Shipping\Calculator\CarrierPriceCalculatorInterface; use CoreShop\Component\Shipping\Model\CarrierInterface as BaseCarrierInterface; use CoreShop\Component\Shipping\Model\ShippableInterface; +use CoreShop\Component\Store\Model\StoreAwareInterface; use CoreShop\Component\Taxation\Calculator\TaxCalculatorInterface; use CoreShop\Component\Taxation\Model\TaxRuleGroupInterface; use Webmozart\Assert\Assert; @@ -61,11 +62,6 @@ public function __construct( */ public function getPrice(BaseCarrierInterface $carrier, ShippableInterface $shippable, AddressInterface $address, $withTax = true) { - /** - * @var $shippable CartInterface - */ - Assert::isInstanceOf($shippable, CartInterface::class); - $price = $this->carrierPriceCalculator->getPrice($carrier, $shippable, $address); if (!$carrier instanceof CoreCarrierInterface) { @@ -74,7 +70,7 @@ public function getPrice(BaseCarrierInterface $carrier, ShippableInterface $ship $taxCalculator = $this->getTaxCalculator($carrier, $address); - if ($taxCalculator instanceof TaxCalculatorInterface) { + if ($taxCalculator instanceof TaxCalculatorInterface && $shippable instanceof StoreAwareInterface) { return $this->taxApplicator->applyTax($price, ['store' => $shippable->getStore()], $taxCalculator, $withTax); } diff --git a/src/CoreShop/Component/Core/Shipping/Discover/StoreBasedShippableCarriersDiscovery.php b/src/CoreShop/Component/Core/Shipping/Discover/StoreBasedShippableCarriersDiscovery.php index 275f01fad2..cab5a82a1e 100644 --- a/src/CoreShop/Component/Core/Shipping/Discover/StoreBasedShippableCarriersDiscovery.php +++ b/src/CoreShop/Component/Core/Shipping/Discover/StoreBasedShippableCarriersDiscovery.php @@ -13,15 +13,19 @@ namespace CoreShop\Component\Core\Shipping\Discover; use CoreShop\Component\Address\Model\AddressInterface; -use CoreShop\Component\Core\Model\CartInterface; use CoreShop\Component\Core\Repository\CarrierRepositoryInterface; use CoreShop\Component\Shipping\Model\ShippableInterface; use CoreShop\Component\Shipping\Resolver\CarriersResolverInterface; use CoreShop\Component\Shipping\Validator\ShippableCarrierValidatorInterface; -use Webmozart\Assert\Assert; +use CoreShop\Component\Store\Model\StoreAwareInterface; final class StoreBasedShippableCarriersDiscovery implements CarriersResolverInterface { + /** + * @var CarriersResolverInterface + */ + private $inner; + /** * @var CarrierRepositoryInterface */ @@ -33,13 +37,16 @@ final class StoreBasedShippableCarriersDiscovery implements CarriersResolverInte private $shippableCarrierValidator; /** + * @param CarriersResolverInterface $inner * @param CarrierRepositoryInterface $carrierRepository * @param ShippableCarrierValidatorInterface $shippableCarrierValidator */ public function __construct( + CarriersResolverInterface $inner, CarrierRepositoryInterface $carrierRepository, ShippableCarrierValidatorInterface $shippableCarrierValidator ) { + $this->inner = $inner; $this->carrierRepository = $carrierRepository; $this->shippableCarrierValidator = $shippableCarrierValidator; } @@ -49,20 +56,19 @@ public function __construct( */ public function resolveCarriers(ShippableInterface $shippable, AddressInterface $address) { - /** - * @var CartInterface $shippable - */ - Assert::isInstanceOf($shippable, CartInterface::class); + if ($shippable instanceof StoreAwareInterface) { + $carriers = $this->carrierRepository->findForStore($shippable->getStore()); + $availableCarriers = []; - $carriers = $this->carrierRepository->findForStore($shippable->getStore()); - $availableCarriers = []; - - foreach ($carriers as $carrier) { - if ($this->shippableCarrierValidator->isCarrierValid($carrier, $shippable, $address)) { - $availableCarriers[] = $carrier; + foreach ($carriers as $carrier) { + if ($this->shippableCarrierValidator->isCarrierValid($carrier, $shippable, $address)) { + $availableCarriers[] = $carrier; + } } + + return $availableCarriers; } - return $availableCarriers; + return $this->inner->resolveCarriers($shippable, $address); } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Action/AdditionAmountActionProcessor.php b/src/CoreShop/Component/Core/Shipping/Rule/Action/AdditionAmountActionProcessor.php index 2b614af16d..5f26c8b5ee 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Action/AdditionAmountActionProcessor.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Action/AdditionAmountActionProcessor.php @@ -15,6 +15,7 @@ use CoreShop\Component\Address\Model\AddressInterface; use CoreShop\Component\Core\Model\CartInterface; use CoreShop\Component\Currency\Converter\CurrencyConverterInterface; +use CoreShop\Component\Currency\Model\CurrencyAwareInterface; use CoreShop\Component\Currency\Model\CurrencyInterface; use CoreShop\Component\Currency\Repository\CurrencyRepositoryInterface; use CoreShop\Component\Shipping\Model\CarrierInterface; @@ -57,16 +58,16 @@ public function getPrice(CarrierInterface $carrier, ShippableInterface $shippabl */ public function getModification(CarrierInterface $carrier, ShippableInterface $shippable, AddressInterface $address, $price, array $configuration) { - /** - * @var CartInterface $shippable - */ - Assert::isInstanceOf($shippable, CartInterface::class); - $amount = $configuration['amount']; - $currency = $this->currencyRepository->find($configuration['currency']); - Assert::isInstanceOf($currency, CurrencyInterface::class); + if ($shippable instanceof CurrencyAwareInterface) { + $currency = $this->currencyRepository->find($configuration['currency']); + + Assert::isInstanceOf($currency, CurrencyInterface::class); + + return $this->moneyConverter->convert($amount, $currency->getIsoCode(), $shippable->getCurrency()->getIsoCode()); + } - return $this->moneyConverter->convert($amount, $currency->getIsoCode(), $shippable->getCurrency()->getIsoCode()); + return $amount; } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Action/DiscountAmountActionProcessor.php b/src/CoreShop/Component/Core/Shipping/Rule/Action/DiscountAmountActionProcessor.php index 3f86c27cf8..29ef90f9d3 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Action/DiscountAmountActionProcessor.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Action/DiscountAmountActionProcessor.php @@ -15,6 +15,7 @@ use CoreShop\Component\Address\Model\AddressInterface; use CoreShop\Component\Core\Model\CartInterface; use CoreShop\Component\Currency\Converter\CurrencyConverterInterface; +use CoreShop\Component\Currency\Model\CurrencyAwareInterface; use CoreShop\Component\Currency\Model\CurrencyInterface; use CoreShop\Component\Currency\Repository\CurrencyRepositoryInterface; use CoreShop\Component\Shipping\Model\CarrierInterface; @@ -57,16 +58,16 @@ public function getPrice(CarrierInterface $carrier, ShippableInterface $shippabl */ public function getModification(CarrierInterface $carrier, ShippableInterface $shippable, AddressInterface $address, $price, array $configuration) { - /** - * @var $shippable CartInterface - */ - Assert::isInstanceOf($shippable, CartInterface::class); - $amount = $configuration['amount']; - $currency = $this->currencyRepository->find($configuration['currency']); - Assert::isInstanceOf($currency, CurrencyInterface::class); + if ($shippable instanceof CurrencyAwareInterface) { + $currency = $this->currencyRepository->find($configuration['currency']); + + Assert::isInstanceOf($currency, CurrencyInterface::class); + + return -1 * $this->moneyConverter->convert($amount, $currency->getIsoCode(), $shippable->getCurrency()->getIsoCode()); + } - return -1 * $this->moneyConverter->convert($amount, $currency->getIsoCode(), $shippable->getCurrency()->getIsoCode()); + return $amount; } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Action/PriceActionProcessor.php b/src/CoreShop/Component/Core/Shipping/Rule/Action/PriceActionProcessor.php index 832b3f4c10..1854a8ad0c 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Action/PriceActionProcessor.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Action/PriceActionProcessor.php @@ -15,6 +15,7 @@ use CoreShop\Component\Address\Model\AddressInterface; use CoreShop\Component\Core\Model\CartInterface; use CoreShop\Component\Currency\Converter\CurrencyConverterInterface; +use CoreShop\Component\Currency\Model\CurrencyAwareInterface; use CoreShop\Component\Currency\Model\CurrencyInterface; use CoreShop\Component\Currency\Repository\CurrencyRepositoryInterface; use CoreShop\Component\Shipping\Model\CarrierInterface; @@ -49,17 +50,17 @@ public function __construct(CurrencyRepositoryInterface $currencyRepository, Cur */ public function getPrice(CarrierInterface $carrier, ShippableInterface $shippable, AddressInterface $address, array $configuration) { - /** - * @var $shippable CartInterface - */ - Assert::isInstanceOf($shippable, CartInterface::class); - $price = $configuration['price']; - $currency = $this->currencyRepository->find($configuration['currency']); - Assert::isInstanceOf($currency, CurrencyInterface::class); + if ($shippable instanceof CurrencyAwareInterface) { + $currency = $this->currencyRepository->find($configuration['currency']); + + Assert::isInstanceOf($currency, CurrencyInterface::class); + + return $this->moneyConverter->convert($price, $currency->getIsoCode(), $shippable->getCurrency()->getIsoCode()); + } - return $this->moneyConverter->convert($price, $currency->getIsoCode(), $shippable->getCurrency()->getIsoCode()); + return $price; } /** diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CategoriesConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CategoriesConditionChecker.php index 6f807b4ec2..e65a33791c 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CategoriesConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CategoriesConditionChecker.php @@ -21,7 +21,6 @@ use CoreShop\Component\Shipping\Model\CarrierInterface; use CoreShop\Component\Shipping\Model\ShippableInterface; use CoreShop\Component\Shipping\Rule\Condition\AbstractConditionChecker; -use Webmozart\Assert\Assert; final class CategoriesConditionChecker extends AbstractConditionChecker { @@ -42,10 +41,9 @@ public function __construct(CategoryRepositoryInterface $categoryRepository) */ public function isShippingRuleValid(CarrierInterface $carrier, ShippableInterface $shippable, AddressInterface $address, array $configuration) { - /** - * @var $shippable CartInterface - */ - Assert::isInstanceOf($shippable, CartInterface::class); + if (!$shippable instanceof CartInterface) { + return false; + } $cartItems = $shippable->getItems(); @@ -59,7 +57,7 @@ public function isShippingRuleValid(CarrierInterface $carrier, ShippableInterfac foreach ($item->getProduct()->getCategories() as $category) { if ($category instanceof ResourceInterface) { - if (in_array($category->getId(), $categoryIdsToCheck)) { + if (in_array($category->getId(), $categoryIdsToCheck, true)) { return true; } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CountriesConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CountriesConditionChecker.php index c69683bc66..5ff136b944 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CountriesConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CountriesConditionChecker.php @@ -26,6 +26,6 @@ public function isShippingRuleValid(CarrierInterface $carrier, ShippableInterfac { $country = $address->getCountry(); - return in_array($country->getId(), $configuration['countries']); + return in_array($country->getId(), $configuration['countries'], true); } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php index 62cffa4a65..6b37005f47 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php @@ -14,6 +14,7 @@ use CoreShop\Component\Address\Model\AddressInterface; use CoreShop\Component\Core\Model\CartInterface; +use CoreShop\Component\Currency\Model\CurrencyAwareInterface; use CoreShop\Component\Shipping\Model\CarrierInterface; use CoreShop\Component\Shipping\Model\ShippableInterface; use CoreShop\Component\Shipping\Rule\Condition\AbstractConditionChecker; @@ -30,11 +31,10 @@ public function isShippingRuleValid( AddressInterface $address, array $configuration ) { - /** - * @var $shippable CartInterface - */ - Assert::isInstanceOf($shippable, CartInterface::class); + if (!$shippable instanceof CurrencyAwareInterface) { + return false; + } - return in_array($shippable->getCurrency()->getId(), $configuration['currencies']); + return in_array($shippable->getCurrency()->getId(), $configuration['currencies'], true); } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomerGroupsConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomerGroupsConditionChecker.php index 1f21afd2d0..4508f57055 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomerGroupsConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomerGroupsConditionChecker.php @@ -13,13 +13,12 @@ namespace CoreShop\Component\Core\Shipping\Rule\Condition; use CoreShop\Component\Address\Model\AddressInterface; -use CoreShop\Component\Core\Model\CartInterface; +use CoreShop\Component\Customer\Model\CustomerAwareInterface; use CoreShop\Component\Customer\Model\CustomerInterface; use CoreShop\Component\Resource\Model\ResourceInterface; use CoreShop\Component\Shipping\Model\CarrierInterface; use CoreShop\Component\Shipping\Model\ShippableInterface; use CoreShop\Component\Shipping\Rule\Condition\AbstractConditionChecker; -use Webmozart\Assert\Assert; final class CustomerGroupsConditionChecker extends AbstractConditionChecker { @@ -32,10 +31,9 @@ public function isShippingRuleValid( AddressInterface $address, array $configuration ) { - /** - * @var $shippable CartInterface - */ - Assert::isInstanceOf($shippable, CartInterface::class); + if (!$shippable instanceof CustomerAwareInterface) { + return false; + } if (!$shippable->getCustomer() instanceof CustomerInterface) { return false; @@ -43,7 +41,7 @@ public function isShippingRuleValid( foreach ($shippable->getCustomer()->getCustomerGroups() as $group) { if ($group instanceof ResourceInterface) { - if (in_array($group->getId(), $configuration['customerGroups'])) { + if (in_array($group->getId(), $configuration['customerGroups'], true)) { return true; } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomersConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomersConditionChecker.php index 100551ff52..ca4da5dcdb 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomersConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomersConditionChecker.php @@ -13,12 +13,11 @@ namespace CoreShop\Component\Core\Shipping\Rule\Condition; use CoreShop\Component\Address\Model\AddressInterface; -use CoreShop\Component\Core\Model\CartInterface; +use CoreShop\Component\Customer\Model\CustomerAwareInterface; use CoreShop\Component\Customer\Model\CustomerInterface; use CoreShop\Component\Shipping\Model\CarrierInterface; use CoreShop\Component\Shipping\Model\ShippableInterface; use CoreShop\Component\Shipping\Rule\Condition\AbstractConditionChecker; -use Webmozart\Assert\Assert; final class CustomersConditionChecker extends AbstractConditionChecker { @@ -31,15 +30,14 @@ public function isShippingRuleValid( AddressInterface $address, array $configuration ) { - /** - * @var $shippable CartInterface - */ - Assert::isInstanceOf($shippable, CartInterface::class); + if (!$shippable instanceof CustomerAwareInterface) { + return false; + } if (!$shippable->getCustomer() instanceof CustomerInterface) { return false; } - return in_array($shippable->getCustomer()->getId(), $configuration['customers']); + return in_array($shippable->getCustomer()->getId(), $configuration['customers'], true); } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/ProductsConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/ProductsConditionChecker.php index d0fd4ac3f3..adcde872e3 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/ProductsConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/ProductsConditionChecker.php @@ -29,7 +29,7 @@ public function isShippingRuleValid(CarrierInterface $carrier, ShippableInterfac foreach ($cartItems as $item) { if ($item->getProduct() instanceof ProductInterface) { - if (in_array($item->getProduct()->getId(), $configuration['products'])) { + if (in_array($item->getProduct()->getId(), $configuration['products'], true)) { return true; } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php index 83533f6a3c..4bf99e2ee4 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php @@ -17,6 +17,7 @@ use CoreShop\Component\Shipping\Model\CarrierInterface; use CoreShop\Component\Shipping\Model\ShippableInterface; use CoreShop\Component\Shipping\Rule\Condition\AbstractConditionChecker; +use CoreShop\Component\Store\Model\StoreAwareInterface; use Webmozart\Assert\Assert; final class StoresConditionChecker extends AbstractConditionChecker @@ -30,11 +31,10 @@ public function isShippingRuleValid( AddressInterface $address, array $configuration ) { - /** - * @var $shippable CartInterface - */ - Assert::isInstanceOf($shippable, CartInterface::class); + if (!$shippable instanceof StoreAwareInterface) { + return false; + } - return in_array($shippable->getStore()->getId(), $configuration['stores']); + return in_array($shippable->getStore()->getId(), $configuration['stores'], true); } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/ZonesConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/ZonesConditionChecker.php index 3a4e15d133..aecb74eb64 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/ZonesConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/ZonesConditionChecker.php @@ -38,6 +38,6 @@ public function isShippingRuleValid(CarrierInterface $carrier, ShippableInterfac return false; } - return in_array($zone->getId(), $configuration['zones']); + return in_array($zone->getId(), $configuration['zones'], true); } } diff --git a/src/CoreShop/Component/Customer/Model/CustomerAwareInterface.php b/src/CoreShop/Component/Customer/Model/CustomerAwareInterface.php new file mode 100644 index 0000000000..c75520d11f --- /dev/null +++ b/src/CoreShop/Component/Customer/Model/CustomerAwareInterface.php @@ -0,0 +1,26 @@ + Date: Thu, 17 Jan 2019 11:13:51 +0100 Subject: [PATCH 2/3] [Core, Customer, Shipping, Cart] remove strict comparison --- .../Core/Shipping/Rule/Condition/CategoriesConditionChecker.php | 2 +- .../Core/Shipping/Rule/Condition/CountriesConditionChecker.php | 2 +- .../Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php | 2 +- .../Shipping/Rule/Condition/CustomerGroupsConditionChecker.php | 2 +- .../Core/Shipping/Rule/Condition/CustomersConditionChecker.php | 2 +- .../Core/Shipping/Rule/Condition/ProductsConditionChecker.php | 2 +- .../Core/Shipping/Rule/Condition/StoresConditionChecker.php | 2 +- .../Core/Shipping/Rule/Condition/ZonesConditionChecker.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CategoriesConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CategoriesConditionChecker.php index e65a33791c..34ee818639 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CategoriesConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CategoriesConditionChecker.php @@ -57,7 +57,7 @@ public function isShippingRuleValid(CarrierInterface $carrier, ShippableInterfac foreach ($item->getProduct()->getCategories() as $category) { if ($category instanceof ResourceInterface) { - if (in_array($category->getId(), $categoryIdsToCheck, true)) { + if (in_array($category->getId(), $categoryIdsToCheck)) { return true; } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CountriesConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CountriesConditionChecker.php index 5ff136b944..c69683bc66 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CountriesConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CountriesConditionChecker.php @@ -26,6 +26,6 @@ public function isShippingRuleValid(CarrierInterface $carrier, ShippableInterfac { $country = $address->getCountry(); - return in_array($country->getId(), $configuration['countries'], true); + return in_array($country->getId(), $configuration['countries']); } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php index 6b37005f47..a85c22acac 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php @@ -35,6 +35,6 @@ public function isShippingRuleValid( return false; } - return in_array($shippable->getCurrency()->getId(), $configuration['currencies'], true); + return in_array($shippable->getCurrency()->getId(), $configuration['currencies']); } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomerGroupsConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomerGroupsConditionChecker.php index 4508f57055..e4f01005b8 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomerGroupsConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomerGroupsConditionChecker.php @@ -41,7 +41,7 @@ public function isShippingRuleValid( foreach ($shippable->getCustomer()->getCustomerGroups() as $group) { if ($group instanceof ResourceInterface) { - if (in_array($group->getId(), $configuration['customerGroups'], true)) { + if (in_array($group->getId(), $configuration['customerGroups'])) { return true; } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomersConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomersConditionChecker.php index ca4da5dcdb..59032a0a8d 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomersConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CustomersConditionChecker.php @@ -38,6 +38,6 @@ public function isShippingRuleValid( return false; } - return in_array($shippable->getCustomer()->getId(), $configuration['customers'], true); + return in_array($shippable->getCustomer()->getId(), $configuration['customers']); } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/ProductsConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/ProductsConditionChecker.php index adcde872e3..d0fd4ac3f3 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/ProductsConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/ProductsConditionChecker.php @@ -29,7 +29,7 @@ public function isShippingRuleValid(CarrierInterface $carrier, ShippableInterfac foreach ($cartItems as $item) { if ($item->getProduct() instanceof ProductInterface) { - if (in_array($item->getProduct()->getId(), $configuration['products'], true)) { + if (in_array($item->getProduct()->getId(), $configuration['products'])) { return true; } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php index 4bf99e2ee4..3e21a64663 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php @@ -35,6 +35,6 @@ public function isShippingRuleValid( return false; } - return in_array($shippable->getStore()->getId(), $configuration['stores'], true); + return in_array($shippable->getStore()->getId(), $configuration['stores']); } } diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/ZonesConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/ZonesConditionChecker.php index aecb74eb64..3a4e15d133 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/ZonesConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/ZonesConditionChecker.php @@ -38,6 +38,6 @@ public function isShippingRuleValid(CarrierInterface $carrier, ShippableInterfac return false; } - return in_array($zone->getId(), $configuration['zones'], true); + return in_array($zone->getId(), $configuration['zones']); } } From ecd15cb087f80615f4f094529c0414f3f492ad8d Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Thu, 17 Jan 2019 12:31:50 +0100 Subject: [PATCH 3/3] [Core, Customer, Shipping, Cart] code-style --- .../Calculator/TaxedCarrierPriceRuleCalculator.php | 2 -- .../Rule/Action/AdditionAmountActionProcessor.php | 1 - .../Rule/Action/DiscountAmountActionProcessor.php | 1 - .../Core/Shipping/Rule/Action/PriceActionProcessor.php | 1 - .../Rule/Condition/CurrenciesConditionChecker.php | 2 -- .../Shipping/Rule/Condition/StoresConditionChecker.php | 2 -- src/CoreShop/Component/Order/Model/ProposalInterface.php | 8 +------- src/CoreShop/Component/Pimcore/DataObject/DataLoader.php | 2 +- .../Component/Pimcore/DataObject/DataLoaderInterface.php | 1 + 9 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/CoreShop/Component/Core/Shipping/Calculator/TaxedCarrierPriceRuleCalculator.php b/src/CoreShop/Component/Core/Shipping/Calculator/TaxedCarrierPriceRuleCalculator.php index ac7f91cf05..891fd7eb59 100644 --- a/src/CoreShop/Component/Core/Shipping/Calculator/TaxedCarrierPriceRuleCalculator.php +++ b/src/CoreShop/Component/Core/Shipping/Calculator/TaxedCarrierPriceRuleCalculator.php @@ -14,7 +14,6 @@ use CoreShop\Component\Address\Model\AddressInterface; use CoreShop\Component\Core\Model\CarrierInterface as CoreCarrierInterface; -use CoreShop\Component\Core\Model\CartInterface; use CoreShop\Component\Core\Taxation\TaxApplicatorInterface; use CoreShop\Component\Core\Taxation\TaxCalculatorFactoryInterface; use CoreShop\Component\Shipping\Calculator\CarrierPriceCalculatorInterface; @@ -23,7 +22,6 @@ use CoreShop\Component\Store\Model\StoreAwareInterface; use CoreShop\Component\Taxation\Calculator\TaxCalculatorInterface; use CoreShop\Component\Taxation\Model\TaxRuleGroupInterface; -use Webmozart\Assert\Assert; final class TaxedCarrierPriceRuleCalculator implements TaxedShippingCalculatorInterface { diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Action/AdditionAmountActionProcessor.php b/src/CoreShop/Component/Core/Shipping/Rule/Action/AdditionAmountActionProcessor.php index 5f26c8b5ee..304b6b435e 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Action/AdditionAmountActionProcessor.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Action/AdditionAmountActionProcessor.php @@ -13,7 +13,6 @@ namespace CoreShop\Component\Core\Shipping\Rule\Action; use CoreShop\Component\Address\Model\AddressInterface; -use CoreShop\Component\Core\Model\CartInterface; use CoreShop\Component\Currency\Converter\CurrencyConverterInterface; use CoreShop\Component\Currency\Model\CurrencyAwareInterface; use CoreShop\Component\Currency\Model\CurrencyInterface; diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Action/DiscountAmountActionProcessor.php b/src/CoreShop/Component/Core/Shipping/Rule/Action/DiscountAmountActionProcessor.php index 29ef90f9d3..66e20d237f 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Action/DiscountAmountActionProcessor.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Action/DiscountAmountActionProcessor.php @@ -13,7 +13,6 @@ namespace CoreShop\Component\Core\Shipping\Rule\Action; use CoreShop\Component\Address\Model\AddressInterface; -use CoreShop\Component\Core\Model\CartInterface; use CoreShop\Component\Currency\Converter\CurrencyConverterInterface; use CoreShop\Component\Currency\Model\CurrencyAwareInterface; use CoreShop\Component\Currency\Model\CurrencyInterface; diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Action/PriceActionProcessor.php b/src/CoreShop/Component/Core/Shipping/Rule/Action/PriceActionProcessor.php index 1854a8ad0c..3634ec9ffe 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Action/PriceActionProcessor.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Action/PriceActionProcessor.php @@ -13,7 +13,6 @@ namespace CoreShop\Component\Core\Shipping\Rule\Action; use CoreShop\Component\Address\Model\AddressInterface; -use CoreShop\Component\Core\Model\CartInterface; use CoreShop\Component\Currency\Converter\CurrencyConverterInterface; use CoreShop\Component\Currency\Model\CurrencyAwareInterface; use CoreShop\Component\Currency\Model\CurrencyInterface; diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php index a85c22acac..459cab5acb 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/CurrenciesConditionChecker.php @@ -13,12 +13,10 @@ namespace CoreShop\Component\Core\Shipping\Rule\Condition; use CoreShop\Component\Address\Model\AddressInterface; -use CoreShop\Component\Core\Model\CartInterface; use CoreShop\Component\Currency\Model\CurrencyAwareInterface; use CoreShop\Component\Shipping\Model\CarrierInterface; use CoreShop\Component\Shipping\Model\ShippableInterface; use CoreShop\Component\Shipping\Rule\Condition\AbstractConditionChecker; -use Webmozart\Assert\Assert; final class CurrenciesConditionChecker extends AbstractConditionChecker { diff --git a/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php b/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php index 3e21a64663..4eb3573f9d 100644 --- a/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php +++ b/src/CoreShop/Component/Core/Shipping/Rule/Condition/StoresConditionChecker.php @@ -13,12 +13,10 @@ namespace CoreShop\Component\Core\Shipping\Rule\Condition; use CoreShop\Component\Address\Model\AddressInterface; -use CoreShop\Component\Core\Model\CartInterface; use CoreShop\Component\Shipping\Model\CarrierInterface; use CoreShop\Component\Shipping\Model\ShippableInterface; use CoreShop\Component\Shipping\Rule\Condition\AbstractConditionChecker; use CoreShop\Component\Store\Model\StoreAwareInterface; -use Webmozart\Assert\Assert; final class StoresConditionChecker extends AbstractConditionChecker { diff --git a/src/CoreShop/Component/Order/Model/ProposalInterface.php b/src/CoreShop/Component/Order/Model/ProposalInterface.php index 2a5df7591a..a2ae58936f 100644 --- a/src/CoreShop/Component/Order/Model/ProposalInterface.php +++ b/src/CoreShop/Component/Order/Model/ProposalInterface.php @@ -16,18 +16,12 @@ use CoreShop\Component\Currency\Model\CurrencyAwareInterface; use CoreShop\Component\Currency\Model\CurrencyInterface; use CoreShop\Component\Customer\Model\CustomerAwareInterface; -use CoreShop\Component\Customer\Model\CustomerInterface; use CoreShop\Component\Locale\Model\LocaleAwareInterface; use CoreShop\Component\Resource\Model\ResourceInterface; use CoreShop\Component\Store\Model\StoreAwareInterface; use Pimcore\Model\DataObject\Fieldcollection; -interface ProposalInterface extends ResourceInterface, - CurrencyAwareInterface, - StoreAwareInterface, - LocaleAwareInterface, - AdjustableInterface, - CustomerAwareInterface +interface ProposalInterface extends ResourceInterface, CurrencyAwareInterface, StoreAwareInterface, LocaleAwareInterface, AdjustableInterface, CustomerAwareInterface { /** * @return CurrencyInterface diff --git a/src/CoreShop/Component/Pimcore/DataObject/DataLoader.php b/src/CoreShop/Component/Pimcore/DataObject/DataLoader.php index c07187a693..5e195a02e4 100644 --- a/src/CoreShop/Component/Pimcore/DataObject/DataLoader.php +++ b/src/CoreShop/Component/Pimcore/DataObject/DataLoader.php @@ -32,7 +32,7 @@ public function getDataForObject(DataObject\Concrete $data, $loadedObjects = []) $loadedObjects[] = $data->getId(); foreach ($data->getClass()->getFieldDefinitions() as $key => $def) { - $getter = 'get'.ucfirst($key); + $getter = 'get' . ucfirst($key); if (!method_exists($data, $getter)) { continue; diff --git a/src/CoreShop/Component/Pimcore/DataObject/DataLoaderInterface.php b/src/CoreShop/Component/Pimcore/DataObject/DataLoaderInterface.php index 5c5f1761dc..ad23c3126e 100644 --- a/src/CoreShop/Component/Pimcore/DataObject/DataLoaderInterface.php +++ b/src/CoreShop/Component/Pimcore/DataObject/DataLoaderInterface.php @@ -19,6 +19,7 @@ interface DataLoaderInterface /** * @param DataObject\Concrete $data * @param array $loadedObjects + * * @return mixed */ public function getDataForObject(DataObject\Concrete $data, $loadedObjects = []);