diff --git a/README.md b/README.md index 768b9b52b2..0c241133d1 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,23 @@ Community Stay updated by following our [Twitter](https://twitter.com/Sylius) and [Facebook](https://www.facebook.com/SyliusEcommerce/). +Official plugins +---------------- + +This is the list of oficially supported Sylius plugins: + + - [Shop API Plugin](https://github.com/Sylius/SyliusShopApiPlugin) - + provides customer-level API for the shop functionalities + - [Admin Order Creation Plugin](https://github.com/Sylius/AdminOrderCreationPlugin) - + allows to create orders directly from the administrator panel + - [Customer Reorder Plugin](https://github.com/Sylius/CustomerReorderPlugin) - + allows customer to copy items from the already placed order to the current cart + - [Customer Order Cancellation Plugin](https://github.com/Sylius/CustomerOrderCancellationPlugin) - + allows customer to cancel a placed order which has not been processed yet + +You can find other plugins on [our ecosystem website](https://sylius.com/plugins/) or by looking for +[packages marked as *sylius-plugin*](https://packagist.org/explore/?type=sylius-plugin). + Contributing ------------ @@ -46,7 +63,7 @@ Would like to help us and build the most developer-friendly eCommerce platform? License ------- -Sylius is completely free and released under the [MIT License](https://github.com/Sylius/Sylius/blob/master/LICENSE). +Sylius is completely free and released under the [MIT License](https://github.com/Sylius/Sylius/blob/1.1/LICENSE). Authors ------- diff --git a/phpstan.neon b/phpstan.neon index 7c48e6af10..9cb0bd73b3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -29,6 +29,8 @@ parameters: - '/Call to an undefined method Faker\\Generator::/' - '/Access to an undefined property Faker\\Generator::/' - '/Method Mockery\\MockInterface::shouldReceive\(\) invoked with 1 parameter, 0 required/' + - '/Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface/' + - '/Call to an undefined method Mockery\\ExpectationInterface|Mockery\\HigherOrderMessage::/' # These packages aren't in require-dev of the global package - '/Class Doctrine\\Bundle\\MongoDBBundle/' diff --git a/src/Sylius/Behat/Context/Api/Admin/ManagingProductVariantsContext.php b/src/Sylius/Behat/Context/Api/Admin/ManagingProductVariantsContext.php index 08ba31a4e5..0c5dcda9de 100644 --- a/src/Sylius/Behat/Context/Api/Admin/ManagingProductVariantsContext.php +++ b/src/Sylius/Behat/Context/Api/Admin/ManagingProductVariantsContext.php @@ -15,9 +15,9 @@ namespace Sylius\Behat\Context\Api\Admin; use Behat\Behat\Context\Context; use Sylius\Component\Core\Model\ProductInterface; -use Symfony\Component\BrowserKit\Client; use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\HttpFoundation\Session\SessionInterface; +use Symfony\Component\HttpKernel\Client; use Webmozart\Assert\Assert; final class ManagingProductVariantsContext implements Context diff --git a/src/Sylius/Behat/Context/Api/Admin/ManagingTaxonsContext.php b/src/Sylius/Behat/Context/Api/Admin/ManagingTaxonsContext.php index bf48b5c537..cc04821944 100644 --- a/src/Sylius/Behat/Context/Api/Admin/ManagingTaxonsContext.php +++ b/src/Sylius/Behat/Context/Api/Admin/ManagingTaxonsContext.php @@ -15,9 +15,9 @@ namespace Sylius\Behat\Context\Api\Admin; use Behat\Behat\Context\Context; use Sylius\Component\Core\Model\TaxonInterface; -use Symfony\Component\BrowserKit\Client; use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\HttpFoundation\Session\SessionInterface; +use Symfony\Component\HttpKernel\Client; use Webmozart\Assert\Assert; final class ManagingTaxonsContext implements Context diff --git a/src/Sylius/Behat/Context/Setup/AdminUserContext.php b/src/Sylius/Behat/Context/Setup/AdminUserContext.php index 655745d4fd..53f5c8b694 100644 --- a/src/Sylius/Behat/Context/Setup/AdminUserContext.php +++ b/src/Sylius/Behat/Context/Setup/AdminUserContext.php @@ -57,7 +57,9 @@ final class AdminUserContext implements Context */ public function thereIsAnAdministratorIdentifiedBy($email, $password = 'sylius') { + /** @var AdminUserInterface $adminUser */ $adminUser = $this->userFactory->create(['email' => $email, 'password' => $password, 'enabled' => true]); + $this->userRepository->add($adminUser); $this->sharedStorage->set('administrator', $adminUser); } @@ -67,6 +69,7 @@ final class AdminUserContext implements Context */ public function thereIsAnAdministratorWithName($username) { + /** @var AdminUserInterface $adminUser */ $adminUser = $this->userFactory->create(['username' => $username]); $adminUser->setUsername($username); diff --git a/src/Sylius/Behat/Context/Setup/CustomerContext.php b/src/Sylius/Behat/Context/Setup/CustomerContext.php index 9f36cf7fa1..ed58dba96b 100644 --- a/src/Sylius/Behat/Context/Setup/CustomerContext.php +++ b/src/Sylius/Behat/Context/Setup/CustomerContext.php @@ -17,7 +17,9 @@ use Behat\Behat\Context\Context; use Doctrine\Common\Persistence\ObjectManager; use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Addressing\Model\CountryInterface; +use Sylius\Component\Core\Model\AddressInterface; use Sylius\Component\Core\Model\CustomerInterface; +use Sylius\Component\Core\Model\ShopUserInterface; use Sylius\Component\Core\Repository\CustomerRepositoryInterface; use Sylius\Component\Customer\Model\CustomerGroupInterface; use Sylius\Component\Resource\Factory\FactoryInterface; @@ -190,6 +192,8 @@ final class CustomerContext implements Context public function thereIsUserIdentifiedByWithAsShippingCountry($email, CountryInterface $country) { $customer = $this->createCustomerWithUserAccount($email, 'password123', true, 'John', 'Doe'); + + /** @var AddressInterface $address */ $address = $this->addressFactory->createNew(); $address->setCountryCode($country->getCode()); $address->setCity('Berlin'); @@ -252,7 +256,9 @@ final class CustomerContext implements Context $lastName = null, $role = null ) { + /** @var ShopUserInterface $user */ $user = $this->userFactory->createNew(); + /** @var CustomerInterface $customer */ $customer = $this->customerFactory->createNew(); diff --git a/src/Sylius/Behat/Context/Setup/OrderContext.php b/src/Sylius/Behat/Context/Setup/OrderContext.php index 30490d5cf2..4f76d73a45 100644 --- a/src/Sylius/Behat/Context/Setup/OrderContext.php +++ b/src/Sylius/Behat/Context/Setup/OrderContext.php @@ -778,6 +778,7 @@ final class OrderContext implements Context $customers = []; for ($i = 0; $i < $count; ++$i) { + /** @var CustomerInterface $customer */ $customer = $this->customerFactory->createNew(); $customer->setEmail(sprintf('john%s@doe.com', uniqid())); $customer->setFirstname('John'); @@ -791,14 +792,9 @@ final class OrderContext implements Context return $customers; } - /** - * @param string $price - * - * @return int - */ - private function getPriceFromString($price) + private function getPriceFromString(string $price): int { - return (int) round(str_replace(['€', '£', '$'], '', $price) * 100, 2); + return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2); } /** @@ -847,6 +843,7 @@ final class OrderContext implements Context */ private function addVariantWithPriceToOrder(OrderInterface $order, ProductVariantInterface $variant, $price) { + /** @var OrderItemInterface $item */ $item = $this->orderItemFactory->createNew(); $item->setVariant($variant); $item->setUnitPrice($price); diff --git a/src/Sylius/Behat/Context/Setup/ProductAssociationContext.php b/src/Sylius/Behat/Context/Setup/ProductAssociationContext.php index b6c39642cc..0fae6fc244 100644 --- a/src/Sylius/Behat/Context/Setup/ProductAssociationContext.php +++ b/src/Sylius/Behat/Context/Setup/ProductAssociationContext.php @@ -22,7 +22,6 @@ use Sylius\Component\Product\Model\ProductAssociationTypeInterface; use Sylius\Component\Product\Model\ProductAssociationTypeTranslationInterface; use Sylius\Component\Product\Repository\ProductAssociationTypeRepositoryInterface; use Sylius\Component\Resource\Factory\FactoryInterface; -use Sylius\Component\Resource\Model\TranslationInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; final class ProductAssociationContext implements Context @@ -198,10 +197,10 @@ final class ProductAssociationContext implements Context */ private function addProductAssociationTypeTranslation( ProductAssociationTypeInterface $productAssociationType, - $name, - $locale + string $name, + string $locale ) { - /** @var ProductAssociationTypeTranslationInterface|TranslationInterface $translation */ + /** @var ProductAssociationTypeTranslationInterface $translation */ $translation = $this->productAssociationTypeTranslationFactory->createNew(); $translation->setLocale($locale); $translation->setName($name); diff --git a/src/Sylius/Behat/Context/Setup/ProductContext.php b/src/Sylius/Behat/Context/Setup/ProductContext.php index 3e9b953068..113c52fb7b 100644 --- a/src/Sylius/Behat/Context/Setup/ProductContext.php +++ b/src/Sylius/Behat/Context/Setup/ProductContext.php @@ -35,7 +35,6 @@ use Sylius\Component\Product\Model\ProductOptionValueInterface; use Sylius\Component\Product\Model\ProductVariantTranslationInterface; use Sylius\Component\Product\Resolver\ProductVariantResolverInterface; use Sylius\Component\Resource\Factory\FactoryInterface; -use Sylius\Component\Resource\Model\TranslationInterface; use Sylius\Component\Shipping\Model\ShippingCategoryInterface; use Sylius\Component\Taxation\Model\TaxCategoryInterface; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -792,14 +791,9 @@ final class ProductContext implements Context $this->objectManager->flush(); } - /** - * @param string $price - * - * @return int - */ - private function getPriceFromString($price) + private function getPriceFromString(string $price): int { - return (int) round($price * 100, 2); + return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2); } /** @@ -934,9 +928,10 @@ final class ProductContext implements Context */ private function addProductTranslation(ProductInterface $product, $name, $locale) { - /** @var ProductTranslationInterface|TranslationInterface $translation */ + /** @var ProductTranslationInterface $translation */ $translation = $product->getTranslation($locale); if ($translation->getLocale() !== $locale) { + /** @var ProductTranslationInterface $translation */ $translation = $this->productTranslationFactory->createNew(); } @@ -954,7 +949,7 @@ final class ProductContext implements Context */ private function addProductVariantTranslation(ProductVariantInterface $productVariant, $name, $locale) { - /** @var ProductVariantTranslationInterface|TranslationInterface $translation */ + /** @var ProductVariantTranslationInterface $translation */ $translation = $this->productVariantTranslationFactory->createNew(); $translation->setLocale($locale); $translation->setName($name); diff --git a/src/Sylius/Behat/Context/Setup/PromotionContext.php b/src/Sylius/Behat/Context/Setup/PromotionContext.php index f42bd0e348..72dfdaeb3c 100644 --- a/src/Sylius/Behat/Context/Setup/PromotionContext.php +++ b/src/Sylius/Behat/Context/Setup/PromotionContext.php @@ -677,6 +677,7 @@ final class PromotionContext implements Context $discount, CustomerGroupInterface $customerGroup ) { + /** @var PromotionRuleInterface $rule */ $rule = $this->ruleFactory->createNew(); $rule->setType(CustomerGroupRuleChecker::TYPE); $rule->setConfiguration(['group_code' => $customerGroup->getCode()]); diff --git a/src/Sylius/Behat/Context/Setup/TaxonomyContext.php b/src/Sylius/Behat/Context/Setup/TaxonomyContext.php index 50f829d2d3..6467090a5c 100644 --- a/src/Sylius/Behat/Context/Setup/TaxonomyContext.php +++ b/src/Sylius/Behat/Context/Setup/TaxonomyContext.php @@ -21,7 +21,6 @@ use Sylius\Component\Core\Model\ImageInterface; use Sylius\Component\Core\Model\TaxonInterface; use Sylius\Component\Core\Uploader\ImageUploaderInterface; use Sylius\Component\Resource\Factory\FactoryInterface; -use Sylius\Component\Resource\Model\TranslationInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; use Sylius\Component\Taxonomy\Generator\TaxonSlugGeneratorInterface; use Sylius\Component\Taxonomy\Model\TaxonTranslationInterface; @@ -184,7 +183,7 @@ final class TaxonomyContext implements Context $taxon = $this->taxonFactory->createNew(); $taxon->setCode(StringInflector::nameToCode($names['en_US'])); foreach ($names as $locale => $name) { - /** @var TranslationInterface|TaxonTranslationInterface $taxonTranslation */ + /** @var TaxonTranslationInterface $taxonTranslation */ $taxonTranslation = $this->taxonTranslationFactory->createNew(); $taxonTranslation->setLocale($locale); $taxonTranslation->setName($name); diff --git a/src/Sylius/Behat/Context/Transform/CustomerContext.php b/src/Sylius/Behat/Context/Transform/CustomerContext.php index a5fbb48dd2..647ebda0a4 100644 --- a/src/Sylius/Behat/Context/Transform/CustomerContext.php +++ b/src/Sylius/Behat/Context/Transform/CustomerContext.php @@ -60,6 +60,7 @@ final class CustomerContext implements Context /** @var CustomerInterface $customer */ $customer = $this->customerRepository->findOneBy(['email' => $email]); if (null === $customer) { + /** @var CustomerInterface $customer */ $customer = $this->customerFactory->createNew(); $customer->setEmail($email); diff --git a/src/Sylius/Behat/Context/Transform/LexicalContext.php b/src/Sylius/Behat/Context/Transform/LexicalContext.php index 59fc093854..34c9d36fc2 100644 --- a/src/Sylius/Behat/Context/Transform/LexicalContext.php +++ b/src/Sylius/Behat/Context/Transform/LexicalContext.php @@ -20,21 +20,23 @@ final class LexicalContext implements Context /** * @Transform /^"(\-)?(?:€|£|¥|\$)((?:\d+\.)?\d+)"$/ */ - public function getPriceFromString($sign, $price) + public function getPriceFromString(string $sign, string $price): int { $this->validatePriceString($price); + $price = (int) round((float) $price * 100, 2); + if ('-' === $sign) { $price *= -1; } - return (int) round($price * 100, 2); + return $price; } /** * @Transform /^"((?:\d+\.)?\d+)%"$/ */ - public function getPercentageFromString($percentage) + public function getPercentageFromString(string $percentage): float { return ((int) $percentage) / 100; } @@ -44,7 +46,7 @@ final class LexicalContext implements Context * * @throws \InvalidArgumentException */ - private function validatePriceString($price) + private function validatePriceString(string $price): void { if (!(bool) preg_match('/^\d+(?:\.\d{1,2})?$/', $price)) { throw new \InvalidArgumentException('Price string should not have more than 2 decimal digits.'); diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingPaymentMethodsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingPaymentMethodsContext.php index 7fb721797f..c3b2231cbd 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingPaymentMethodsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingPaymentMethodsContext.php @@ -151,17 +151,6 @@ final class ManagingPaymentMethodsContext implements Context $this->notificationChecker->checkNotification('Cannot delete, the payment method is in use.', NotificationType::failure()); } - /** - * @When I choose :gatewayName gateway - */ - public function iChooseGateway($gatewayName) - { - /** @var CreatePageInterface|UpdatePageInterface $currentPage */ - $currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]); - - $currentPage->chooseGateway($gatewayName); - } - /** * @Then this payment method :element should be :value */ diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductAttributesContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductAttributesContext.php index 0c1727db0e..aec2e0bc91 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductAttributesContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductAttributesContext.php @@ -193,6 +193,7 @@ final class ManagingProductAttributesContext implements Context */ public function theTypeFieldShouldBeDisabled() { + /** @var CreatePageInterface|UpdatePageInterface $currentPage */ $currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]); Assert::true($currentPage->isTypeDisabled()); diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php index 9be19e577a..6aaffb6c3c 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php @@ -142,6 +142,7 @@ final class ManagingProductOptionsContext implements Context */ public function iAddTheOptionValueWithCodeAndValue($value, $code) { + /** @var CreatePageInterface|UpdatePageInterface $currentPage */ $currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]); $currentPage->addOptionValue($code, $value); diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductVariantsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductVariantsContext.php index 108cc6b0b1..324ef1bb41 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductVariantsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductVariantsContext.php @@ -115,14 +115,6 @@ final class ManagingProductVariantsContext implements Context $this->createPage->nameItIn($name, $language); } - /** - * @When I rename it to :name - */ - public function iRenameItTo($name) - { - $this->updatePage->nameIt($name); - } - /** * @When I add it * @When I try to add it @@ -418,14 +410,6 @@ final class ManagingProductVariantsContext implements Context $this->updatePage->saveChanges(); } - /** - * @When I remove its name - */ - public function iRemoveItsNameFromTranslation() - { - $this->updatePage->nameIt(''); - } - /** * @Then /^inventory of (this variant) should not be tracked$/ */ diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php index 6f95d71700..9cc1635124 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php @@ -25,7 +25,6 @@ use Sylius\Behat\Page\Admin\Product\IndexPerTaxonPageInterface; use Sylius\Behat\Page\Admin\Product\UpdateConfigurableProductPageInterface; use Sylius\Behat\Page\Admin\Product\UpdateSimpleProductPageInterface; use Sylius\Behat\Page\Admin\ProductReview\IndexPageInterface as ProductReviewIndexPageInterface; -use Sylius\Behat\Page\SymfonyPageInterface; use Sylius\Behat\Service\NotificationCheckerInterface; use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface; use Sylius\Behat\Service\SharedStorageInterface; @@ -987,7 +986,7 @@ final class ManagingProductsContext implements Context } /** - * @return SymfonyPageInterface|IndexPageInterface|IndexPerTaxonPageInterface|CreateSimpleProductPageInterface|CreateConfigurableProductPageInterface|UpdateSimpleProductPageInterface|UpdateConfigurableProductPageInterface + * @return IndexPageInterface|IndexPerTaxonPageInterface|CreateSimpleProductPageInterface|CreateConfigurableProductPageInterface|UpdateSimpleProductPageInterface|UpdateConfigurableProductPageInterface */ private function resolveCurrentPage() { diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php index 8e42ac767f..e2207e7c71 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php @@ -350,6 +350,7 @@ final class ManagingPromotionsContext implements Context */ public function iSetItsUsageLimitTo($usageLimit) { + /** @var CreatePageInterface|UpdatePageInterface $currentPage */ $currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]); $currentPage->fillUsageLimit($usageLimit); diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingShippingCategoriesContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingShippingCategoriesContext.php index c916c2be73..4542f2506e 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingShippingCategoriesContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingShippingCategoriesContext.php @@ -15,8 +15,8 @@ namespace Sylius\Behat\Context\Ui\Admin; use Behat\Behat\Context\Context; use Sylius\Behat\Page\Admin\Crud\IndexPageInterface; -use Sylius\Behat\Page\Admin\Crud\UpdatePageInterface; use Sylius\Behat\Page\Admin\ShippingCategory\CreatePageInterface; +use Sylius\Behat\Page\Admin\ShippingCategory\UpdatePageInterface; use Sylius\Component\Shipping\Model\ShippingCategoryInterface; use Webmozart\Assert\Assert; diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php index a08a018e64..c71736e000 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php @@ -17,7 +17,6 @@ use Behat\Behat\Context\Context; use Sylius\Behat\Page\Admin\Taxon\CreateForParentPageInterface; use Sylius\Behat\Page\Admin\Taxon\CreatePageInterface; use Sylius\Behat\Page\Admin\Taxon\UpdatePageInterface; -use Sylius\Behat\Page\SymfonyPageInterface; use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface; use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Core\Model\TaxonInterface; @@ -408,7 +407,7 @@ final class ManagingTaxonsContext implements Context } /** - * @return SymfonyPageInterface|CreatePageInterface|CreateForParentPageInterface|UpdatePageInterface + * @return CreatePageInterface|CreateForParentPageInterface|UpdatePageInterface */ private function resolveCurrentPage() { diff --git a/src/Sylius/Behat/Context/Ui/Shop/AccountContext.php b/src/Sylius/Behat/Context/Ui/Shop/AccountContext.php index 1688d9d832..55148229a2 100644 --- a/src/Sylius/Behat/Context/Ui/Shop/AccountContext.php +++ b/src/Sylius/Behat/Context/Ui/Shop/AccountContext.php @@ -15,7 +15,6 @@ namespace Sylius\Behat\Context\Ui\Shop; use Behat\Behat\Context\Context; use Sylius\Behat\NotificationType; -use Sylius\Behat\Page\PageInterface; use Sylius\Behat\Page\Shop\Account\ChangePasswordPageInterface; use Sylius\Behat\Page\Shop\Account\DashboardPageInterface; use Sylius\Behat\Page\Shop\Account\LoginPageInterface; @@ -170,11 +169,10 @@ final class AccountContext implements Context */ public function iShouldBeNotifiedThatElementIsRequired($element) { - $this->assertFieldValidationMessage( - $this->profileUpdatePage, + Assert::true($this->profileUpdatePage->checkValidationMessageFor( StringInflector::nameToCode($element), sprintf('Please enter your %s.', $element) - ); + )); } /** @@ -182,11 +180,10 @@ final class AccountContext implements Context */ public function iShouldBeNotifiedThatElementIsInvalid($element) { - $this->assertFieldValidationMessage( - $this->profileUpdatePage, + Assert::true($this->profileUpdatePage->checkValidationMessageFor( StringInflector::nameToCode($element), sprintf('This %s is invalid.', $element) - ); + )); } /** @@ -194,7 +191,7 @@ final class AccountContext implements Context */ public function iShouldBeNotifiedThatTheEmailIsAlreadyUsed() { - $this->assertFieldValidationMessage($this->profileUpdatePage, 'email', 'This email is already used.'); + Assert::true($this->profileUpdatePage->checkValidationMessageFor('email', 'This email is already used.')); } /** @@ -252,11 +249,10 @@ final class AccountContext implements Context */ public function iShouldBeNotifiedThatProvidedPasswordIsDifferentThanTheCurrentOne() { - $this->assertFieldValidationMessage( - $this->changePasswordPage, + Assert::true($this->changePasswordPage->checkValidationMessageFor( 'current_password', 'Provided password is different than the current one.' - ); + )); } /** @@ -264,11 +260,10 @@ final class AccountContext implements Context */ public function iShouldBeNotifiedThatTheEnteredPasswordsDoNotMatch() { - $this->assertFieldValidationMessage( - $this->changePasswordPage, + Assert::true($this->changePasswordPage->checkValidationMessageFor( 'new_password', 'The entered passwords don\'t match' - ); + )); } /** @@ -276,11 +271,10 @@ final class AccountContext implements Context */ public function iShouldBeNotifiedThatThePasswordShouldBeAtLeastCharactersLong() { - $this->assertFieldValidationMessage( - $this->changePasswordPage, + Assert::true($this->changePasswordPage->checkValidationMessageFor( 'new_password', 'Password must be at least 4 characters long.' - ); + )); } /** @@ -452,14 +446,4 @@ final class AccountContext implements Context { $this->loginPage->tryToOpen(); } - - /** - * @param PageInterface $page - * @param string $element - * @param string $expectedMessage - */ - private function assertFieldValidationMessage(PageInterface $page, $element, $expectedMessage) - { - Assert::true($page->checkValidationMessageFor($element, $expectedMessage)); - } } diff --git a/src/Sylius/Behat/Context/Ui/Shop/CartContext.php b/src/Sylius/Behat/Context/Ui/Shop/CartContext.php index 5b2bdebe09..2cb92af4f5 100644 --- a/src/Sylius/Behat/Context/Ui/Shop/CartContext.php +++ b/src/Sylius/Behat/Context/Ui/Shop/CartContext.php @@ -423,13 +423,8 @@ final class CartContext implements Context Assert::same($this->summaryPage->getCartTotal(), $total); } - /** - * @param string $price - * - * @return int - */ - private function getPriceFromString($price) + private function getPriceFromString(string $price): int { - return (int) round(str_replace(['€', '£', '$'], '', $price) * 100, 2); + return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2); } } diff --git a/src/Sylius/Behat/Context/Ui/Shop/ContactContext.php b/src/Sylius/Behat/Context/Ui/Shop/ContactContext.php index 4b260c9524..2ecadbaa34 100644 --- a/src/Sylius/Behat/Context/Ui/Shop/ContactContext.php +++ b/src/Sylius/Behat/Context/Ui/Shop/ContactContext.php @@ -15,7 +15,6 @@ namespace Sylius\Behat\Context\Ui\Shop; use Behat\Behat\Context\Context; use Sylius\Behat\NotificationType; -use Sylius\Behat\Page\PageInterface; use Sylius\Behat\Page\Shop\Contact\ContactPageInterface; use Sylius\Behat\Service\NotificationCheckerInterface; use Webmozart\Assert\Assert; @@ -95,11 +94,7 @@ final class ContactContext implements Context */ public function iShouldBeNotifiedThatElementIsRequired($element) { - $this->assertFieldValidationMessage( - $this->contactPage, - $element, - sprintf('Please enter your %s.', $element) - ); + Assert::same($this->contactPage->getValidationMessageFor($element), sprintf('Please enter your %s.', $element)); } /** @@ -107,11 +102,7 @@ final class ContactContext implements Context */ public function iShouldBeNotifiedThatEmailIsInvalid() { - $this->assertFieldValidationMessage( - $this->contactPage, - 'email', - 'This email is invalid.' - ); + Assert::same($this->contactPage->getValidationMessageFor('email'), 'This email is invalid.'); } /** @@ -124,14 +115,4 @@ final class ContactContext implements Context NotificationType::failure() ); } - - /** - * @param PageInterface $page - * @param string $element - * @param string $expectedMessage - */ - private function assertFieldValidationMessage(PageInterface $page, $element, $expectedMessage) - { - Assert::same($page->getValidationMessageFor($element), $expectedMessage); - } } diff --git a/src/Sylius/Behat/Context/Ui/UserContext.php b/src/Sylius/Behat/Context/Ui/UserContext.php index 7281a79dd1..f4c69822eb 100644 --- a/src/Sylius/Behat/Context/Ui/UserContext.php +++ b/src/Sylius/Behat/Context/Ui/UserContext.php @@ -17,6 +17,7 @@ use Behat\Behat\Context\Context; use Sylius\Behat\Page\Admin\Customer\ShowPageInterface; use Sylius\Behat\Page\Shop\HomePageInterface; use Sylius\Behat\Service\SharedStorageInterface; +use Sylius\Component\Core\Model\ShopUserInterface; use Sylius\Component\User\Repository\UserRepositoryInterface; use Webmozart\Assert\Assert; @@ -73,6 +74,7 @@ final class UserContext implements Context */ public function iDeleteAccount($email) { + /** @var ShopUserInterface $user */ $user = $this->userRepository->findOneByEmail($email); $this->sharedStorage->set('deleted_user', $user); diff --git a/src/Sylius/Behat/Page/Admin/Customer/CreatePageInterface.php b/src/Sylius/Behat/Page/Admin/Customer/CreatePageInterface.php index 5146dfe3f2..7871f274a7 100644 --- a/src/Sylius/Behat/Page/Admin/Customer/CreatePageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Customer/CreatePageInterface.php @@ -64,6 +64,11 @@ interface CreatePageInterface extends BaseCreatePageInterface */ public function hasCheckedCreateOption(); + /** + * @return bool + */ + public function hasCreateOption(); + /** * @return bool */ diff --git a/src/Sylius/Behat/Page/Admin/Order/UpdatePageInterface.php b/src/Sylius/Behat/Page/Admin/Order/UpdatePageInterface.php index 019224a324..62704471da 100644 --- a/src/Sylius/Behat/Page/Admin/Order/UpdatePageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Order/UpdatePageInterface.php @@ -27,4 +27,12 @@ interface UpdatePageInterface extends BaseUpdatePageInterface * @param AddressInterface $address */ public function specifyBillingAddress(AddressInterface $address); + + /** + * @param string $element + * @param string $message + * + * @return bool + */ + public function checkValidationMessageFor($element, $message); } diff --git a/src/Sylius/Behat/Page/Admin/ShippingCategory/CreatePageInterface.php b/src/Sylius/Behat/Page/Admin/ShippingCategory/CreatePageInterface.php index 1dd6114505..7043c33bc4 100644 --- a/src/Sylius/Behat/Page/Admin/ShippingCategory/CreatePageInterface.php +++ b/src/Sylius/Behat/Page/Admin/ShippingCategory/CreatePageInterface.php @@ -17,6 +17,16 @@ use Sylius\Behat\Page\Admin\Crud\CreatePageInterface as BaseCreatePageInteface; interface CreatePageInterface extends BaseCreatePageInteface { + /** + * @param string $code + */ + public function specifyCode($code); + + /** + * @param string $name + */ + public function nameIt($name); + /** * @param string $description */ diff --git a/src/Sylius/Behat/Page/Admin/ShippingCategory/UpdatePage.php b/src/Sylius/Behat/Page/Admin/ShippingCategory/UpdatePage.php index 247b8375b3..0e8b511439 100644 --- a/src/Sylius/Behat/Page/Admin/ShippingCategory/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/ShippingCategory/UpdatePage.php @@ -15,7 +15,6 @@ namespace Sylius\Behat\Page\Admin\ShippingCategory; use Sylius\Behat\Behaviour\ChecksCodeImmutability; use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage; -use Sylius\Behat\Page\Admin\Crud\UpdatePageInterface; class UpdatePage extends BaseUpdatePage implements UpdatePageInterface { diff --git a/src/Sylius/Behat/Page/Admin/ShippingCategory/UpdatePageInterface.php b/src/Sylius/Behat/Page/Admin/ShippingCategory/UpdatePageInterface.php new file mode 100644 index 0000000000..75359731f2 --- /dev/null +++ b/src/Sylius/Behat/Page/Admin/ShippingCategory/UpdatePageInterface.php @@ -0,0 +1,24 @@ +getCountryName($countryCode, 'en')); } - /** - * @param string $price - * - * @return int - */ - private function getPriceFromString($price): int + private function getPriceFromString(string $price): int { return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2); } diff --git a/src/Sylius/Behat/Page/Shop/Product/IndexPageInterface.php b/src/Sylius/Behat/Page/Shop/Product/IndexPageInterface.php index f3af2ccfa0..c1d81933d7 100644 --- a/src/Sylius/Behat/Page/Shop/Product/IndexPageInterface.php +++ b/src/Sylius/Behat/Page/Shop/Product/IndexPageInterface.php @@ -13,7 +13,9 @@ declare(strict_types=1); namespace Sylius\Behat\Page\Shop\Product; -interface IndexPageInterface +use Sylius\Behat\Page\PageInterface; + +interface IndexPageInterface extends PageInterface { /** * @return int diff --git a/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php b/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php index 2e2f854278..fa0d1b94dd 100644 --- a/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php +++ b/src/Sylius/Bundle/AddressingBundle/Tests/Form/Type/CountryChoiceTypeTest.php @@ -46,13 +46,17 @@ final class CountryChoiceTypeTest extends TypeTestCase { $this->countryRepository = $this->prophesize(RepositoryInterface::class); - $this->france = $this->prophesize(CountryInterface::class); - $this->france->getCode()->willReturn('FR'); - $this->france->getName()->willReturn('France'); + /** @var ProphecyInterface|CountryInterface $france */ + $france = $this->prophesize(CountryInterface::class); + $france->getCode()->willReturn('FR'); + $france->getName()->willReturn('France'); + $this->france = $france; - $this->poland = $this->prophesize(CountryInterface::class); - $this->poland->getCode()->willReturn('PL'); - $this->poland->getName()->willReturn('Poland'); + /** @var ProphecyInterface|CountryInterface $poland */ + $poland = $this->prophesize(CountryInterface::class); + $poland->getCode()->willReturn('PL'); + $poland->getName()->willReturn('Poland'); + $this->poland = $poland; parent::setUp(); } diff --git a/src/Sylius/Bundle/AddressingBundle/Validator/Constraints/ProvinceAddressConstraintValidator.php b/src/Sylius/Bundle/AddressingBundle/Validator/Constraints/ProvinceAddressConstraintValidator.php index 9f1883161e..8b1bf0d972 100644 --- a/src/Sylius/Bundle/AddressingBundle/Validator/Constraints/ProvinceAddressConstraintValidator.php +++ b/src/Sylius/Bundle/AddressingBundle/Validator/Constraints/ProvinceAddressConstraintValidator.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace Sylius\Bundle\AddressingBundle\Validator\Constraints; use Sylius\Component\Addressing\Model\AddressInterface; +use Sylius\Component\Addressing\Model\CountryInterface; +use Sylius\Component\Addressing\Model\ProvinceInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; @@ -76,7 +78,11 @@ class ProvinceAddressConstraintValidator extends ConstraintValidator protected function isProvinceValid(AddressInterface $address): bool { $countryCode = $address->getCountryCode(); - if (null === $country = $this->countryRepository->findOneBy(['code' => $countryCode])) { + + /** @var CountryInterface|null $country */ + $country = $this->countryRepository->findOneBy(['code' => $countryCode]); + + if (null === $country) { return true; } @@ -88,7 +94,10 @@ class ProvinceAddressConstraintValidator extends ConstraintValidator return false; } - if (null === $province = $this->provinceRepository->findOneBy(['code' => $address->getProvinceCode()])) { + /** @var ProvinceInterface|null $province */ + $province = $this->provinceRepository->findOneBy(['code' => $address->getProvinceCode()]); + + if (null === $province) { return false; } diff --git a/src/Sylius/Bundle/AdminBundle/Tests/Controller/NotificationControllerTest.php b/src/Sylius/Bundle/AdminBundle/Tests/Controller/NotificationControllerTest.php index 435b20592e..59b8c9e947 100644 --- a/src/Sylius/Bundle/AdminBundle/Tests/Controller/NotificationControllerTest.php +++ b/src/Sylius/Bundle/AdminBundle/Tests/Controller/NotificationControllerTest.php @@ -18,6 +18,7 @@ use GuzzleHttp\Exception\ConnectException; use Http\Message\MessageFactory; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\Prophecy\ProphecyInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; @@ -28,12 +29,12 @@ use Symfony\Component\HttpFoundation\Request; final class NotificationControllerTest extends TestCase { /** - * @var ClientInterface + * @var ProphecyInterface|ClientInterface */ private $client; /** - * @var MessageFactory + * @var ProphecyInterface|MessageFactory */ private $messageFactory; @@ -52,7 +53,7 @@ final class NotificationControllerTest extends TestCase */ public function it_returns_an_empty_json_response_upon_client_exception(): void { - $this->messageFactory->createRequest(Argument::cetera()) + $this->messageFactory->createRequest(Argument::any(), Argument::cetera()) ->willReturn($this->prophesize(RequestInterface::class)->reveal()) ; @@ -71,13 +72,15 @@ final class NotificationControllerTest extends TestCase { $content = json_encode(['version' => '9001']); - $this->messageFactory->createRequest(Argument::cetera()) + $this->messageFactory->createRequest(Argument::any(), Argument::cetera()) ->willReturn($this->prophesize(RequestInterface::class)->reveal()) ; + /** @var ProphecyInterface|StreamInterface $stream */ $stream = $this->prophesize(StreamInterface::class); $stream->getContents()->willReturn($content); + /** @var ProphecyInterface|ResponseInterface $externalResponse */ $externalResponse = $this->prophesize(ResponseInterface::class); $externalResponse->getBody()->willReturn($stream->reveal()); diff --git a/src/Sylius/Bundle/AttributeBundle/Doctrine/ORM/Subscriber/LoadMetadataSubscriber.php b/src/Sylius/Bundle/AttributeBundle/Doctrine/ORM/Subscriber/LoadMetadataSubscriber.php index eeb6a9d9dd..92f0190a5c 100644 --- a/src/Sylius/Bundle/AttributeBundle/Doctrine/ORM/Subscriber/LoadMetadataSubscriber.php +++ b/src/Sylius/Bundle/AttributeBundle/Doctrine/ORM/Subscriber/LoadMetadataSubscriber.php @@ -71,6 +71,7 @@ final class LoadMetadataSubscriber implements EventSubscriber ClassMetadataInfo $metadata, ClassMetadataFactory $metadataFactory ): void { + /** @var ClassMetadataInfo $targetEntityMetadata */ $targetEntityMetadata = $metadataFactory->getMetadataFor($subjectClass); $subjectMapping = [ 'fieldName' => 'subject', @@ -97,6 +98,7 @@ final class LoadMetadataSubscriber implements EventSubscriber ClassMetadataInfo $metadata, ClassMetadataFactory $metadataFactory ): void { + /** @var ClassMetadataInfo $attributeMetadata */ $attributeMetadata = $metadataFactory->getMetadataFor($attributeClass); $attributeMapping = [ 'fieldName' => 'attribute', diff --git a/src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php b/src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php index f809d9fb80..e077a2f11c 100644 --- a/src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php +++ b/src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php @@ -13,6 +13,7 @@ declare(strict_types=1); namespace Sylius\Bundle\CoreBundle\Command; +use Doctrine\ORM\EntityManagerInterface; use Sylius\Bundle\CoreBundle\Installer\Executor\CommandExecutor; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Helper\ProgressBar; @@ -59,7 +60,7 @@ abstract class AbstractInstallCommand extends ContainerAwareCommand */ protected function getEnvironment(): string { - return $this->get('kernel')->getEnvironment(); + return (string) $this->getContainer()->getParameter('kernel.environment'); } /** @@ -67,7 +68,7 @@ abstract class AbstractInstallCommand extends ContainerAwareCommand */ protected function isDebug(): bool { - return $this->get('kernel')->isDebug(); + return (bool) $this->getContainer()->getParameter('kernel.debug'); } /** @@ -126,7 +127,9 @@ abstract class AbstractInstallCommand extends ContainerAwareCommand // PDO does not always close the connection after Doctrine commands. // See https://github.com/symfony/symfony/issues/11750. - $this->get('doctrine')->getManager()->getConnection()->close(); + /** @var EntityManagerInterface $entityManager */ + $entityManager = $this->getContainer()->get('doctrine')->getManager(); + $entityManager->getConnection()->close(); $progress->advance(); } @@ -140,7 +143,7 @@ abstract class AbstractInstallCommand extends ContainerAwareCommand */ protected function ensureDirectoryExistsAndIsWritable(string $directory, OutputInterface $output): void { - $checker = $this->get('sylius.installer.checker.command_directory'); + $checker = $this->getContainer()->get('sylius.installer.checker.command_directory'); $checker->setCommandName($this->getName()); $checker->ensureDirectoryExists($directory, $output); diff --git a/src/Sylius/Bundle/CoreBundle/Command/CheckRequirementsCommand.php b/src/Sylius/Bundle/CoreBundle/Command/CheckRequirementsCommand.php index 88713ab0c9..13f54fec96 100644 --- a/src/Sylius/Bundle/CoreBundle/Command/CheckRequirementsCommand.php +++ b/src/Sylius/Bundle/CoreBundle/Command/CheckRequirementsCommand.php @@ -39,7 +39,7 @@ EOT */ protected function execute(InputInterface $input, OutputInterface $output): void { - $fulfilled = $this->get('sylius.installer.checker.sylius_requirements')->check($input, $output); + $fulfilled = $this->getContainer()->get('sylius.installer.checker.sylius_requirements')->check($input, $output); if (!$fulfilled) { throw new RuntimeException( diff --git a/src/Sylius/Bundle/CoreBundle/Command/InstallDatabaseCommand.php b/src/Sylius/Bundle/CoreBundle/Command/InstallDatabaseCommand.php index d2a9fde560..5423d0a3f8 100644 --- a/src/Sylius/Bundle/CoreBundle/Command/InstallDatabaseCommand.php +++ b/src/Sylius/Bundle/CoreBundle/Command/InstallDatabaseCommand.php @@ -46,6 +46,7 @@ EOT )); $commands = $this + ->getContainer() ->get('sylius.commands_provider.database_setup') ->getCommands($input, $output, $this->getHelper('question')) ; diff --git a/src/Sylius/Bundle/CoreBundle/Command/SetupCommand.php b/src/Sylius/Bundle/CoreBundle/Command/SetupCommand.php index 33b51dcc75..d96ef64219 100644 --- a/src/Sylius/Bundle/CoreBundle/Command/SetupCommand.php +++ b/src/Sylius/Bundle/CoreBundle/Command/SetupCommand.php @@ -47,9 +47,9 @@ EOT */ protected function execute(InputInterface $input, OutputInterface $output): void { - $currency = $this->get('sylius.setup.currency')->setup($input, $output, $this->getHelper('question')); - $locale = $this->get('sylius.setup.locale')->setup($input, $output); - $this->get('sylius.setup.channel')->setup($locale, $currency); + $currency = $this->getContainer()->get('sylius.setup.currency')->setup($input, $output, $this->getHelper('question')); + $locale = $this->getContainer()->get('sylius.setup.locale')->setup($input, $output); + $this->getContainer()->get('sylius.setup.channel')->setup($locale, $currency); $this->setupAdministratorUser($input, $output, $locale->getCode()); } @@ -63,8 +63,8 @@ EOT $outputStyle = new SymfonyStyle($input, $output); $outputStyle->writeln('Create your administrator account.'); - $userManager = $this->get('sylius.manager.admin_user'); - $userFactory = $this->get('sylius.factory.admin_user'); + $userManager = $this->getContainer()->get('sylius.manager.admin_user'); + $userFactory = $this->getContainer()->get('sylius.factory.admin_user'); try { $user = $this->configureNewUser($userFactory->createNew(), $input, $output); @@ -123,7 +123,7 @@ EOT return (new Question('E-mail: ')) ->setValidator(function ($value) { /** @var ConstraintViolationListInterface $errors */ - $errors = $this->get('validator')->validate((string) $value, [new Email(), new NotBlank()]); + $errors = $this->getContainer()->get('validator')->validate((string) $value, [new Email(), new NotBlank()]); foreach ($errors as $error) { throw new \DomainException($error->getMessage()); } @@ -191,7 +191,7 @@ EOT * @param InputInterface $input * @param OutputInterface $output * - * @return mixed + * @return string */ private function getAdministratorPassword(InputInterface $input, OutputInterface $output): string { @@ -221,7 +221,7 @@ EOT { return function ($value) { /** @var ConstraintViolationListInterface $errors */ - $errors = $this->get('validator')->validate($value, [new NotBlank()]); + $errors = $this->getContainer()->get('validator')->validate($value, [new NotBlank()]); foreach ($errors as $error) { throw new \DomainException($error->getMessage()); } @@ -251,6 +251,6 @@ EOT */ private function getAdminUserRepository(): UserRepositoryInterface { - return $this->get('sylius.repository.admin_user'); + return $this->getContainer()->get('sylius.repository.admin_user'); } } diff --git a/src/Sylius/Bundle/CoreBundle/Fixture/AbstractResourceFixture.php b/src/Sylius/Bundle/CoreBundle/Fixture/AbstractResourceFixture.php index 0d3d8c5cfe..278c82aafc 100644 --- a/src/Sylius/Bundle/CoreBundle/Fixture/AbstractResourceFixture.php +++ b/src/Sylius/Bundle/CoreBundle/Fixture/AbstractResourceFixture.php @@ -96,8 +96,9 @@ abstract class AbstractResourceFixture implements FixtureInterface final public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder(); - $optionsNode = $treeBuilder->root($this->getName()); + /** @var ArrayNodeDefinition $optionsNode */ + $optionsNode = $treeBuilder->root($this->getName()); $optionsNode->children()->integerNode('random')->min(0)->defaultValue(0); /** @var ArrayNodeDefinition $resourcesNode */ diff --git a/src/Sylius/Bundle/CoreBundle/Fixture/OrderFixture.php b/src/Sylius/Bundle/CoreBundle/Fixture/OrderFixture.php index 7b6825260b..889b6f27e8 100644 --- a/src/Sylius/Bundle/CoreBundle/Fixture/OrderFixture.php +++ b/src/Sylius/Bundle/CoreBundle/Fixture/OrderFixture.php @@ -20,6 +20,7 @@ use Sylius\Component\Core\Checker\OrderPaymentMethodSelectionRequirementCheckerI use Sylius\Component\Core\Checker\OrderShippingMethodSelectionRequirementCheckerInterface; use Sylius\Component\Core\Model\AddressInterface; use Sylius\Component\Core\Model\OrderInterface; +use Sylius\Component\Core\Model\OrderItemInterface; use Sylius\Component\Core\OrderCheckoutTransitions; use Sylius\Component\Core\Repository\PaymentMethodRepositoryInterface; use Sylius\Component\Core\Repository\ShippingMethodRepositoryInterface; @@ -225,6 +226,7 @@ class OrderFixture extends AbstractFixture $products = $this->productRepository->findAll(); for ($i = 0; $i < $numberOfItems; ++$i) { + /** @var OrderItemInterface $item */ $item = $this->orderItemFactory->createNew(); $product = $this->faker->randomElement($products); diff --git a/src/Sylius/Bundle/CoreBundle/Form/DataTransformer/ProductTaxonToTaxonTransformer.php b/src/Sylius/Bundle/CoreBundle/Form/DataTransformer/ProductTaxonToTaxonTransformer.php index ec51d4ad65..f7d4d9d77e 100644 --- a/src/Sylius/Bundle/CoreBundle/Form/DataTransformer/ProductTaxonToTaxonTransformer.php +++ b/src/Sylius/Bundle/CoreBundle/Form/DataTransformer/ProductTaxonToTaxonTransformer.php @@ -82,6 +82,7 @@ final class ProductTaxonToTaxonTransformer implements DataTransformerInterface $productTaxon = $this->productTaxonRepository->findOneBy(['taxon' => $taxon, 'product' => $this->product]); if (null === $productTaxon) { + /** @var ProductTaxonInterface $productTaxon */ $productTaxon = $this->productTaxonFactory->createNew(); $productTaxon->setProduct($this->product); $productTaxon->setTaxon($taxon); diff --git a/src/Sylius/Bundle/CoreBundle/Form/EventSubscriber/CustomerRegistrationFormSubscriber.php b/src/Sylius/Bundle/CoreBundle/Form/EventSubscriber/CustomerRegistrationFormSubscriber.php index dde96b38da..7c7e82a1f0 100644 --- a/src/Sylius/Bundle/CoreBundle/Form/EventSubscriber/CustomerRegistrationFormSubscriber.php +++ b/src/Sylius/Bundle/CoreBundle/Form/EventSubscriber/CustomerRegistrationFormSubscriber.php @@ -13,7 +13,7 @@ declare(strict_types=1); namespace Sylius\Bundle\CoreBundle\Form\EventSubscriber; -use Sylius\Component\Customer\Model\CustomerInterface; +use Sylius\Component\Core\Model\CustomerInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\FormEvent; @@ -62,6 +62,8 @@ final class CustomerRegistrationFormSubscriber implements EventSubscriberInterfa if (!isset($rawData['email']) || empty($rawData['email'])) { return; } + + /** @var CustomerInterface|null $existingCustomer */ $existingCustomer = $this->customerRepository->findOneBy(['email' => $rawData['email']]); if (null === $existingCustomer || null !== $existingCustomer->getUser()) { return; diff --git a/src/Sylius/Bundle/CoreBundle/Form/Type/Customer/CustomerGuestType.php b/src/Sylius/Bundle/CoreBundle/Form/Type/Customer/CustomerGuestType.php index 721d042f63..53813b89b9 100644 --- a/src/Sylius/Bundle/CoreBundle/Form/Type/Customer/CustomerGuestType.php +++ b/src/Sylius/Bundle/CoreBundle/Form/Type/Customer/CustomerGuestType.php @@ -79,6 +79,7 @@ final class CustomerGuestType extends AbstractResourceType return; } + /** @var CustomerInterface $customer */ $customer = $this->customerFactory->createNew(); $customer->setEmail($data['email']); diff --git a/src/Sylius/Bundle/CoreBundle/Installer/Provider/DatabaseSetupCommandsProvider.php b/src/Sylius/Bundle/CoreBundle/Installer/Provider/DatabaseSetupCommandsProvider.php index b8f0fe1d37..ae43a2f69e 100644 --- a/src/Sylius/Bundle/CoreBundle/Installer/Provider/DatabaseSetupCommandsProvider.php +++ b/src/Sylius/Bundle/CoreBundle/Installer/Provider/DatabaseSetupCommandsProvider.php @@ -15,6 +15,7 @@ namespace Sylius\Bundle\CoreBundle\Installer\Provider; use Doctrine\Bundle\DoctrineBundle\Registry; use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -152,7 +153,7 @@ final class DatabaseSetupCommandsProvider implements DatabaseSetupCommandsProvid */ private function getDatabaseName(): string { - return $this->doctrineRegistry->getManager()->getConnection()->getDatabase(); + return $this->getEntityManager()->getConnection()->getDatabase(); } /** @@ -160,6 +161,11 @@ final class DatabaseSetupCommandsProvider implements DatabaseSetupCommandsProvid */ private function getSchemaManager(): AbstractSchemaManager { - return $this->doctrineRegistry->getManager()->getConnection()->getSchemaManager(); + return $this->getEntityManager()->getConnection()->getSchemaManager(); + } + + private function getEntityManager(): EntityManagerInterface + { + return $this->doctrineRegistry->getManager(); } } diff --git a/src/Sylius/Bundle/CoreBundle/Installer/Requirement/ExtensionsRequirements.php b/src/Sylius/Bundle/CoreBundle/Installer/Requirement/ExtensionsRequirements.php index e263e0e8fd..9bbc4cb3f8 100644 --- a/src/Sylius/Bundle/CoreBundle/Installer/Requirement/ExtensionsRequirements.php +++ b/src/Sylius/Bundle/CoreBundle/Installer/Requirement/ExtensionsRequirements.php @@ -61,7 +61,7 @@ final class ExtensionsRequirements extends RequirementCollection )) ->add(new Requirement( $translator->trans('sylius.installer.extensions.pcre', []), - defined('PCRE_VERSION') ? ((float) PCRE_VERSION) > 8.0 : false, + defined('PCRE_VERSION') ? ((float) substr(PCRE_VERSION, 0, strpos(PCRE_VERSION, ' '))) > 8.0 : false, true, $translator->trans('sylius.installer.extensions.help', ['%extension%' => 'PCRE (>=8.0)']) )) diff --git a/src/Sylius/Bundle/CoreBundle/OAuth/UserProvider.php b/src/Sylius/Bundle/CoreBundle/OAuth/UserProvider.php index 8a3eaca6fd..546a65eddd 100644 --- a/src/Sylius/Bundle/CoreBundle/OAuth/UserProvider.php +++ b/src/Sylius/Bundle/CoreBundle/OAuth/UserProvider.php @@ -27,6 +27,7 @@ use Sylius\Component\User\Canonicalizer\CanonicalizerInterface; use Sylius\Component\User\Model\UserOAuthInterface; use Sylius\Component\User\Repository\UserRepositoryInterface; use Symfony\Component\Security\Core\User\UserInterface; +use Webmozart\Assert\Assert; /** * Loading and ad-hoc creation of a user by an OAuth sign-in provider account. @@ -184,17 +185,20 @@ class UserProvider extends BaseUserProvider implements AccountConnectorInterface * @param UserInterface $user * @param UserResponseInterface $response * - * @return UserInterface + * @return SyliusUserInterface */ - private function updateUserByOAuthUserResponse(UserInterface $user, UserResponseInterface $response): UserInterface + private function updateUserByOAuthUserResponse(UserInterface $user, UserResponseInterface $response): SyliusUserInterface { + /** @var SyliusUserInterface $user */ + Assert::isInstanceOf($user, SyliusUserInterface::class); + + /** @var UserOAuthInterface $oauth */ $oauth = $this->oauthFactory->createNew(); $oauth->setIdentifier($response->getUsername()); $oauth->setProvider($response->getResourceOwner()->getName()); $oauth->setAccessToken($response->getAccessToken()); $oauth->setRefreshToken($response->getRefreshToken()); - /** @var SyliusUserInterface $user */ $user->addOAuthAccount($oauth); $this->userManager->persist($user); diff --git a/src/Sylius/Bundle/CoreBundle/Order/NumberGenerator/SequentialOrderNumberGenerator.php b/src/Sylius/Bundle/CoreBundle/Order/NumberGenerator/SequentialOrderNumberGenerator.php index 747c084c41..7f16466498 100644 --- a/src/Sylius/Bundle/CoreBundle/Order/NumberGenerator/SequentialOrderNumberGenerator.php +++ b/src/Sylius/Bundle/CoreBundle/Order/NumberGenerator/SequentialOrderNumberGenerator.php @@ -16,8 +16,8 @@ namespace Sylius\Bundle\CoreBundle\Order\NumberGenerator; use Doctrine\DBAL\LockMode; use Doctrine\ORM\EntityManagerInterface; use Sylius\Bundle\OrderBundle\NumberGenerator\OrderNumberGeneratorInterface; +use Sylius\Component\Core\Model\OrderSequenceInterface; use Sylius\Component\Order\Model\OrderInterface; -use Sylius\Component\Order\Model\OrderSequenceInterface; use Sylius\Component\Resource\Factory\FactoryInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; @@ -108,6 +108,7 @@ final class SequentialOrderNumberGenerator implements OrderNumberGeneratorInterf return $sequence; } + /** @var OrderSequenceInterface $sequence */ $sequence = $this->sequenceFactory->createNew(); $this->sequenceManager->persist($sequence); diff --git a/src/Sylius/Bundle/CoreBundle/Tests/Form/Type/Taxon/ProductTaxonAutocompleteChoiceTypeTest.php b/src/Sylius/Bundle/CoreBundle/Tests/Form/Type/Taxon/ProductTaxonAutocompleteChoiceTypeTest.php index 63c45ddb93..6f6bc919d8 100644 --- a/src/Sylius/Bundle/CoreBundle/Tests/Form/Type/Taxon/ProductTaxonAutocompleteChoiceTypeTest.php +++ b/src/Sylius/Bundle/CoreBundle/Tests/Form/Type/Taxon/ProductTaxonAutocompleteChoiceTypeTest.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Sylius\Bundle\CoreBundle\Tests\Form\Type\Taxon; use Doctrine\Common\Collections\ArrayCollection; +use Prophecy\Prophecy\ObjectProphecy; use Sylius\Bundle\CoreBundle\Form\Type\Taxon\ProductTaxonAutocompleteChoiceType; use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType; use Sylius\Component\Core\Model\ProductInterface; @@ -29,17 +30,17 @@ use Symfony\Component\Form\Test\TypeTestCase; final class ProductTaxonAutocompleteChoiceTypeTest extends TypeTestCase { /** - * @var ServiceRegistryInterface + * @var ObjectProphecy|ServiceRegistryInterface */ private $resourceRepositoryRegistry; /** - * @var FactoryInterface + * @var ObjectProphecy|FactoryInterface */ private $productTaxonFactory; /** - * @var RepositoryInterface + * @var ObjectProphecy|RepositoryInterface */ private $productTaxonRepository; @@ -73,6 +74,7 @@ final class ProductTaxonAutocompleteChoiceTypeTest extends TypeTestCase $taxon = $this->prophesize(TaxonInterface::class); $product = $this->prophesize(ProductInterface::class); + /** @var ObjectProphecy|TaxonRepositoryInterface $taxonRepository */ $taxonRepository = $this->prophesize(TaxonRepositoryInterface::class); $this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository); @@ -102,6 +104,8 @@ final class ProductTaxonAutocompleteChoiceTypeTest extends TypeTestCase $taxon = $this->prophesize(TaxonInterface::class); $product = $this->prophesize(ProductInterface::class); $productTaxon = $this->prophesize(ProductTaxonInterface::class); + + /** @var ObjectProphecy|TaxonRepositoryInterface $taxonRepository */ $taxonRepository = $this->prophesize(TaxonRepositoryInterface::class); $this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository); @@ -126,6 +130,8 @@ final class ProductTaxonAutocompleteChoiceTypeTest extends TypeTestCase { $taxon = $this->prophesize(TaxonInterface::class); $product = $this->prophesize(ProductInterface::class); + + /** @var ObjectProphecy|TaxonRepositoryInterface $taxonRepository */ $taxonRepository = $this->prophesize(TaxonRepositoryInterface::class); $this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository); @@ -155,6 +161,7 @@ final class ProductTaxonAutocompleteChoiceTypeTest extends TypeTestCase $product = $this->prophesize(ProductInterface::class); $productTaxon = $this->prophesize(ProductTaxonInterface::class); + /** @var ObjectProphecy|TaxonRepositoryInterface $taxonRepository */ $taxonRepository = $this->prophesize(TaxonRepositoryInterface::class); $this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository); diff --git a/src/Sylius/Bundle/CoreBundle/Validator/Constraints/RegisteredUserValidator.php b/src/Sylius/Bundle/CoreBundle/Validator/Constraints/RegisteredUserValidator.php index 77a1955fae..65652ddc58 100644 --- a/src/Sylius/Bundle/CoreBundle/Validator/Constraints/RegisteredUserValidator.php +++ b/src/Sylius/Bundle/CoreBundle/Validator/Constraints/RegisteredUserValidator.php @@ -45,6 +45,7 @@ final class RegisteredUserValidator extends ConstraintValidator /** @var RegisteredUser $constraint */ Assert::isInstanceOf($constraint, RegisteredUser::class); + /** @var CustomerInterface|null $existingCustomer */ $existingCustomer = $this->customerRepository->findOneBy(['email' => $customer->getEmail()]); if (null !== $existingCustomer && null !== $existingCustomer->getUser()) { $this->context->buildViolation($constraint->message)->atPath('email')->addViolation(); diff --git a/src/Sylius/Bundle/PayumBundle/Controller/PayumController.php b/src/Sylius/Bundle/PayumBundle/Controller/PayumController.php index 74f2da3ab9..9f165e0e54 100644 --- a/src/Sylius/Bundle/PayumBundle/Controller/PayumController.php +++ b/src/Sylius/Bundle/PayumBundle/Controller/PayumController.php @@ -16,6 +16,8 @@ namespace Sylius\Bundle\PayumBundle\Controller; use FOS\RestBundle\View\View; use Payum\Core\Model\GatewayConfigInterface; use Payum\Core\Payum; +use Payum\Core\Request\Generic; +use Payum\Core\Request\GetStatusInterface; use Payum\Core\Security\GenericTokenFactoryInterface; use Payum\Core\Security\HttpRequestVerifierInterface; use Payum\Core\Security\TokenInterface; @@ -24,12 +26,14 @@ use Sylius\Bundle\PayumBundle\Factory\ResolveNextRouteFactoryInterface; use Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationFactoryInterface; use Sylius\Bundle\ResourceBundle\Controller\ViewHandlerInterface; use Sylius\Component\Core\Model\OrderInterface; +use Sylius\Component\Core\Model\PaymentInterface; +use Sylius\Component\Core\Model\PaymentMethodInterface; use Sylius\Component\Order\Repository\OrderRepositoryInterface; -use Sylius\Component\Payment\Model\PaymentInterface; use Sylius\Component\Resource\Metadata\MetadataInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\RouterInterface; @@ -124,15 +128,19 @@ final class PayumController $token = $this->getHttpRequestVerifier()->verify($request); + /** @var Generic|GetStatusInterface $status */ $status = $this->getStatusRequestFactory->createNewWithModel($token); $this->payum->getGateway($token->getGatewayName())->execute($status); + $resolveNextRoute = $this->resolveNextRouteRequestFactory->createNewWithModel($status->getFirstModel()); $this->payum->getGateway($token->getGatewayName())->execute($resolveNextRoute); $this->getHttpRequestVerifier()->invalidate($token); if (PaymentInterface::STATE_NEW !== $status->getValue()) { - $request->getSession()->getBag('flashes')->add('info', sprintf('sylius.payment.%s', $status->getValue())); + /** @var FlashBagInterface $flashBag */ + $flashBag = $request->getSession()->getBag('flashes'); + $flashBag->add('info', sprintf('sylius.payment.%s', $status->getValue())); } return $this->viewHandler->handle( @@ -153,8 +161,11 @@ final class PayumController private function provideTokenBasedOnPayment(PaymentInterface $payment, array $redirectOptions): TokenInterface { + /** @var PaymentMethodInterface $paymentMethod */ + $paymentMethod = $payment->getMethod(); + /** @var GatewayConfigInterface $gatewayConfig */ - $gatewayConfig = $payment->getMethod()->getGatewayConfig(); + $gatewayConfig = $paymentMethod->getGatewayConfig(); if (isset($gatewayConfig->getConfig()['use_authorize']) && $gatewayConfig->getConfig()['use_authorize'] == true) { $token = $this->getTokenFactory()->createAuthorizeToken( diff --git a/src/Sylius/Bundle/ResourceBundle/Form/Type/DefaultResourceType.php b/src/Sylius/Bundle/ResourceBundle/Form/Type/DefaultResourceType.php index d757b23611..9fd63015e0 100644 --- a/src/Sylius/Bundle/ResourceBundle/Form/Type/DefaultResourceType.php +++ b/src/Sylius/Bundle/ResourceBundle/Form/Type/DefaultResourceType.php @@ -13,6 +13,7 @@ declare(strict_types=1); namespace Sylius\Bundle\ResourceBundle\Form\Type; +use Sylius\Bundle\ResourceBundle\Form\Builder\DefaultFormBuilderInterface; use Sylius\Component\Registry\ServiceRegistryInterface; use Sylius\Component\Resource\Metadata\RegistryInterface; use Symfony\Component\Form\AbstractType; @@ -46,6 +47,8 @@ final class DefaultResourceType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { $metadata = $this->metadataRegistry->getByClass($options['data_class']); + + /** @var DefaultFormBuilderInterface $formBuilder */ $formBuilder = $this->formBuilderRegistry->get($metadata->getDriver()); $formBuilder->build($metadata, $builder, $options); diff --git a/src/Sylius/Bundle/ResourceBundle/Grid/Renderer/TwigBulkActionGridRenderer.php b/src/Sylius/Bundle/ResourceBundle/Grid/Renderer/TwigBulkActionGridRenderer.php index f81023b967..e65e426dec 100644 --- a/src/Sylius/Bundle/ResourceBundle/Grid/Renderer/TwigBulkActionGridRenderer.php +++ b/src/Sylius/Bundle/ResourceBundle/Grid/Renderer/TwigBulkActionGridRenderer.php @@ -14,9 +14,11 @@ declare(strict_types=1); namespace Sylius\Bundle\ResourceBundle\Grid\Renderer; use Sylius\Bundle\ResourceBundle\Grid\Parser\OptionsParserInterface; +use Sylius\Bundle\ResourceBundle\Grid\View\ResourceGridView; use Sylius\Component\Grid\Definition\Action; use Sylius\Component\Grid\Renderer\BulkActionGridRendererInterface; use Sylius\Component\Grid\View\GridViewInterface; +use Webmozart\Assert\Assert; final class TwigBulkActionGridRenderer implements BulkActionGridRendererInterface { @@ -55,6 +57,9 @@ final class TwigBulkActionGridRenderer implements BulkActionGridRendererInterfac */ public function renderBulkAction(GridViewInterface $gridView, Action $bulkAction, $data = null): string { + /** @var ResourceGridView $gridView */ + Assert::isInstanceOf($gridView, ResourceGridView::class); + $type = $bulkAction->getType(); if (!isset($this->bulkActionTemplates[$type])) { throw new \InvalidArgumentException(sprintf('Missing template for bulk action type "%s".', $type)); diff --git a/src/Sylius/Bundle/ResourceBundle/Grid/Renderer/TwigGridRenderer.php b/src/Sylius/Bundle/ResourceBundle/Grid/Renderer/TwigGridRenderer.php index b1f10ab966..be28dc0863 100644 --- a/src/Sylius/Bundle/ResourceBundle/Grid/Renderer/TwigGridRenderer.php +++ b/src/Sylius/Bundle/ResourceBundle/Grid/Renderer/TwigGridRenderer.php @@ -14,11 +14,13 @@ declare(strict_types=1); namespace Sylius\Bundle\ResourceBundle\Grid\Renderer; use Sylius\Bundle\ResourceBundle\Grid\Parser\OptionsParserInterface; +use Sylius\Bundle\ResourceBundle\Grid\View\ResourceGridView; use Sylius\Component\Grid\Definition\Action; use Sylius\Component\Grid\Definition\Field; use Sylius\Component\Grid\Definition\Filter; use Sylius\Component\Grid\Renderer\GridRendererInterface; use Sylius\Component\Grid\View\GridViewInterface; +use Webmozart\Assert\Assert; final class TwigGridRenderer implements GridRendererInterface { @@ -81,6 +83,9 @@ final class TwigGridRenderer implements GridRendererInterface */ public function renderAction(GridViewInterface $gridView, Action $action, $data = null): string { + /** @var ResourceGridView $gridView */ + Assert::isInstanceOf($gridView, ResourceGridView::class); + $type = $action->getType(); if (!isset($this->actionTemplates[$type])) { throw new \InvalidArgumentException(sprintf('Missing template for action type "%s".', $type)); diff --git a/src/Sylius/Bundle/ResourceBundle/Routing/Configuration.php b/src/Sylius/Bundle/ResourceBundle/Routing/Configuration.php index 9b5419e7b8..5370c3347a 100644 --- a/src/Sylius/Bundle/ResourceBundle/Routing/Configuration.php +++ b/src/Sylius/Bundle/ResourceBundle/Routing/Configuration.php @@ -13,6 +13,7 @@ declare(strict_types=1); namespace Sylius\Bundle\ResourceBundle\Routing; +use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -24,6 +25,8 @@ final class Configuration implements ConfigurationInterface public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder(); + + /** @var ArrayNodeDefinition $rootNode */ $rootNode = $treeBuilder->root('routing'); $rootNode diff --git a/src/Sylius/Bundle/ResourceBundle/Tests/Command/DebugResourceCommandTest.php b/src/Sylius/Bundle/ResourceBundle/Tests/Command/DebugResourceCommandTest.php index 60438aff92..fa9ab6aa6c 100644 --- a/src/Sylius/Bundle/ResourceBundle/Tests/Command/DebugResourceCommandTest.php +++ b/src/Sylius/Bundle/ResourceBundle/Tests/Command/DebugResourceCommandTest.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Sylius\Bundle\ResourceBundle\Tests\Command; use PHPUnit\Framework\TestCase; +use Prophecy\Prophecy\ObjectProphecy; use Sylius\Bundle\ResourceBundle\Command\DebugResourceCommand; use Sylius\Component\Resource\Metadata\Metadata; use Sylius\Component\Resource\Metadata\MetadataInterface; @@ -23,7 +24,7 @@ use Symfony\Component\Console\Tester\CommandTester; final class DebugResourceCommandTest extends TestCase { /** - * @var RegistryInterface + * @var ObjectProphecy|RegistryInterface */ private $registry; diff --git a/src/Sylius/Bundle/ResourceBundle/Tests/Form/Type/ResourceAutocompleteChoiceTypeTest.php b/src/Sylius/Bundle/ResourceBundle/Tests/Form/Type/ResourceAutocompleteChoiceTypeTest.php index 46993b9ab9..75bee2effc 100644 --- a/src/Sylius/Bundle/ResourceBundle/Tests/Form/Type/ResourceAutocompleteChoiceTypeTest.php +++ b/src/Sylius/Bundle/ResourceBundle/Tests/Form/Type/ResourceAutocompleteChoiceTypeTest.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Sylius\Bundle\ResourceBundle\Tests\Form\Type; use Doctrine\Common\Collections\ArrayCollection; +use Prophecy\Prophecy\ObjectProphecy; use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType; use Sylius\Component\Registry\ServiceRegistryInterface; use Sylius\Component\Resource\Model\ResourceInterface; @@ -26,7 +27,7 @@ use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase { /** - * @var ServiceRegistryInterface + * @var ObjectProphecy|ServiceRegistryInterface */ private $resourceRepositoryRegistry; @@ -51,6 +52,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase */ public function it_returns_resource_from_its_code(): void { + /** @var ObjectProphecy|RepositoryInterface $resourceRepository */ $resourceRepository = $this->prophesize(RepositoryInterface::class); $resource = $this->prophesize(ResourceInterface::class); @@ -73,6 +75,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase */ public function it_returns_resource_from_its_id(): void { + /** @var ObjectProphecy|RepositoryInterface $resourceRepository */ $resourceRepository = $this->prophesize(RepositoryInterface::class); $resource = $this->prophesize(ResourceInterface::class); @@ -95,6 +98,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase */ public function it_returns_different_resource_from_its_identifier(): void { + /** @var ObjectProphecy|RepositoryInterface $resourceRepository */ $resourceRepository = $this->prophesize(RepositoryInterface::class); $resource = $this->prophesize(ResourceInterface::class); @@ -117,6 +121,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase */ public function it_has_identifier_as_view_value(): void { + /** @var ObjectProphecy|RepositoryInterface $resourceRepository */ $resourceRepository = $this->prophesize(RepositoryInterface::class); $resource = $this->prophesize(ResourceInterface::class); @@ -139,6 +144,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase */ public function it_has_different_view_based_on_passed_configuration(): void { + /** @var ObjectProphecy|RepositoryInterface $resourceRepository */ $resourceRepository = $this->prophesize(RepositoryInterface::class); $resource = $this->prophesize(ResourceInterface::class); @@ -162,6 +168,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase */ public function it_returns_collection_of_resources_from_identifiers(): void { + /** @var ObjectProphecy|RepositoryInterface $resourceRepository */ $resourceRepository = $this->prophesize(RepositoryInterface::class); $mug = $this->prophesize(ResourceInterface::class); $book = $this->prophesize(ResourceInterface::class); diff --git a/src/Sylius/Bundle/ThemeBundle/Configuration/ThemeConfiguration.php b/src/Sylius/Bundle/ThemeBundle/Configuration/ThemeConfiguration.php index df59b167af..81b7bc0e05 100644 --- a/src/Sylius/Bundle/ThemeBundle/Configuration/ThemeConfiguration.php +++ b/src/Sylius/Bundle/ThemeBundle/Configuration/ThemeConfiguration.php @@ -25,8 +25,9 @@ final class ThemeConfiguration implements ConfigurationInterface public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder(); - $rootNodeDefinition = $treeBuilder->root('sylius_theme'); + /** @var ArrayNodeDefinition $rootNodeDefinition */ + $rootNodeDefinition = $treeBuilder->root('sylius_theme'); $rootNodeDefinition->ignoreExtraKeys(); $this->addRequiredNameField($rootNodeDefinition); diff --git a/src/Sylius/Component/Core/Model/Order.php b/src/Sylius/Component/Core/Model/Order.php index b3545a89c6..0dade5187e 100644 --- a/src/Sylius/Component/Core/Model/Order.php +++ b/src/Sylius/Component/Core/Model/Order.php @@ -30,7 +30,7 @@ use Webmozart\Assert\Assert; class Order extends BaseOrder implements OrderInterface { /** - * @var BaseCustomerInterface + * @var CustomerInterface */ protected $customer; @@ -126,6 +126,8 @@ class Order extends BaseOrder implements OrderInterface */ public function setCustomer(?BaseCustomerInterface $customer): void { + Assert::isInstanceOf($customer, CustomerInterface::class); + $this->customer = $customer; } @@ -270,6 +272,8 @@ class Order extends BaseOrder implements OrderInterface public function addPayment(BasePaymentInterface $payment): void { /** @var PaymentInterface $payment */ + Assert::isInstanceOf($payment, PaymentInterface::class); + if (!$this->hasPayment($payment)) { $this->payments->add($payment); $payment->setOrder($this); @@ -282,6 +286,8 @@ class Order extends BaseOrder implements OrderInterface public function removePayment(BasePaymentInterface $payment): void { /** @var PaymentInterface $payment */ + Assert::isInstanceOf($payment, PaymentInterface::class); + if ($this->hasPayment($payment)) { $this->payments->removeElement($payment); $payment->setOrder(null); diff --git a/src/Sylius/Component/Core/spec/Model/OrderSpec.php b/src/Sylius/Component/Core/spec/Model/OrderSpec.php index 24a6f1c190..500c539cfc 100644 --- a/src/Sylius/Component/Core/spec/Model/OrderSpec.php +++ b/src/Sylius/Component/Core/spec/Model/OrderSpec.php @@ -18,13 +18,13 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Channel\Model\ChannelInterface; use Sylius\Component\Core\Model\AddressInterface; use Sylius\Component\Core\Model\AdjustmentInterface; +use Sylius\Component\Core\Model\CustomerInterface; use Sylius\Component\Core\Model\OrderItemInterface; use Sylius\Component\Core\Model\PaymentInterface; use Sylius\Component\Core\Model\PromotionInterface; use Sylius\Component\Core\Model\ShipmentInterface; use Sylius\Component\Core\OrderCheckoutStates; use Sylius\Component\Core\OrderShippingStates; -use Sylius\Component\Customer\Model\CustomerInterface; use Sylius\Component\Order\Model\Order as BaseOrder; use Sylius\Component\Order\Model\OrderInterface; use Sylius\Component\Promotion\Model\PromotionCouponInterface;