diff --git a/app/code/Magento/AdvancedSearch/Model/Recommendations/DataProvider.php b/app/code/Magento/AdvancedSearch/Model/Recommendations/DataProvider.php index 546983bb5e5a8..c0c224766eb3c 100644 --- a/app/code/Magento/AdvancedSearch/Model/Recommendations/DataProvider.php +++ b/app/code/Magento/AdvancedSearch/Model/Recommendations/DataProvider.php @@ -10,6 +10,9 @@ use Magento\Search\Model\QueryInterface; use Magento\AdvancedSearch\Model\SuggestedQueriesInterface; +/** + * Class DataProvider + */ class DataProvider implements SuggestedQueriesInterface { /** @@ -51,6 +54,8 @@ class DataProvider implements SuggestedQueriesInterface private $recommendationsFactory; /** + * DataProvider constructor. + * * @param ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Layer\Resolver $layerResolver * @param \Magento\AdvancedSearch\Model\ResourceModel\RecommendationsFactory $recommendationsFactory @@ -69,18 +74,20 @@ public function __construct( } /** + * Is Results Count Enabled + * * @return bool */ public function isResultsCountEnabled() { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::CONFIG_RESULTS_COUNT_ENABLED, ScopeInterface::SCOPE_STORE ); } /** - * {@inheritdoc} + * @inheritdoc */ public function getItems(QueryInterface $query) { @@ -102,6 +109,8 @@ public function getItems(QueryInterface $query) } /** + * Return Search Recommendations + * * @param QueryInterface $query * @return array */ @@ -126,17 +135,21 @@ private function getSearchRecommendations(\Magento\Search\Model\QueryInterface $ } /** + * Is Search Recommendations Enabled + * * @return bool */ private function isSearchRecommendationsEnabled() { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::CONFIG_IS_ENABLED, ScopeInterface::SCOPE_STORE ); } /** + * Return Search Recommendations Count + * * @return int */ private function getSearchRecommendationsCount() diff --git a/app/code/Magento/CatalogInventory/Model/Configuration.php b/app/code/Magento/CatalogInventory/Model/Configuration.php index 2f0415b40dc01..8b0849c8874bc 100644 --- a/app/code/Magento/CatalogInventory/Model/Configuration.php +++ b/app/code/Magento/CatalogInventory/Model/Configuration.php @@ -9,6 +9,7 @@ use Magento\CatalogInventory\Helper\Minsaleqty as MinsaleqtyHelper; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Catalog\Model\ProductTypes\ConfigInterface; +use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; /** @@ -131,6 +132,8 @@ class Configuration implements StockConfigurationInterface protected $storeManager; /** + * Configuration constructor. + * * @param ConfigInterface $config * @param ScopeConfigInterface $scopeConfig * @param MinsaleqtyHelper $minsaleqtyHelper @@ -149,7 +152,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function getDefaultScopeId() { @@ -159,6 +162,8 @@ public function getDefaultScopeId() } /** + * Is Qty Type Ids + * * @param int|null $filter * @return array */ @@ -182,6 +187,8 @@ public function getIsQtyTypeIds($filter = null) } /** + * Is Qty + * * @param int $productTypeId * @return bool */ @@ -201,12 +208,14 @@ public function canSubtractQty($store = null) { return $this->scopeConfig->isSetFlag( self::XML_PATH_CAN_SUBTRACT, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } /** + * Get Min Qty + * * @param null|string|bool|int|\Magento\Store\Model\Store $store * @return float */ @@ -214,12 +223,14 @@ public function getMinQty($store = null) { return (float)$this->scopeConfig->getValue( self::XML_PATH_MIN_QTY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } /** + * Get Min Sale Qty + * * @param null|string|bool|int|\Magento\Store\Model\Store $store * @param int $customerGroupId * @return float @@ -230,6 +241,8 @@ public function getMinSaleQty($store = null, $customerGroupId = null) } /** + * Get Max Sale Qty + * * @param null|string|bool|int|\Magento\Store\Model\Store $store * @return float|null */ @@ -237,12 +250,14 @@ public function getMaxSaleQty($store = null) { return (float)$this->scopeConfig->getValue( self::XML_PATH_MAX_SALE_QTY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } /** + * Get Notify Stock Qty + * * @param null|string|bool|int|\Magento\Store\Model\Store $store * @return float */ @@ -250,7 +265,7 @@ public function getNotifyStockQty($store = null) { return (float) $this->scopeConfig->getValue( self::XML_PATH_NOTIFY_STOCK_QTY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } @@ -264,14 +279,16 @@ public function getNotifyStockQty($store = null) */ public function getEnableQtyIncrements($store = null) { - return (bool) $this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::XML_PATH_ENABLE_QTY_INCREMENTS, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } /** + * Get Qty Increments + * * @param null|string|bool|int|\Magento\Store\Model\Store $store * @return float */ @@ -279,7 +296,7 @@ public function getQtyIncrements($store = null) { return (float)$this->scopeConfig->getValue( self::XML_PATH_QTY_INCREMENTS, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } @@ -294,7 +311,7 @@ public function getBackorders($store = null) { return (int) $this->scopeConfig->getValue( self::XML_PATH_BACKORDERS, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } @@ -309,7 +326,7 @@ public function getManageStock($store = null) { return (int) $this->scopeConfig->isSetFlag( self::XML_PATH_MANAGE_STOCK, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } @@ -325,7 +342,7 @@ public function getCanBackInStock($store = null) { return $this->scopeConfig->isSetFlag( self::XML_PATH_CAN_BACK_IN_STOCK, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } @@ -340,7 +357,7 @@ public function isShowOutOfStock($store = null) { return $this->scopeConfig->isSetFlag( self::XML_PATH_SHOW_OUT_OF_STOCK, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } @@ -355,14 +372,13 @@ public function isAutoReturnEnabled($store = null) { return $this->scopeConfig->isSetFlag( self::XML_PATH_ITEM_AUTO_RETURN, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } /** - * Get 'Display product stock status' option value - * Shows if it is necessary to show product stock status ('in stock'/'out of stock') + * Display product stock status. Shows if it is necessary to show product stock status in stock/out of stock. * * @param null|string|bool|int|\Magento\Store\Model\Store $store * @return bool @@ -371,12 +387,14 @@ public function isDisplayProductStockStatus($store = null) { return $this->scopeConfig->isSetFlag( self::XML_PATH_DISPLAY_PRODUCT_STOCK_STATUS, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } /** + * Get Default Config Value + * * @param string $field * @param null|string|bool|int|\Magento\Store\Model\Store $store * @return string|null @@ -385,12 +403,14 @@ public function getDefaultConfigValue($field, $store = null) { return $this->scopeConfig->getValue( self::XML_PATH_ITEM . $field, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } /** + * Get Stock Threshold Qty + * * @param null|string|bool|int|\Magento\Store\Model\Store $store * @return string|null */ @@ -398,7 +418,7 @@ public function getStockThresholdQty($store = null) { return $this->scopeConfig->getValue( self::XML_PATH_STOCK_THRESHOLD_QTY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php index d2779b79b30d7..cefc4ada7d212 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php @@ -144,7 +144,7 @@ public function testGetEnableQtyIncrements() $store = 1; $this->scopeConfigMock->expects($this->once()) - ->method('getValue') + ->method('isSetFlag') ->with( Configuration::XML_PATH_ENABLE_QTY_INCREMENTS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, diff --git a/app/code/Magento/Checkout/Helper/Data.php b/app/code/Magento/Checkout/Helper/Data.php index 0f2326d37c1ad..40bdf93d161ed 100644 --- a/app/code/Magento/Checkout/Helper/Data.php +++ b/app/code/Magento/Checkout/Helper/Data.php @@ -59,6 +59,8 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper private $paymentFailures; /** + * Data constructor. + * * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Checkout\Model\Session $checkoutSession @@ -113,6 +115,8 @@ public function getQuote() } /** + * Format Price + * * @param float $price * @return string */ @@ -127,6 +131,8 @@ public function formatPrice($price) } /** + * Convert Price + * * @param float $price * @param bool $format * @return float @@ -145,9 +151,9 @@ public function convertPrice($price, $format = true) */ public function canOnepageCheckout() { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( 'checkout/options/onepage_checkout_enabled', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } @@ -184,6 +190,8 @@ public function getSubtotalInclTax($item) } /** + * Get Base Price Incl Tax + * * @param AbstractItem $item * @return float */ @@ -196,6 +204,8 @@ public function getBasePriceInclTax($item) } /** + * Get Base Subtotal Incl Tax + * * @param AbstractItem $item * @return float */ @@ -217,13 +227,15 @@ public function sendPaymentFailedEmail( \Magento\Quote\Model\Quote $checkout, string $message, string $checkoutType = 'onepage' - ): \Magento\Checkout\Helper\Data { + ): Data { $this->paymentFailures->handle((int)$checkout->getId(), $message, $checkoutType); return $this; } /** + * Get Emails + * * @param string $configPath * @param null|string|bool|int|Store $storeId * @return array|false @@ -232,7 +244,7 @@ protected function _getEmails($configPath, $storeId) { $data = $this->scopeConfig->getValue( $configPath, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $storeId ); if (!empty($data)) { @@ -242,8 +254,7 @@ protected function _getEmails($configPath, $storeId) } /** - * Check is allowed Guest Checkout - * Use config settings and observer + * Check is allowed Guest Checkout. Use config settings and observer * * @param \Magento\Quote\Model\Quote $quote * @param int|Store $store @@ -256,7 +267,7 @@ public function isAllowedGuestCheckout(\Magento\Quote\Model\Quote $quote, $store } $guestCheckout = $this->scopeConfig->isSetFlag( self::XML_PATH_GUEST_CHECKOUT, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); @@ -295,13 +306,13 @@ public function isCustomerMustBeLogged() { return $this->scopeConfig->isSetFlag( self::XML_PATH_CUSTOMER_MUST_BE_LOGGED, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } /** - * Checks if display billing address on payment method is available, otherwise - * billing address should be display on payment page + * If display billing address on payment method is available, otherwise should be display on payment page + * * @return bool */ public function isDisplayBillingOnPaymentMethodAvailable() diff --git a/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php b/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php index 53132ffaa748b..089ea15726c68 100644 --- a/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php @@ -179,7 +179,7 @@ public function testConvertPrice() public function testCanOnepageCheckout() { - $this->scopeConfig->expects($this->once())->method('getValue')->with( + $this->scopeConfig->expects($this->once())->method('isSetFlag')->with( 'checkout/options/onepage_checkout_enabled', 'store' )->will($this->returnValue(true)); diff --git a/app/code/Magento/Customer/Helper/Address.php b/app/code/Magento/Customer/Helper/Address.php index cfc76753fa10a..7c81e29325823 100644 --- a/app/code/Magento/Customer/Helper/Address.php +++ b/app/code/Magento/Customer/Helper/Address.php @@ -10,6 +10,8 @@ use Magento\Customer\Api\Data\AttributeMetadataInterface; use Magento\Directory\Model\Country\Format; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\View\Element\BlockInterface; +use Magento\Store\Model\ScopeInterface; /** * Customer address helper @@ -94,6 +96,8 @@ class Address extends \Magento\Framework\App\Helper\AbstractHelper protected $_addressConfig; /** + * Address constructor. + * * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\View\Element\BlockFactory $blockFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -173,7 +177,9 @@ public function getRenderer($renderer) * * @param string $key * @param \Magento\Store\Model\Store|int|string $store + * * @return string|null + * @throws NoSuchEntityException */ public function getConfig($key, $store = null) { @@ -182,7 +188,7 @@ public function getConfig($key, $store = null) if (!isset($this->_config[$websiteId])) { $this->_config[$websiteId] = $this->scopeConfig->getValue( 'customer/address', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } @@ -193,7 +199,10 @@ public function getConfig($key, $store = null) * Return Number of Lines in a Street Address for store * * @param \Magento\Store\Model\Store|int|string $store + * * @return int + * @throws NoSuchEntityException + * @throws \Magento\Framework\Exception\LocalizedException */ public function getStreetLines($store = null) { @@ -242,7 +251,9 @@ public function getFormatTypeRenderer($code) * Determine if specified address config value can be shown * * @param string $key + * * @return bool + * @throws NoSuchEntityException */ public function canShowConfig($key) { @@ -253,9 +264,11 @@ public function canShowConfig($key) * Get string with frontend validation classes for attribute * * @param string $attributeCode + * * @return string * * @SuppressWarnings(PHPMD.NPathComplexity) + * @throws \Magento\Framework\Exception\LocalizedException */ public function getAttributeValidationClass($attributeCode) { @@ -323,9 +336,9 @@ public function convertStreetLines($origStreets, $toCount) */ public function isVatValidationEnabled($store = null) { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::XML_PATH_VAT_VALIDATION_ENABLED, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } @@ -337,9 +350,9 @@ public function isVatValidationEnabled($store = null) */ public function isDisableAutoGroupAssignDefaultValue() { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::XML_PATH_VIV_DISABLE_AUTO_ASSIGN_DEFAULT, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } @@ -351,9 +364,9 @@ public function isDisableAutoGroupAssignDefaultValue() */ public function hasValidateOnEachTransaction($store = null) { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::XML_PATH_VIV_ON_EACH_TRANSACTION, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } @@ -368,7 +381,7 @@ public function getTaxCalculationAddressType($store = null) { return (string)$this->scopeConfig->getValue( self::XML_PATH_VIV_TAX_CALCULATION_ADDRESS_TYPE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $store ); } @@ -380,9 +393,9 @@ public function getTaxCalculationAddressType($store = null) */ public function isVatAttributeVisible() { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::XML_PATH_VAT_FRONTEND_VISIBILITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } @@ -390,7 +403,10 @@ public function isVatAttributeVisible() * Retrieve attribute visibility * * @param string $code + * * @return bool + * @throws NoSuchEntityException + * @throws \Magento\Framework\Exception\LocalizedException * @since 100.2.0 */ public function isAttributeVisible($code) diff --git a/app/code/Magento/Customer/Model/AccountConfirmation.php b/app/code/Magento/Customer/Model/AccountConfirmation.php index 7d01ff0efc411..f29330af25874 100644 --- a/app/code/Magento/Customer/Model/AccountConfirmation.php +++ b/app/code/Magento/Customer/Model/AccountConfirmation.php @@ -10,8 +10,7 @@ use Magento\Framework\Registry; /** - * Class AccountConfirmation. - * Checks if email confirmation required for customer. + * Class AccountConfirmation. Checks if email confirmation required for customer. */ class AccountConfirmation { @@ -31,6 +30,8 @@ class AccountConfirmation private $registry; /** + * AccountConfirmation constructor. + * * @param ScopeConfigInterface $scopeConfig * @param Registry $registry */ @@ -56,7 +57,7 @@ public function isConfirmationRequired($websiteId, $customerId, $customerEmail): return false; } - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::XML_PATH_IS_CONFIRM, ScopeInterface::SCOPE_WEBSITES, $websiteId diff --git a/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php b/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php index fd06f778efe45..2c49a81676c1e 100644 --- a/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php @@ -212,7 +212,7 @@ public function getConvertStreetLinesDataProvider() public function testIsVatValidationEnabled($store, $result) { $this->scopeConfig->expects($this->once()) - ->method('getValue') + ->method('isSetFlag') ->with( \Magento\Customer\Helper\Address::XML_PATH_VAT_VALIDATION_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, @@ -242,7 +242,7 @@ public function getVatValidationEnabledDataProvider() public function testHasValidateOnEachTransaction($store, $result) { $this->scopeConfig->expects($this->once()) - ->method('getValue') + ->method('isSetFlag') ->with( \Magento\Customer\Helper\Address::XML_PATH_VIV_ON_EACH_TRANSACTION, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, @@ -297,7 +297,7 @@ public function getTaxCalculationAddressTypeDataProvider() public function testIsDisableAutoGroupAssignDefaultValue() { $this->scopeConfig->expects($this->once()) - ->method('getValue') + ->method('isSetFlag') ->with( \Magento\Customer\Helper\Address::XML_PATH_VIV_DISABLE_AUTO_ASSIGN_DEFAULT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE @@ -309,7 +309,7 @@ public function testIsDisableAutoGroupAssignDefaultValue() public function testIsVatAttributeVisible() { $this->scopeConfig->expects($this->once()) - ->method('getValue') + ->method('isSetFlag') ->with( \Magento\Customer\Helper\Address::XML_PATH_VAT_FRONTEND_VISIBILITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE diff --git a/app/code/Magento/Customer/Test/Unit/Model/AccountConfirmationTest.php b/app/code/Magento/Customer/Test/Unit/Model/AccountConfirmationTest.php index ae246665b28ed..1ce80d9d1e99b 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AccountConfirmationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AccountConfirmationTest.php @@ -59,7 +59,7 @@ public function testIsConfirmationRequired( $websiteId = 1; $this->scopeConfig->expects($this->any()) - ->method('getValue') + ->method('isSetFlag') ->with( $this->accountConfirmation::XML_PATH_IS_CONFIRM, ScopeInterface::SCOPE_WEBSITES, diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php index 1d7905cca7941..a9c6de72acbef 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php @@ -175,7 +175,7 @@ public function testGetConfirmationAttribute() $this->document->setData('original_website_id', $websiteId); $this->scopeConfig->expects(static::once()) - ->method('getValue') + ->method('isSetFlag') ->with() ->willReturn(true); diff --git a/app/code/Magento/Customer/Ui/Component/DataProvider/Document.php b/app/code/Magento/Customer/Ui/Component/DataProvider/Document.php index a9a5c5b17744e..468a9e7946f2d 100644 --- a/app/code/Magento/Customer/Ui/Component/DataProvider/Document.php +++ b/app/code/Magento/Customer/Ui/Component/DataProvider/Document.php @@ -72,6 +72,7 @@ class Document extends \Magento\Framework\View\Element\UiComponent\DataProvider\ /** * Document constructor. + * * @param AttributeValueFactory $attributeValueFactory * @param GroupRepositoryInterface $groupRepository * @param CustomerMetadataInterface $customerMetadata @@ -118,9 +119,10 @@ public function getCustomAttribute($attributeCode) } /** - * Update customer gender value - * Method set gender label instead of id value + * Update customer gender value. Method set gender label instead of id value + * * @return void + * @throws \Magento\Framework\Exception\LocalizedException */ private function setGenderValue() { @@ -141,9 +143,10 @@ private function setGenderValue() } /** - * Update customer group value - * Method set group code instead id value + * Update customer group value. Method set group code instead id value + * * @return void + * @throws \Magento\Framework\Exception\LocalizedException */ private function setCustomerGroupValue() { @@ -157,8 +160,8 @@ private function setCustomerGroupValue() } /** - * Update website value - * Method set website name instead id value + * Update website value. Method set website name instead id value + * * @return void */ private function setWebsiteValue() @@ -170,22 +173,22 @@ private function setWebsiteValue() } /** - * Update confirmation value - * Method set confirmation text value to match what is shown in grid + * Update confirmation value. Method set confirmation text value to match what is shown in grid + * * @return void */ private function setConfirmationValue() { $value = $this->getData(self::$confirmationAttributeCode); $websiteId = $this->getData(self::$websiteIdAttributeCode) ?: $this->getData(self::$websiteAttributeCode); - $isConfirmationRequired = (bool)$this->scopeConfig->getValue( + $isConfirmRequired = $this->scopeConfig->isSetFlag( AccountManagement::XML_PATH_IS_CONFIRM, ScopeInterface::SCOPE_WEBSITES, $websiteId ); $valueText = __('Confirmation Not Required'); - if ($isConfirmationRequired) { + if ($isConfirmRequired) { $valueText = $value === null ? __('Confirmed') : __('Confirmation Required'); } @@ -193,8 +196,8 @@ private function setConfirmationValue() } /** - * Update lock expires value - * Method set account lock text value to match what is shown in grid + * Update lock expires value. Method set account lock text value to match what is shown in grid + * * @return void */ private function setAccountLockValue() diff --git a/app/code/Magento/Directory/Helper/Data.php b/app/code/Magento/Directory/Helper/Data.php index 99e1d1ad5394e..3a5558e6d6f3d 100644 --- a/app/code/Magento/Directory/Helper/Data.php +++ b/app/code/Magento/Directory/Helper/Data.php @@ -6,7 +6,15 @@ namespace Magento\Directory\Helper; +use Magento\Directory\Model\Currency; +use Magento\Directory\Model\CurrencyFactory; +use Magento\Directory\Model\ResourceModel\Country\Collection; +use Magento\Directory\Model\ResourceModel\Region\CollectionFactory; +use Magento\Framework\App\Cache\Type\Config; +use Magento\Framework\App\Helper\Context; +use Magento\Framework\Json\Helper\Data as JsonData; use Magento\Store\Model\ScopeInterface; +use Magento\Store\Model\StoreManagerInterface; /** * Directory data helper @@ -53,7 +61,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * Country collection * - * @var \Magento\Directory\Model\ResourceModel\Country\Collection + * @var Collection */ protected $_countryCollection; @@ -86,47 +94,49 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_optZipCountries = null; /** - * @var \Magento\Framework\App\Cache\Type\Config + * @var Config */ protected $_configCacheType; /** - * @var \Magento\Directory\Model\ResourceModel\Region\CollectionFactory + * @var CollectionFactory */ protected $_regCollectionFactory; /** - * @var \Magento\Framework\Json\Helper\Data + * @var JsonData */ protected $jsonHelper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** - * @var \Magento\Directory\Model\CurrencyFactory + * @var CurrencyFactory */ protected $_currencyFactory; /** - * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Framework\App\Cache\Type\Config $configCacheType - * @param \Magento\Directory\Model\ResourceModel\Country\Collection $countryCollection - * @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regCollectionFactory, - * @param \Magento\Framework\Json\Helper\Data $jsonHelper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory + * Data constructor. + * + * @param Context $context + * @param Config $configCacheType + * @param Collection $countryCollection + * @param CollectionFactory $regCollectionFactory + * @param JsonData $jsonHelper + * @param StoreManagerInterface $storeManager + * @param CurrencyFactory $currencyFactory */ public function __construct( - \Magento\Framework\App\Helper\Context $context, - \Magento\Framework\App\Cache\Type\Config $configCacheType, - \Magento\Directory\Model\ResourceModel\Country\Collection $countryCollection, - \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regCollectionFactory, - \Magento\Framework\Json\Helper\Data $jsonHelper, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Directory\Model\CurrencyFactory $currencyFactory + Context $context, + Config $configCacheType, + Collection $countryCollection, + CollectionFactory $regCollectionFactory, + JsonData $jsonHelper, + StoreManagerInterface $storeManager, + CurrencyFactory $currencyFactory ) { parent::__construct($context); $this->_configCacheType = $configCacheType; @@ -155,7 +165,7 @@ public function getRegionCollection() * Retrieve country collection * * @param null|int|string|\Magento\Store\Model\Store $store - * @return \Magento\Directory\Model\ResourceModel\Country\Collection + * @return Collection */ public function getCountryCollection($store = null) { @@ -169,6 +179,7 @@ public function getCountryCollection($store = null) * Retrieve regions data json * * @return string + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getRegionJson() { @@ -197,8 +208,10 @@ public function getRegionJson() * @param float $amount * @param string $from * @param string $to + * * @return float * @SuppressWarnings(PHPMD.ShortVariable) + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function currencyConvert($amount, $from, $to = null) { @@ -251,7 +264,7 @@ public function isZipCodeOptional($countryCode) * Returns the list of countries, for which region is required * * @param boolean $asJson - * @return array + * @return array|string */ public function getCountriesWithStatesRequired($asJson = false) { @@ -275,7 +288,7 @@ public function getCountriesWithStatesRequired($asJson = false) */ public function isShowNonRequiredState() { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::XML_PATH_DISPLAY_ALL_STATES, ScopeInterface::SCOPE_STORE ); @@ -303,7 +316,10 @@ public function isRegionRequired($countryId) */ public function getBaseCurrencyCode() { - return $this->scopeConfig->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default'); + return $this->scopeConfig->getValue( + Currency::XML_PATH_CURRENCY_BASE, + 'default' + ); } /** diff --git a/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php b/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php index 73e9f0f5fa1a5..6ff0f8ea0f30b 100644 --- a/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php @@ -46,6 +46,7 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->scopeConfigMock->expects($this->any())->method('isSetFlag')->willReturn(false); $context = $this->createMock(\Magento\Framework\App\Helper\Context::class); $context->expects($this->any()) ->method('getScopeConfig') diff --git a/app/code/Magento/Downloadable/Helper/Data.php b/app/code/Magento/Downloadable/Helper/Data.php index 96aa5bdfeffd7..e9b2a5ce44c01 100644 --- a/app/code/Magento/Downloadable/Helper/Data.php +++ b/app/code/Magento/Downloadable/Helper/Data.php @@ -5,7 +5,9 @@ */ namespace Magento\Downloadable\Helper; +use Magento\Downloadable\Model\Link; use Magento\Downloadable\Model\Link\Purchased\Item; +use Magento\Store\Model\ScopeInterface; /** * Downloadable helper @@ -17,7 +19,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * Check is link shareable or not * - * @param \Magento\Downloadable\Model\Link|Item $link + * @param Link|Item $link * @return bool * @SuppressWarnings(PHPMD.BooleanGetMethodName) */ @@ -25,14 +27,14 @@ public function getIsShareable($link) { $shareable = false; switch ($link->getIsShareable()) { - case \Magento\Downloadable\Model\Link::LINK_SHAREABLE_YES: - case \Magento\Downloadable\Model\Link::LINK_SHAREABLE_NO: + case Link::LINK_SHAREABLE_YES: + case Link::LINK_SHAREABLE_NO: $shareable = (bool)$link->getIsShareable(); break; - case \Magento\Downloadable\Model\Link::LINK_SHAREABLE_CONFIG: - $shareable = (bool)$this->scopeConfig->isSetFlag( - \Magento\Downloadable\Model\Link::XML_PATH_CONFIG_IS_SHAREABLE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + case Link::LINK_SHAREABLE_CONFIG: + $shareable = $this->scopeConfig->isSetFlag( + Link::XML_PATH_CONFIG_IS_SHAREABLE, + ScopeInterface::SCOPE_STORE ); } return $shareable; diff --git a/app/code/Magento/Elasticsearch/Model/DataProvider/Suggestions.php b/app/code/Magento/Elasticsearch/Model/DataProvider/Suggestions.php index 8ebd45596d399..c4fab39dfde61 100644 --- a/app/code/Magento/Elasticsearch/Model/DataProvider/Suggestions.php +++ b/app/code/Magento/Elasticsearch/Model/DataProvider/Suggestions.php @@ -15,6 +15,9 @@ use Magento\Elasticsearch\SearchAdapter\SearchIndexNameResolver; use Magento\Store\Model\StoreManagerInterface as StoreManager; +/** + * Class Suggestions + */ class Suggestions implements SuggestedQueriesInterface { /** @@ -66,6 +69,8 @@ class Suggestions implements SuggestedQueriesInterface private $storeManager; /** + * Suggestions constructor. + * * @param ScopeConfigInterface $scopeConfig * @param Config $config * @param QueryResultFactory $queryResultFactory @@ -90,11 +95,9 @@ public function __construct( } /** - * {@inheritdoc} - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @inheritdoc */ - public function getItems(QueryInterface $query, $limit = null, $additionalFilters = null) + public function getItems(QueryInterface $query) { $result = []; if ($this->isSuggestionsAllowed()) { @@ -118,19 +121,23 @@ public function getItems(QueryInterface $query, $limit = null, $additionalFilter } /** - * {@inheritdoc} + * @inheritdoc */ public function isResultsCountEnabled() { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::CONFIG_SUGGESTION_COUNT_RESULTS_ENABLED, ScopeInterface::SCOPE_STORE ); } /** + * Get Suggestions + * * @param QueryInterface $query + * * @return array + * @throws \Magento\Framework\Exception\NoSuchEntityException */ private function getSuggestions(QueryInterface $query) { @@ -178,6 +185,8 @@ private function getSuggestions(QueryInterface $query) } /** + * Fetch Query + * * @param array $query * @return array */ @@ -200,16 +209,18 @@ private function getSearchSuggestionsCount() } /** + * Is Search Suggestions Allowed + * * @return bool */ private function isSuggestionsAllowed() { - $isSearchSuggestionsEnabled = (bool)$this->scopeConfig->getValue( + $isSuggestionsEnabled = $this->scopeConfig->isSetFlag( self::CONFIG_SUGGESTION_ENABLED, ScopeInterface::SCOPE_STORE ); $isEnabled = $this->config->isElasticsearchEnabled(); - $isSuggestionsAllowed = ($isEnabled && $isSearchSuggestionsEnabled); + $isSuggestionsAllowed = ($isEnabled && $isSuggestionsEnabled); return $isSuggestionsAllowed; } } diff --git a/app/code/Magento/GiftMessage/Model/GiftMessageConfigProvider.php b/app/code/Magento/GiftMessage/Model/GiftMessageConfigProvider.php index c7f145eaddbb4..b124897770b6f 100644 --- a/app/code/Magento/GiftMessage/Model/GiftMessageConfigProvider.php +++ b/app/code/Magento/GiftMessage/Model/GiftMessageConfigProvider.php @@ -13,6 +13,7 @@ use Magento\Framework\Locale\FormatInterface as LocaleFormat; use Magento\Framework\Data\Form\FormKey; use Magento\Catalog\Model\Product\Attribute\Source\Boolean; +use Magento\Store\Model\ScopeInterface; /** * Configuration provider for GiftMessage rendering on "Checkout cart" page. @@ -41,6 +42,11 @@ class GiftMessageConfigProvider implements ConfigProviderInterface */ protected $checkoutSession; + /** + * @var HttpContext + */ + protected $httpContext; + /** * @var \Magento\Store\Model\StoreManagerInterface */ @@ -57,6 +63,8 @@ class GiftMessageConfigProvider implements ConfigProviderInterface protected $formKey; /** + * GiftMessageConfigProvider constructor. + * * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\GiftMessage\Api\CartRepositoryInterface $cartRepository * @param \Magento\GiftMessage\Api\ItemRepositoryInterface $itemRepository @@ -87,28 +95,28 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function getConfig() { $configuration = []; $configuration['giftMessage'] = []; - $orderLevelGiftMessageConfiguration = (bool)$this->scopeConfiguration->getValue( + $orderLevelGiftMsg = $this->scopeConfiguration->isSetFlag( GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); - $itemLevelGiftMessageConfiguration = (bool)$this->scopeConfiguration->getValue( + $itemLevelGiftMessage = $this->scopeConfiguration->isSetFlag( GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); - if ($orderLevelGiftMessageConfiguration) { + if ($orderLevelGiftMsg) { $orderMessages = $this->getOrderLevelGiftMessages(); $configuration['isOrderLevelGiftOptionsEnabled'] = (bool)$this->isQuoteVirtual() ? false : true; $configuration['giftMessage']['orderLevel'] = $orderMessages === null ? true : $orderMessages->getData(); } $itemMessages = $this->getItemLevelGiftMessages(); - $configuration['isItemLevelGiftOptionsEnabled'] = $itemLevelGiftMessageConfiguration; + $configuration['isItemLevelGiftOptionsEnabled'] = $itemLevelGiftMessage; $configuration['giftMessage']['itemLevel'] = $itemMessages === null ? true : $itemMessages; $configuration['priceFormat'] = $this->localeFormat->getPriceFormat( @@ -168,6 +176,7 @@ protected function getOrderLevelGiftMessages() * Load already specified item level gift messages and related configuration. * * @return \Magento\GiftMessage\Api\Data\MessageInterface[]|null + * @throws \Magento\Framework\Exception\NoSuchEntityException */ protected function getItemLevelGiftMessages() { diff --git a/app/code/Magento/GiftMessage/Test/Unit/Model/GiftMessageConfigProviderTest.php b/app/code/Magento/GiftMessage/Test/Unit/Model/GiftMessageConfigProviderTest.php index a5580606134b4..08ebefb68d724 100644 --- a/app/code/Magento/GiftMessage/Test/Unit/Model/GiftMessageConfigProviderTest.php +++ b/app/code/Magento/GiftMessage/Test/Unit/Model/GiftMessageConfigProviderTest.php @@ -111,7 +111,7 @@ public function testGetConfig() ); $messageMock = $this->createMock(\Magento\GiftMessage\Model\Message::class); - $this->scopeConfigMock->expects($this->atLeastOnce())->method('getValue')->willReturnMap( + $this->scopeConfigMock->expects($this->atLeastOnce())->method('isSetFlag')->willReturnMap( [ [GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER, Scope::SCOPE_STORE, null, $orderLevel], [GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS, Scope::SCOPE_STORE, null, $itemLevel] diff --git a/app/code/Magento/GoogleOptimizer/Helper/Data.php b/app/code/Magento/GoogleOptimizer/Helper/Data.php index 5b0291eb1435d..7138a7729fe0e 100644 --- a/app/code/Magento/GoogleOptimizer/Helper/Data.php +++ b/app/code/Magento/GoogleOptimizer/Helper/Data.php @@ -11,6 +11,8 @@ use \Magento\Store\Model\ScopeInterface; /** + * Class Data + * * @api * @since 100.0.2 */ @@ -32,6 +34,8 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_analyticsHelper; /** + * Data constructor. + * * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\GoogleAnalytics\Helper\Data $analyticsHelper */ @@ -51,7 +55,7 @@ public function __construct( */ public function isGoogleExperimentEnabled($store = null) { - return (bool)$this->scopeConfig->isSetFlag(self::XML_PATH_ENABLED, ScopeInterface::SCOPE_STORE, $store); + return $this->scopeConfig->isSetFlag(self::XML_PATH_ENABLED, ScopeInterface::SCOPE_STORE, $store); } /** diff --git a/app/code/Magento/Msrp/Model/Config.php b/app/code/Magento/Msrp/Model/Config.php index 2ee9f41870a5a..3662a2cef8d20 100644 --- a/app/code/Magento/Msrp/Model/Config.php +++ b/app/code/Magento/Msrp/Model/Config.php @@ -10,6 +10,9 @@ use Magento\Store\Model\StoreManagerInterface; use Magento\Framework\Escaper; +/** + * Class Config + */ class Config { /**#@+ @@ -40,6 +43,8 @@ class Config protected $storeId; /** + * Config constructor. + * * @param ScopeConfigInterface $scopeConfig * @param StoreManagerInterface $storeManager * @param Escaper $escaper @@ -74,7 +79,7 @@ public function setStoreId($store) */ public function isEnabled() { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::XML_PATH_MSRP_ENABLED, ScopeInterface::SCOPE_STORE, $this->storeId diff --git a/app/code/Magento/NewRelicReporting/Model/Config.php b/app/code/Magento/NewRelicReporting/Model/Config.php index 4bb381eb2f12d..6f3ff1df57448 100644 --- a/app/code/Magento/NewRelicReporting/Model/Config.php +++ b/app/code/Magento/NewRelicReporting/Model/Config.php @@ -91,7 +91,7 @@ public function __construct( */ public function isNewRelicEnabled() { - return (bool)$this->scopeConfig->getValue('newrelicreporting/general/enable'); + return $this->scopeConfig->isSetFlag('newrelicreporting/general/enable'); } /** @@ -181,7 +181,7 @@ public function isSeparateApps() */ public function isCronEnabled() { - return (bool)$this->scopeConfig->getValue('newrelicreporting/cron/enable_cron'); + return $this->scopeConfig->isSetFlag('newrelicreporting/cron/enable_cron'); } /** diff --git a/app/code/Magento/Reports/Model/ReportStatus.php b/app/code/Magento/Reports/Model/ReportStatus.php index ec0c32d9af1ec..d5d4611682090 100644 --- a/app/code/Magento/Reports/Model/ReportStatus.php +++ b/app/code/Magento/Reports/Model/ReportStatus.php @@ -21,6 +21,8 @@ class ReportStatus private $scopeConfig; /** + * ReportStatus constructor. + * * @param ScopeConfigInterface $scopeConfig */ public function __construct(ScopeConfigInterface $scopeConfig) @@ -37,11 +39,13 @@ public function __construct(ScopeConfigInterface $scopeConfig) */ public function isReportEnabled(string $reportEventType): bool { - return (bool)$this->scopeConfig->getValue('reports/options/enabled') - && (bool)$this->scopeConfig->getValue($this->getConfigPathByEventType($reportEventType)); + return $this->scopeConfig->isSetFlag('reports/options/enabled') + && $this->scopeConfig->isSetFlag($this->getConfigPathByEventType($reportEventType)); } /** + * Get Config Path By Event Type + * * @param string $reportEventType * @return string * @throws InputException diff --git a/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php b/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php index 11a59cfa59f17..82024b3b015e5 100644 --- a/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php +++ b/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php @@ -105,6 +105,8 @@ class Product extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb private $scopeConfig; /** + * Product constructor. + * * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Sitemap\Helper\Data $sitemapData * @param \Magento\Catalog\Model\ResourceModel\Product $productResource @@ -157,6 +159,8 @@ public function __construct( } /** + * Construct + * * @return void */ protected function _construct() @@ -171,7 +175,9 @@ protected function _construct() * @param string $attributeCode * @param mixed $value * @param string $type + * * @return \Magento\Framework\DB\Select|bool + * @throws \Magento\Framework\Exception\LocalizedException */ protected function _addFilter($storeId, $attributeCode, $value, $type = '=') { @@ -217,7 +223,9 @@ protected function _addFilter($storeId, $attributeCode, $value, $type = '=') * @param int $storeId * @param string $attributeCode * @param string $column Add attribute value to given column + * * @return void + * @throws \Magento\Framework\Exception\LocalizedException */ protected function _joinAttribute($storeId, $attributeCode, $column = null) { @@ -260,7 +268,9 @@ protected function _joinAttribute($storeId, $attributeCode, $column = null) * Get attribute data by attribute code * * @param string $attributeCode + * * @return array + * @throws \Magento\Framework\Exception\LocalizedException */ protected function _getAttribute($attributeCode) { @@ -283,7 +293,11 @@ protected function _getAttribute($attributeCode) * Get category collection array * * @param null|string|bool|int|Store $storeId + * * @return array|bool + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Zend_Db_Statement_Exception */ public function getCollection($storeId) { @@ -348,7 +362,9 @@ public function getCollection($storeId) * * @param array $productRow * @param int $storeId + * * @return \Magento\Framework\DataObject + * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareProduct(array $productRow, $storeId) { @@ -476,13 +492,13 @@ private function getProductImageUrl($image) /** * Return Use Categories Path for Product URLs config value * - * @param $storeId + * @param null|string $storeId * * @return bool */ private function isCategoryProductURLsConfig($storeId) { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( HelperProduct::XML_PATH_PRODUCT_URL_USE_CATEGORY, ScopeInterface::SCOPE_STORE, $storeId diff --git a/app/code/Magento/Store/Model/BaseUrlChecker.php b/app/code/Magento/Store/Model/BaseUrlChecker.php index b65a76e8806f1..dbdcd9ff17bf9 100644 --- a/app/code/Magento/Store/Model/BaseUrlChecker.php +++ b/app/code/Magento/Store/Model/BaseUrlChecker.php @@ -5,6 +5,8 @@ */ namespace Magento\Store\Model; +use Magento\Store\Model\ScopeInterface; + /** * Verifies that the requested URL matches to base URL of store. */ @@ -16,6 +18,8 @@ class BaseUrlChecker private $scopeConfig; /** + * BaseUrlChecker constructor. + * * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct( @@ -47,9 +51,9 @@ public function execute($uri, $request) */ public function isEnabled() { - return (bool) $this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( 'web/url/redirect_to_base', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } @@ -62,13 +66,13 @@ public function isFrontendSecure() { $baseUrl = $this->scopeConfig->getValue( 'web/unsecure/base_url', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); $baseUrlParts = explode('://', $baseUrl); $baseUrlProtocol = array_shift($baseUrlParts); - $isSecure = (bool) $this->scopeConfig->getValue( + $isSecure = $this->scopeConfig->isSetFlag( 'web/secure/use_in_frontend', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); return $isSecure && $baseUrlProtocol == 'https'; diff --git a/app/code/Magento/Store/Model/HeaderProvider/Hsts.php b/app/code/Magento/Store/Model/HeaderProvider/Hsts.php index 623fbed57e6c6..b22775e0987cb 100644 --- a/app/code/Magento/Store/Model/HeaderProvider/Hsts.php +++ b/app/code/Magento/Store/Model/HeaderProvider/Hsts.php @@ -33,6 +33,8 @@ class Hsts extends \Magento\Framework\App\Response\HeaderProvider\AbstractHeader protected $scopeConfig; /** + * Hsts constructor. + * * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig) @@ -41,11 +43,11 @@ public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $ } /** - * {@inheritdoc} + * @inheritdoc */ public function canApply() { - return (bool)$this->scopeConfig->isSetFlag(Store::XML_PATH_SECURE_IN_FRONTEND) + return $this->scopeConfig->isSetFlag(Store::XML_PATH_SECURE_IN_FRONTEND) && $this->scopeConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML) && $this->scopeConfig->isSetFlag(Store::XML_PATH_ENABLE_HSTS); } diff --git a/app/code/Magento/Store/Model/HeaderProvider/UpgradeInsecure.php b/app/code/Magento/Store/Model/HeaderProvider/UpgradeInsecure.php index a0bd015c15061..0ef8726e07f1b 100644 --- a/app/code/Magento/Store/Model/HeaderProvider/UpgradeInsecure.php +++ b/app/code/Magento/Store/Model/HeaderProvider/UpgradeInsecure.php @@ -33,6 +33,8 @@ class UpgradeInsecure extends \Magento\Framework\App\Response\HeaderProvider\Abs protected $scopeConfig; /** + * UpgradeInsecure constructor. + * * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig) @@ -41,11 +43,11 @@ public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $ } /** - * {@inheritdoc} + * @inheritdoc */ public function canApply() { - return (bool)$this->scopeConfig->isSetFlag(Store::XML_PATH_SECURE_IN_FRONTEND) + return $this->scopeConfig->isSetFlag(Store::XML_PATH_SECURE_IN_FRONTEND) && $this->scopeConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML) && $this->scopeConfig->isSetFlag(Store::XML_PATH_ENABLE_UPGRADE_INSECURE); } diff --git a/app/code/Magento/Store/Model/StoreManager.php b/app/code/Magento/Store/Model/StoreManager.php index 445824baadfe0..0fce3a5217058 100644 --- a/app/code/Magento/Store/Model/StoreManager.php +++ b/app/code/Magento/Store/Model/StoreManager.php @@ -6,6 +6,7 @@ namespace Magento\Store\Model; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Store\Api\StoreResolverInterface; use Magento\Store\Model\ResourceModel\StoreWebsiteRelation; @@ -87,6 +88,8 @@ class StoreManager implements protected $isSingleStoreAllowed; /** + * StoreManager constructor. + * * @param \Magento\Store\Api\StoreRepositoryInterface $storeRepository * @param \Magento\Store\Api\GroupRepositoryInterface $groupRepository * @param \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository @@ -114,7 +117,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function setCurrentStore($store) { @@ -122,7 +125,7 @@ public function setCurrentStore($store) } /** - * {@inheritdoc} + * @inheritdoc */ public function setIsSingleStoreModeAllowed($value) { @@ -130,7 +133,7 @@ public function setIsSingleStoreModeAllowed($value) } /** - * {@inheritdoc} + * @inheritdoc */ public function hasSingleStore() { @@ -139,7 +142,7 @@ public function hasSingleStore() } /** - * {@inheritdoc} + * @inheritdoc */ public function isSingleStoreMode() { @@ -147,7 +150,7 @@ public function isSingleStoreMode() } /** - * {@inheritdoc} + * @inheritdoc */ public function getStore($storeId = null) { @@ -171,7 +174,7 @@ public function getStore($storeId = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function getStores($withDefault = false, $codeKey = false) { @@ -190,7 +193,7 @@ public function getStores($withDefault = false, $codeKey = false) } /** - * {@inheritdoc} + * @inheritdoc */ public function getWebsite($websiteId = null) { @@ -210,7 +213,7 @@ public function getWebsite($websiteId = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function getWebsites($withDefault = false, $codeKey = false) { @@ -229,7 +232,7 @@ public function getWebsites($withDefault = false, $codeKey = false) } /** - * {@inheritdoc} + * @inheritdoc */ public function reinitStores() { @@ -242,7 +245,7 @@ public function reinitStores() } /** - * {@inheritdoc} + * @inheritdoc */ public function getDefaultStoreView() { @@ -252,7 +255,7 @@ public function getDefaultStoreView() } /** - * {@inheritdoc} + * @inheritdoc */ public function getGroup($groupId = null) { @@ -267,7 +270,7 @@ public function getGroup($groupId = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function getGroups($withDefault = false) { @@ -291,13 +294,15 @@ function ($item) { */ protected function isSingleStoreModeEnabled() { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( self::XML_PATH_SINGLE_STORE_MODE_ENABLED, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } /** + * Get Store Website Relation + * * @deprecated 100.2.0 * @return StoreWebsiteRelation */ diff --git a/app/code/Magento/Store/Test/Unit/Model/BaseUrlCheckerTest.php b/app/code/Magento/Store/Test/Unit/Model/BaseUrlCheckerTest.php index 0eea86da61b3b..78a627c195f81 100644 --- a/app/code/Magento/Store/Test/Unit/Model/BaseUrlCheckerTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/BaseUrlCheckerTest.php @@ -78,9 +78,9 @@ public function testExecute() public function testIsEnabled() { $this->scopeConfig->expects($this->once()) - ->method('getValue') + ->method('isSetFlag') ->with('web/url/redirect_to_base', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) - ->willReturn(1); + ->willReturn(!!1); $this->assertTrue($this->baseUrlChecker->isEnabled()); } @@ -89,15 +89,16 @@ public function testIsEnabled() */ public function testIsFrontendSecure() { - $this->scopeConfig->expects($this->exactly(2)) + $this->scopeConfig->expects($this->once()) ->method('getValue') - ->withConsecutive( - ['web/unsecure/base_url', \Magento\Store\Model\ScopeInterface::SCOPE_STORE], - ['web/secure/use_in_frontend', \Magento\Store\Model\ScopeInterface::SCOPE_STORE] - )->will($this->onConsecutiveCalls( - $this->returnValue('https://localhost'), - 1 - )); + ->with('web/unsecure/base_url', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ->willReturn('https://localhost'); + + $this->scopeConfig->expects($this->once()) + ->method('isSetFlag') + ->with('web/secure/use_in_frontend', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ->willReturn(!!1); + $this->assertTrue($this->baseUrlChecker->isFrontendSecure()); } } diff --git a/app/code/Magento/Wishlist/Model/Rss/Wishlist.php b/app/code/Magento/Wishlist/Model/Rss/Wishlist.php index 75df3027ad9a9..9ccbf80f99a0c 100644 --- a/app/code/Magento/Wishlist/Model/Rss/Wishlist.php +++ b/app/code/Magento/Wishlist/Model/Rss/Wishlist.php @@ -7,9 +7,11 @@ namespace Magento\Wishlist\Model\Rss; use Magento\Framework\App\Rss\DataProviderInterface; +use Magento\Store\Model\ScopeInterface; /** * Wishlist RSS model + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Wishlist implements DataProviderInterface @@ -70,6 +72,8 @@ class Wishlist implements DataProviderInterface protected $customerFactory; /** + * Wishlist constructor. + * * @param \Magento\Wishlist\Helper\Rss $wishlistHelper * @param \Magento\Wishlist\Block\Customer\Wishlist $wishlistBlock * @param \Magento\Catalog\Helper\Output $outputHelper @@ -114,9 +118,9 @@ public function __construct( */ public function isAllowed() { - return (bool)$this->scopeConfig->getValue( + return $this->scopeConfig->isSetFlag( 'rss/wishlist/active', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } @@ -124,6 +128,7 @@ public function isAllowed() * Get RSS feed items * * @return array + * @throws \Magento\Framework\Exception\LocalizedException */ public function getRssData() { @@ -191,6 +196,8 @@ public function getRssData() } /** + * GetCacheKey + * * @return string */ public function getCacheKey() @@ -199,6 +206,8 @@ public function getCacheKey() } /** + * Get Cache Lifetime + * * @return int */ public function getCacheLifetime() @@ -264,7 +273,7 @@ public function getProductPriceHtml(\Magento\Catalog\Model\Product $product) } /** - * @return array + * @inheritdoc */ public function getFeeds() { @@ -272,7 +281,7 @@ public function getFeeds() } /** - * {@inheritdoc} + * @inheritdoc */ public function isAuthRequired() { diff --git a/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php b/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php index 98d36dea28a2a..85f6c504457d3 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php @@ -278,7 +278,7 @@ protected function processWishlistItemDescription($wishlistModelMock, $staticArg public function testIsAllowed() { - $this->scopeConfig->expects($this->once())->method('getValue') + $this->scopeConfig->expects($this->once())->method('isSetFlag') ->with('rss/wishlist/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) ->will($this->returnValue(true)); $this->assertTrue($this->model->isAllowed()); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/SidResolverTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/SidResolverTest.php index e928422528409..5e70eb491b50c 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Session/SidResolverTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Session/SidResolverTest.php @@ -114,7 +114,7 @@ public function testGetSid($sid, $useFrontedSid, $isOwnOriginUrl, $testSid) $this->scopeConfig->expects( $this->any() )->method( - 'getValue' + 'isSetFlag' )->with( \Magento\Framework\Session\SidResolver::XML_PATH_USE_FRONTEND_SID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE @@ -195,7 +195,7 @@ public function testSetGetUseSessionInUrl($configValue) $this->scopeConfig->expects( $this->any() )->method( - 'getValue' + 'isSetFlag' )->with( \Magento\Framework\Session\SidResolver::XML_PATH_USE_FRONTEND_SID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE diff --git a/lib/internal/Magento/Framework/Session/SidResolver.php b/lib/internal/Magento/Framework/Session/SidResolver.php index feb4877028dae..1208aeb31eaee 100644 --- a/lib/internal/Magento/Framework/Session/SidResolver.php +++ b/lib/internal/Magento/Framework/Session/SidResolver.php @@ -9,6 +9,9 @@ use Magento\Framework\App\State; +/** + * Class SidResolver + */ class SidResolver implements SidResolverInterface { /** @@ -86,8 +89,12 @@ public function __construct( } /** + * Get Sid + * * @param SessionManagerInterface $session + * * @return string|null + * @throws \Magento\Framework\Exception\LocalizedException */ public function getSid(SessionManagerInterface $session) { @@ -169,7 +176,7 @@ public function getUseSessionInUrl() if ($this->_useSessionInUrl === null) { //Using config value by default, can be overridden by using the //setter. - $this->_useSessionInUrl = (bool)$this->scopeConfig->getValue( + $this->_useSessionInUrl = $this->scopeConfig->isSetFlag( self::XML_PATH_USE_FRONTEND_SID, $this->_scopeType ); diff --git a/lib/internal/Magento/Framework/View/Asset/Config.php b/lib/internal/Magento/Framework/View/Asset/Config.php index 2a3d0d3dad467..6a0548b3395a0 100644 --- a/lib/internal/Magento/Framework/View/Asset/Config.php +++ b/lib/internal/Magento/Framework/View/Asset/Config.php @@ -8,7 +8,6 @@ use Magento\Store\Model\ScopeInterface; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\App\State; /** * View asset configuration interface @@ -55,7 +54,7 @@ public function __construct(ScopeConfigInterface $scopeConfig) */ public function isMergeCssFiles() { - return (bool)$this->scopeConfig->isSetFlag( + return $this->scopeConfig->isSetFlag( self::XML_PATH_MERGE_CSS_FILES, ScopeInterface::SCOPE_STORE ); @@ -68,7 +67,7 @@ public function isMergeCssFiles() */ public function isBundlingJsFiles() { - return (bool)$this->scopeConfig->isSetFlag( + return $this->scopeConfig->isSetFlag( self::XML_PATH_JS_BUNDLING, ScopeInterface::SCOPE_STORE ); @@ -81,7 +80,7 @@ public function isBundlingJsFiles() */ public function isMergeJsFiles() { - return (bool)$this->scopeConfig->isSetFlag( + return $this->scopeConfig->isSetFlag( self::XML_PATH_MERGE_JS_FILES, ScopeInterface::SCOPE_STORE ); @@ -94,7 +93,7 @@ public function isMergeJsFiles() */ public function isMinifyHtml() { - return (bool)$this->scopeConfig->isSetFlag( + return $this->scopeConfig->isSetFlag( self::XML_PATH_MINIFICATION_HTML, ScopeInterface::SCOPE_STORE ); diff --git a/lib/internal/Magento/Framework/View/Asset/Minification.php b/lib/internal/Magento/Framework/View/Asset/Minification.php index 596add349dbfa..087d57ffa4162 100644 --- a/lib/internal/Magento/Framework/View/Asset/Minification.php +++ b/lib/internal/Magento/Framework/View/Asset/Minification.php @@ -64,7 +64,7 @@ public function isEnabled($contentType) if (!isset($this->configCache[self::XML_PATH_MINIFICATION_ENABLED][$contentType])) { $this->configCache[self::XML_PATH_MINIFICATION_ENABLED][$contentType] = $this->appState->getMode() != State::MODE_DEVELOPER && - (bool)$this->scopeConfig->isSetFlag( + $this->scopeConfig->isSetFlag( sprintf(self::XML_PATH_MINIFICATION_ENABLED, $contentType), $this->scope ); @@ -112,6 +112,8 @@ public function removeMinifiedSign($filename) } /** + * Is Minified Filename + * * @param string $filename * @return bool */ @@ -121,6 +123,8 @@ public function isMinifiedFilename($filename) } /** + * Is Excluded + * * @param string $filename * @return boolean */ @@ -135,6 +139,8 @@ public function isExcluded($filename) } /** + * Get Excludes + * * @param string $contentType * @return string[] */