Skip to content

Commit c387cdc

Browse files
author
Oleksii Korshenko
committed
MAGETWO-83958: Phpdoc improvements magento#12257
- Merge Pull Request magento#12257 from KarlDeux/magento2:feature/phpdoc-improvements - Merged commits: 1. f936604 2. 3ce246d 3. 8f1aa87 4. 41a43c1 5. 19de842 6. dc22a82 7. 820c097
2 parents 255fecc + 820c097 commit c387cdc

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Catalog\Model\Product\Visibility;
1010
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as ValidatorInterface;
1111
use Magento\Framework\App\Filesystem\DirectoryList;
12+
use Magento\Framework\Exception\LocalizedException;
1213
use Magento\Framework\Filesystem;
1314
use Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor;
1415
use Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface;
@@ -712,7 +713,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
712713
* @param \Magento\CatalogInventory\Model\Spi\StockStateProviderInterface $stockStateProvider
713714
* @param \Magento\Catalog\Helper\Data $catalogData
714715
* @param \Magento\ImportExport\Model\Import\Config $importConfig
715-
* @param Proxy\Product\ResourceFactory $resourceFactory
716+
* @param Proxy\Product\ResourceModelFactory $resourceFactory
716717
* @param Product\OptionFactory $optionFactory
717718
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setColFactory
718719
* @param Product\Type\Factory $productTypeFactory
@@ -1084,12 +1085,12 @@ protected function _initTypeModels()
10841085
$params = [$this, $productTypeName];
10851086
if (!($model = $this->_productTypeFactory->create($productTypeConfig['model'], ['params' => $params]))
10861087
) {
1087-
throw new \Magento\Framework\Exception\LocalizedException(
1088+
throw new LocalizedException(
10881089
__('Entity type model \'%1\' is not found', $productTypeConfig['model'])
10891090
);
10901091
}
10911092
if (!$model instanceof \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType) {
1092-
throw new \Magento\Framework\Exception\LocalizedException(
1093+
throw new LocalizedException(
10931094
__(
10941095
'Entity type model must be an instance of '
10951096
. \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType::class
@@ -1551,6 +1552,7 @@ public function getImagesFromRow(array $rowData)
15511552
* @SuppressWarnings(PHPMD.NPathComplexity)
15521553
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
15531554
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
1555+
* @throws \Magento\Framework\Exception\LocalizedException
15541556
*/
15551557
protected function _saveProducts()
15561558
{
@@ -1611,7 +1613,7 @@ protected function _saveProducts()
16111613

16121614
// wrong attribute_set_code was received
16131615
if (!$attributeSetId) {
1614-
throw new \Magento\Framework\Exception\LocalizedException(
1616+
throw new LocalizedException(
16151617
__(
16161618
'Wrong attribute set code "%1", please correct it and try again.',
16171619
$rowData['attribute_set_code']
@@ -1814,7 +1816,7 @@ protected function _saveProducts()
18141816
) {
18151817
$attrValue = $this->dateTime->formatDate($attrValue, false);
18161818
} elseif ('datetime' == $attribute->getBackendType() && strtotime($attrValue)) {
1817-
$attrValue = $this->dateTime->gmDate(
1819+
$attrValue = gmdate(
18181820
'Y-m-d H:i:s',
18191821
$this->_localeDate->date($attrValue)->getTimestamp()
18201822
);
@@ -1998,7 +2000,7 @@ protected function _getUploader()
19982000
}
19992001

20002002
if (!$this->_fileUploader->setTmpDir($tmpPath)) {
2001-
throw new \Magento\Framework\Exception\LocalizedException(
2003+
throw new LocalizedException(
20022004
__('File directory \'%1\' is not readable.', $tmpPath)
20032005
);
20042006
}
@@ -2007,7 +2009,7 @@ protected function _getUploader()
20072009

20082010
$this->_mediaDirectory->create($destinationPath);
20092011
if (!$this->_fileUploader->setDestDir($destinationPath)) {
2010-
throw new \Magento\Framework\Exception\LocalizedException(
2012+
throw new LocalizedException(
20112013
__('File directory \'%1\' is not writable.', $destinationPath)
20122014
);
20132015
}
@@ -2029,6 +2031,8 @@ public function getUploader()
20292031
* Return a new file name if the same file is already exists.
20302032
*
20312033
* @param string $fileName
2034+
* @param bool $renameFileOff [optional] boolean to pass. Default is false
2035+
* which will set not to rename the file after import.
20322036
* @return string
20332037
*/
20342038
protected function uploadMediaFiles($fileName, $renameFileOff = false)
@@ -2237,7 +2241,7 @@ protected function _saveStockItem()
22372241
$stockItemDo->setData($row);
22382242
$row['is_in_stock'] = $this->stockStateProvider->verifyStock($stockItemDo);
22392243
if ($this->stockStateProvider->verifyNotification($stockItemDo)) {
2240-
$row['low_stock_date'] = $this->dateTime->gmDate(
2244+
$row['low_stock_date'] = gmdate(
22412245
'Y-m-d H:i:s',
22422246
(new \DateTime())->getTimestamp()
22432247
);
@@ -2755,7 +2759,7 @@ private function _customFieldsMapping($rowData)
27552759
/**
27562760
* Validate data rows and save bunches to DB
27572761
*
2758-
* @return $this
2762+
* @return $this|\Magento\ImportExport\Model\Import\Entity\AbstractEntity
27592763
*/
27602764
protected function _saveValidatedBunches()
27612765
{

app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\App\ObjectManager;
99
use Magento\Framework\App\ResourceConnection;
10+
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\Framework\Serialize\Serializer\Json;
1112
use Magento\ImportExport\Model\Import\AbstractSource;
1213
use Magento\ImportExport\Model\Import as ImportExport;
@@ -310,7 +311,7 @@ public function __construct(
310311
protected function _getSource()
311312
{
312313
if (!$this->_source) {
313-
throw new \Magento\Framework\Exception\LocalizedException(__('Please specify a source.'));
314+
throw new LocalizedException(__('Please specify a source.'));
314315
}
315316
return $this->_source;
316317
}
@@ -378,7 +379,7 @@ protected function addErrors($code, $errors)
378379
/**
379380
* Validate data rows and save bunches to DB.
380381
*
381-
* @return $this|void
382+
* @return $this
382383
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
383384
*/
384385
protected function _saveValidatedBunches()
@@ -548,11 +549,11 @@ public function getBehavior()
548549
if (!isset(
549550
$this->_parameters['behavior']
550551
) ||
551-
$this->_parameters['behavior'] != \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND &&
552-
$this->_parameters['behavior'] != \Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE &&
553-
$this->_parameters['behavior'] != \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE
552+
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_APPEND &&
553+
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_REPLACE &&
554+
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_DELETE
554555
) {
555-
return \Magento\ImportExport\Model\Import::getDefaultBehavior();
556+
return ImportExport::getDefaultBehavior();
556557
}
557558
return $this->_parameters['behavior'];
558559
}
@@ -604,7 +605,7 @@ public function getProcessedRowsCount()
604605
public function getSource()
605606
{
606607
if (!$this->_source) {
607-
throw new \Magento\Framework\Exception\LocalizedException(__('The source is not set.'));
608+
throw new LocalizedException(__('The source is not set.'));
608609
}
609610
return $this->_source;
610611
}
@@ -879,7 +880,7 @@ public function getValidColumnNames()
879880
protected function getMetadataPool()
880881
{
881882
if (!$this->metadataPool) {
882-
$this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance()
883+
$this->metadataPool = ObjectManager::getInstance()
883884
->get(\Magento\Framework\EntityManager\MetadataPool::class);
884885
}
885886
return $this->metadataPool;

0 commit comments

Comments
 (0)