From de385ed9de6c9bc0ca602085816d161096562b41 Mon Sep 17 00:00:00 2001 From: Vitaliy Prokopoov Date: Thu, 11 Feb 2021 15:49:35 +0200 Subject: [PATCH] Updated classes and interfaces and marked them as API --- .../Magento/Catalog/Model/Layer/Resolver.php | 11 +- app/code/Magento/Sales/Setup/SalesSetup.php | 37 ++-- .../Framework/Api/SearchCriteriaBuilder.php | 91 +++++++-- lib/internal/Magento/Framework/App/Area.php | 97 +++++----- .../Magento/Framework/App/Request/Http.php | 21 +- .../Framework/Controller/Result/Forward.php | 13 +- .../Magento/Framework/DB/Transaction.php | 50 ++--- .../Magento/Framework/DataObject/Factory.php | 5 + lib/internal/Magento/Framework/File/Csv.php | 19 +- .../Magento/Framework/Filesystem/Io/File.php | 181 +++++++++--------- .../Magento/Framework/HTTP/Client/Curl.php | 118 ++++++------ .../HTTP/PhpEnvironment/RemoteAddress.php | 6 +- .../Magento/Framework/Module/Manager.php | 59 +----- .../Module/Test/Unit/ManagerTest.php | 62 ------ .../Magento/Framework/Webapi/Exception.php | 32 ++-- 15 files changed, 384 insertions(+), 418 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Layer/Resolver.php b/app/code/Magento/Catalog/Model/Layer/Resolver.php index ed911a1eb1b3e..ea832ab38b755 100644 --- a/app/code/Magento/Catalog/Model/Layer/Resolver.php +++ b/app/code/Magento/Catalog/Model/Layer/Resolver.php @@ -6,6 +6,11 @@ */ namespace Magento\Catalog\Model\Layer; +/** + * Class Resolver + * + * @api + */ class Resolver { const CATALOG_LAYER_CATEGORY = 'category'; @@ -16,19 +21,19 @@ class Resolver * * @var array */ - protected $layersPool; + private $layersPool; /** * Filter factory * * @var \Magento\Framework\ObjectManagerInterface */ - protected $objectManager; + private $objectManager; /** * @var \Magento\Catalog\Model\Layer */ - protected $layer = null; + private $layer = null; /** * @param \Magento\Framework\ObjectManagerInterface $objectManager diff --git a/app/code/Magento/Sales/Setup/SalesSetup.php b/app/code/Magento/Sales/Setup/SalesSetup.php index 4be2b38b074e7..728a587b64cbd 100644 --- a/app/code/Magento/Sales/Setup/SalesSetup.php +++ b/app/code/Magento/Sales/Setup/SalesSetup.php @@ -19,6 +19,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @codeCoverageIgnore + * @api */ class SalesSetup extends EavSetup { @@ -45,12 +46,12 @@ class SalesSetup extends EavSetup /** * @var ScopeConfigInterface */ - protected $config; + private $config; /** * @var EncryptorInterface */ - protected $encryptor; + private $encryptor; /** * @var string @@ -81,9 +82,9 @@ public function __construct( /** * List of entities converted from EAV to flat data structure * - * @var $_flatEntityTables array + * @var array $flatEntityTables */ - protected $_flatEntityTables = [ + private $flatEntityTables = [ 'order' => 'sales_order', 'order_payment' => 'sales_order_payment', 'order_item' => 'sales_order_item', @@ -104,9 +105,9 @@ public function __construct( /** * List of entities used with separate grid table * - * @var string[] $_flatEntitiesGrid + * @var string[] $flatEntitiesGrid */ - protected $_flatEntitiesGrid = ['order', 'invoice', 'shipment', 'creditmemo']; + private $flatEntitiesGrid = ['order', 'invoice', 'shipment', 'creditmemo']; /** * Check if table exist for flat entity @@ -114,7 +115,7 @@ public function __construct( * @param string $table * @return bool */ - protected function _flatTableExist($table) + private function flatTableExist($table) { $tablesList = $this->getConnection() ->listTables(); @@ -135,13 +136,13 @@ protected function _flatTableExist($table) public function addAttribute($entityTypeId, $code, array $attr) { if (isset( - $this->_flatEntityTables[$entityTypeId] - ) && $this->_flatTableExist( - $this->_flatEntityTables[$entityTypeId] + $this->flatEntityTables[$entityTypeId] + ) && $this->flatTableExist( + $this->flatEntityTables[$entityTypeId] ) ) { - $this->_addFlatAttribute($this->_flatEntityTables[$entityTypeId], $code, $attr); - $this->_addGridAttribute($this->_flatEntityTables[$entityTypeId], $code, $attr, $entityTypeId); + $this->addFlatAttribute($this->flatEntityTables[$entityTypeId], $code, $attr); + $this->addGridAttribute($this->flatEntityTables[$entityTypeId], $code, $attr, $entityTypeId); } else { parent::addAttribute($entityTypeId, $code, $attr); } @@ -156,14 +157,14 @@ public function addAttribute($entityTypeId, $code, array $attr) * @param array $attr * @return $this */ - protected function _addFlatAttribute($table, $attribute, $attr) + private function addFlatAttribute($table, $attribute, $attr) { $tableInfo = $this->getConnection() ->describeTable($this->getTable($table)); if (isset($tableInfo[$attribute])) { return $this; } - $columnDefinition = $this->_getAttributeColumnDefinition($attribute, $attr); + $columnDefinition = $this->getAttributeColumnDefinition($attribute, $attr); $this->getConnection()->addColumn( $this->getTable($table), $attribute, @@ -181,10 +182,10 @@ protected function _addFlatAttribute($table, $attribute, $attr) * @param string $entityTypeId * @return $this */ - protected function _addGridAttribute($table, $attribute, $attr, $entityTypeId) + private function addGridAttribute($table, $attribute, $attr, $entityTypeId) { - if (in_array($entityTypeId, $this->_flatEntitiesGrid) && !empty($attr['grid'])) { - $columnDefinition = $this->_getAttributeColumnDefinition($attribute, $attr); + if (in_array($entityTypeId, $this->flatEntitiesGrid) && !empty($attr['grid'])) { + $columnDefinition = $this->getAttributeColumnDefinition($attribute, $attr); $this->getConnection()->addColumn( $this->getTable($table . '_grid'), $attribute, @@ -203,7 +204,7 @@ protected function _addGridAttribute($table, $attribute, $attr, $entityTypeId) * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ - protected function _getAttributeColumnDefinition($code, $data) + private function getAttributeColumnDefinition($code, $data) { // Convert attribute type to column info $data['type'] = isset($data['type']) ? $data['type'] : 'varchar'; diff --git a/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php b/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php index 4cf7a8fbef9ed..9cfdb4096d272 100644 --- a/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php +++ b/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php @@ -6,22 +6,36 @@ namespace Magento\Framework\Api; +use Magento\Framework\Api\Search\FilterGroup; use Magento\Framework\Api\Search\FilterGroupBuilder; +use Magento\Framework\Api\SimpleBuilderInterface; /** * Builder for SearchCriteria Service Data Object + * + * @api */ -class SearchCriteriaBuilder extends AbstractSimpleObjectBuilder +class SearchCriteriaBuilder implements SimpleBuilderInterface { + /** + * @var array + */ + private $data; + /** * @var FilterGroupBuilder */ - protected $_filterGroupBuilder; + private $filterGroupBuilder; + + /** + * @var FilterBuilder + */ + private $filterBuilder; /** - * @var \Magento\Framework\Api\FilterBuilder + * @var ObjectFactory */ - protected $filterBuilder; + private $objectFactory; /** * @param ObjectFactory $objectFactory @@ -33,11 +47,9 @@ public function __construct( FilterGroupBuilder $filterGroupBuilder, FilterBuilder $filterBuilder ) { - parent::__construct( - $objectFactory - ); - $this->_filterGroupBuilder = $filterGroupBuilder; + $this->filterGroupBuilder = $filterGroupBuilder; $this->filterBuilder = $filterBuilder; + $this->objectFactory = $objectFactory; } /** @@ -49,20 +61,51 @@ public function create() { //Initialize with empty array if not set if (empty($this->data[SearchCriteria::FILTER_GROUPS])) { - $this->_set(SearchCriteria::FILTER_GROUPS, []); + $this->set(SearchCriteria::FILTER_GROUPS, []); + } + + $dataObjectType = $this->getDataObjectType(); + $dataObject = $this->objectFactory->create($dataObjectType, ['data' => $this->data]); + $this->data = []; + + return $dataObject; + } + + /** + * Return the Data type class name + * + * @return string + */ + private function getDataObjectType() + { + $dataObjectType = ''; + $pattern = '/(?.*?)Builder(\\Interceptor)?/'; + if (preg_match($pattern, get_class($this), $match)) { + $dataObjectType = $match['data_object']; } - return parent::create(); + + return $dataObjectType; + } + + /** + * Return data Object data. + * + * @return array + */ + public function getData() + { + return $this->data; } /** * Create a filter group based on the filter array provided and add to the filter groups * - * @param \Magento\Framework\Api\Filter[] $filter + * @param Filter[] $filter * @return $this */ public function addFilters(array $filter) { - $this->data[SearchCriteria::FILTER_GROUPS][] = $this->_filterGroupBuilder->setFilters($filter)->create(); + $this->data[SearchCriteria::FILTER_GROUPS][] = $this->filterGroupBuilder->setFilters($filter)->create(); return $this; } @@ -86,12 +129,12 @@ public function addFilter($field, $value, $conditionType = 'eq') /** * Set filter groups * - * @param \Magento\Framework\Api\Search\FilterGroup[] $filterGroups + * @param FilterGroup[] $filterGroups * @return $this */ public function setFilterGroups(array $filterGroups) { - return $this->_set(SearchCriteria::FILTER_GROUPS, $filterGroups); + return $this->set(SearchCriteria::FILTER_GROUPS, $filterGroups); } /** @@ -117,7 +160,7 @@ public function addSortOrder($sortOrder) */ public function setSortOrders(array $sortOrders) { - return $this->_set(SearchCriteria::SORT_ORDERS, $sortOrders); + return $this->set(SearchCriteria::SORT_ORDERS, $sortOrders); } /** @@ -128,7 +171,7 @@ public function setSortOrders(array $sortOrders) */ public function setPageSize($pageSize) { - return $this->_set(SearchCriteria::PAGE_SIZE, $pageSize); + return $this->set(SearchCriteria::PAGE_SIZE, $pageSize); } /** @@ -139,6 +182,20 @@ public function setPageSize($pageSize) */ public function setCurrentPage($currentPage) { - return $this->_set(SearchCriteria::CURRENT_PAGE, $currentPage); + return $this->set(SearchCriteria::CURRENT_PAGE, $currentPage); + } + + /** + * Overwrite data in Object. + * + * @param string $key + * @param mixed $value + * @return $this + */ + private function set($key, $value) + { + $this->data[$key] = $value; + + return $this; } } diff --git a/lib/internal/Magento/Framework/App/Area.php b/lib/internal/Magento/Framework/App/Area.php index 4bc7c769caf19..d7c70130a9ba9 100644 --- a/lib/internal/Magento/Framework/App/Area.php +++ b/lib/internal/Magento/Framework/App/Area.php @@ -12,6 +12,7 @@ * Application area model * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @api */ class Area implements \Magento\Framework\App\AreaInterface { @@ -39,62 +40,62 @@ class Area implements \Magento\Framework\App\AreaInterface * * @var array */ - protected $_loadedParts; + private $loadedParts; /** * Area code * * @var string */ - protected $_code; + private $code; /** * Event Manager * * @var \Magento\Framework\Event\ManagerInterface */ - protected $_eventManager; + private $eventManager; /** * Translator * * @var \Magento\Framework\TranslateInterface */ - protected $_translator; + private $translator; /** * Object manager * * @var \Magento\Framework\ObjectManagerInterface */ - protected $_objectManager; + private $objectManager; /** * @var ConfigLoaderInterface */ - protected $_diConfigLoader; + private $diConfigLoader; /** * @var \Psr\Log\LoggerInterface */ - protected $_logger; + private $logger; /** * Core design * * @var \Magento\Framework\App\DesignInterface */ - protected $_design; + private $design; /** * @var \Magento\Framework\App\ScopeResolverInterface */ - protected $_scopeResolver; + private $scopeResolver; /** * @var \Magento\Framework\View\DesignExceptions */ - protected $_designExceptions; + private $designExceptions; /** * @param \Psr\Log\LoggerInterface $logger @@ -118,15 +119,15 @@ public function __construct( \Magento\Framework\View\DesignExceptions $designExceptions, $areaCode ) { - $this->_code = $areaCode; - $this->_objectManager = $objectManager; - $this->_diConfigLoader = $diConfigLoader; - $this->_eventManager = $eventManager; - $this->_translator = $translator; - $this->_logger = $logger; - $this->_design = $design; - $this->_scopeResolver = $scopeResolver; - $this->_designExceptions = $designExceptions; + $this->code = $areaCode; + $this->objectManager = $objectManager; + $this->diConfigLoader = $diConfigLoader; + $this->eventManager = $eventManager; + $this->translator = $translator; + $this->logger = $logger; + $this->design = $design; + $this->scopeResolver = $scopeResolver; + $this->designExceptions = $designExceptions; } /** @@ -138,9 +139,9 @@ public function __construct( public function load($part = null) { if ($part === null) { - $this->_loadPart(self::PART_CONFIG)->_loadPart(self::PART_DESIGN)->_loadPart(self::PART_TRANSLATE); + $this->loadPart(self::PART_CONFIG)->loadPart(self::PART_DESIGN)->loadPart(self::PART_TRANSLATE); } else { - $this->_loadPart($part); + $this->loadPart($part); } return $this; } @@ -153,13 +154,13 @@ public function load($part = null) */ public function detectDesign($request = null) { - if ($this->_code == self::AREA_FRONTEND) { - $isDesignException = $request && $this->_applyUserAgentDesignException($request); + if ($this->code == self::AREA_FRONTEND) { + $isDesignException = $request && $this->applyUserAgentDesignException($request); if (!$isDesignException) { - $this->_design->loadChange( - $this->_scopeResolver->getScope()->getId() + $this->design->loadChange( + $this->scopeResolver->getScope()->getId() )->changeDesign( - $this->_getDesign() + $this->getDesign() ); } } @@ -171,16 +172,16 @@ public function detectDesign($request = null) * @param \Magento\Framework\App\RequestInterface $request * @return bool */ - protected function _applyUserAgentDesignException($request) + private function applyUserAgentDesignException($request) { try { - $theme = $this->_designExceptions->getThemeByRequest($request); + $theme = $this->designExceptions->getThemeByRequest($request); if (false !== $theme) { - $this->_getDesign()->setDesignTheme($theme); + $this->getDesign()->setDesignTheme($theme); return true; } } catch (\Exception $e) { - $this->_logger->critical($e); + $this->logger->critical($e); } return false; } @@ -188,9 +189,9 @@ protected function _applyUserAgentDesignException($request) /** * @return \Magento\Framework\View\DesignInterface */ - protected function _getDesign() + private function getDesign() { - return $this->_objectManager->get(\Magento\Framework\View\DesignInterface::class); + return $this->objectManager->get(\Magento\Framework\View\DesignInterface::class); } /** @@ -199,28 +200,28 @@ protected function _getDesign() * @param string $part * @return $this */ - protected function _loadPart($part) + private function loadPart($part) { - if (isset($this->_loadedParts[$part])) { + if (isset($this->loadedParts[$part])) { return $this; } \Magento\Framework\Profiler::start( - 'load_area:' . $this->_code . '.' . $part, - ['group' => 'load_area', 'area_code' => $this->_code, 'part' => $part] + 'load_area:' . $this->code . '.' . $part, + ['group' => 'load_area', 'area_code' => $this->code, 'part' => $part] ); switch ($part) { case self::PART_CONFIG: - $this->_initConfig(); + $this->initConfig(); break; case self::PART_TRANSLATE: - $this->_initTranslate(); + $this->initTranslate(); break; case self::PART_DESIGN: - $this->_initDesign(); + $this->initDesign(); break; } - $this->_loadedParts[$part] = true; - \Magento\Framework\Profiler::stop('load_area:' . $this->_code . '.' . $part); + $this->loadedParts[$part] = true; + \Magento\Framework\Profiler::stop('load_area:' . $this->code . '.' . $part); return $this; } @@ -229,9 +230,9 @@ protected function _loadPart($part) * * @return $this */ - protected function _initConfig() + private function initConfig() { - $this->_objectManager->configure($this->_diConfigLoader->load($this->_code)); + $this->objectManager->configure($this->diConfigLoader->load($this->code)); return $this; } @@ -240,12 +241,12 @@ protected function _initConfig() * * @return $this */ - protected function _initTranslate() + private function initTranslate() { - $this->_translator->loadData(null, false); + $this->translator->loadData(null, false); \Magento\Framework\Phrase::setRenderer( - $this->_objectManager->get(\Magento\Framework\Phrase\RendererInterface::class) + $this->objectManager->get(\Magento\Framework\Phrase\RendererInterface::class) ); return $this; @@ -256,9 +257,9 @@ protected function _initTranslate() * * @return $this */ - protected function _initDesign() + private function initDesign() { - $this->_getDesign()->setArea($this->_code)->setDefaultDesignTheme(); + $this->getDesign()->setArea($this->code)->setDefaultDesignTheme(); return $this; } } diff --git a/lib/internal/Magento/Framework/App/Request/Http.php b/lib/internal/Magento/Framework/App/Request/Http.php index 961e871fbfa91..5445b1a11583b 100644 --- a/lib/internal/Magento/Framework/App/Request/Http.php +++ b/lib/internal/Magento/Framework/App/Request/Http.php @@ -17,6 +17,7 @@ /** * Http request * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) + * @api */ class Http extends Request implements RequestContentInterface, RequestSafetyInterface, HttpRequestInterface { @@ -33,7 +34,7 @@ class Http extends Request implements RequestContentInterface, RequestSafetyInte /** * @var string */ - protected $route; + private $route; /** * PATH_INFO @@ -47,49 +48,49 @@ class Http extends Request implements RequestContentInterface, RequestSafetyInte * * @var string */ - protected $originalPathInfo = ''; + private $originalPathInfo = ''; /** * @var array */ - protected $directFrontNames; + private $directFrontNames; /** * @var string */ - protected $controllerModule; + private $controllerModule; /** * Request's original information before forward. * * @var array */ - protected $beforeForwardInfo = []; + private $beforeForwardInfo = []; /** * @var ConfigInterface */ - protected $routeConfig; + private $routeConfig; /** * @var PathInfoProcessorInterface */ - protected $pathInfoProcessor; + private $pathInfoProcessor; /** * @var ObjectManagerInterface */ - protected $objectManager; + private $objectManager; /** * @var bool|null */ - protected $isSafeMethod = null; + private $isSafeMethod = null; /** * @var array */ - protected $safeRequestTypes = ['GET', 'HEAD', 'TRACE', 'OPTIONS']; + private $safeRequestTypes = ['GET', 'HEAD', 'TRACE', 'OPTIONS']; /** * @var string diff --git a/lib/internal/Magento/Framework/Controller/Result/Forward.php b/lib/internal/Magento/Framework/Controller/Result/Forward.php index 51409e6d3833a..dbb0710ef5726 100644 --- a/lib/internal/Magento/Framework/Controller/Result/Forward.php +++ b/lib/internal/Magento/Framework/Controller/Result/Forward.php @@ -10,27 +10,32 @@ use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface; use Magento\Framework\Controller\AbstractResult; +/** + * Class Forward + * + * @api + */ class Forward extends AbstractResult { /** * @var \Magento\Framework\App\RequestInterface */ - protected $request; + private $request; /** * @var string */ - protected $module; + private $module; /** * @var string */ - protected $controller; + private $controller; /** * @var array */ - protected $params = []; + private $params = []; /** * @param RequestInterface $request diff --git a/lib/internal/Magento/Framework/DB/Transaction.php b/lib/internal/Magento/Framework/DB/Transaction.php index 8d3fc8fff9fd5..04327a85abc62 100644 --- a/lib/internal/Magento/Framework/DB/Transaction.php +++ b/lib/internal/Magento/Framework/DB/Transaction.php @@ -9,6 +9,8 @@ * DB transaction model * * @todo need collect connection by name + * + * @api */ class Transaction { @@ -17,30 +19,30 @@ class Transaction * * @var array */ - protected $_objects = []; + protected $objects = []; /** * Transaction objects array with alias key * * @var array */ - protected $_objectsByAlias = []; + private $objectsByAlias = []; /** * Callbacks array. * * @var array */ - protected $_beforeCommitCallbacks = []; + private $beforeCommitCallbacks = []; /** * Begin transaction for all involved object resources * * @return $this */ - protected function _startTransaction() + private function startTransaction() { - foreach ($this->_objects as $object) { + foreach ($this->objects as $object) { $object->getResource()->beginTransaction(); } return $this; @@ -51,9 +53,9 @@ protected function _startTransaction() * * @return $this */ - protected function _commitTransaction() + private function commitTransaction() { - foreach ($this->_objects as $object) { + foreach ($this->objects as $object) { $object->getResource()->commit(); } return $this; @@ -64,9 +66,9 @@ protected function _commitTransaction() * * @return $this */ - protected function _rollbackTransaction() + private function rollbackTransaction() { - foreach ($this->_objects as $object) { + foreach ($this->objects as $object) { $object->getResource()->rollBack(); } return $this; @@ -77,9 +79,9 @@ protected function _rollbackTransaction() * * @return $this */ - protected function _runCallbacks() + private function runCallbacks() { - foreach ($this->_beforeCommitCallbacks as $callback) { + foreach ($this->beforeCommitCallbacks as $callback) { call_user_func($callback); } return $this; @@ -94,9 +96,9 @@ protected function _runCallbacks() */ public function addObject(\Magento\Framework\Model\AbstractModel $object, $alias = '') { - $this->_objects[] = $object; + $this->objects[] = $object; if (!empty($alias)) { - $this->_objectsByAlias[$alias] = $object; + $this->objectsByAlias[$alias] = $object; } return $this; } @@ -109,7 +111,7 @@ public function addObject(\Magento\Framework\Model\AbstractModel $object, $alias */ public function addCommitCallback($callback) { - $this->_beforeCommitCallbacks[] = $callback; + $this->beforeCommitCallbacks[] = $callback; return $this; } @@ -121,11 +123,11 @@ public function addCommitCallback($callback) */ public function save() { - $this->_startTransaction(); + $this->startTransaction(); $error = false; try { - foreach ($this->_objects as $object) { + foreach ($this->objects as $object) { $object->save(); } } catch (\Exception $e) { @@ -134,17 +136,17 @@ public function save() if ($error === false) { try { - $this->_runCallbacks(); + $this->runCallbacks(); } catch (\Exception $e) { $error = $e; } } if ($error) { - $this->_rollbackTransaction(); + $this->rollbackTransaction(); throw $error; } else { - $this->_commitTransaction(); + $this->commitTransaction(); } return $this; @@ -158,11 +160,11 @@ public function save() */ public function delete() { - $this->_startTransaction(); + $this->startTransaction(); $error = false; try { - foreach ($this->_objects as $object) { + foreach ($this->objects as $object) { $object->delete(); } } catch (\Exception $e) { @@ -171,17 +173,17 @@ public function delete() if ($error === false) { try { - $this->_runCallbacks(); + $this->runCallbacks(); } catch (\Exception $e) { $error = $e; } } if ($error) { - $this->_rollbackTransaction(); + $this->rollbackTransaction(); throw $error; } else { - $this->_commitTransaction(); + $this->commitTransaction(); } return $this; } diff --git a/lib/internal/Magento/Framework/DataObject/Factory.php b/lib/internal/Magento/Framework/DataObject/Factory.php index 2fd16b7159c4f..3572710bb89af 100644 --- a/lib/internal/Magento/Framework/DataObject/Factory.php +++ b/lib/internal/Magento/Framework/DataObject/Factory.php @@ -5,6 +5,11 @@ */ namespace Magento\Framework\DataObject; +/** + * Class Factory + * + * @api + */ class Factory { /** diff --git a/lib/internal/Magento/Framework/File/Csv.php b/lib/internal/Magento/Framework/File/Csv.php index e33b38562bf57..4df6f84c7a2e8 100644 --- a/lib/internal/Magento/Framework/File/Csv.php +++ b/lib/internal/Magento/Framework/File/Csv.php @@ -12,23 +12,24 @@ * Csv parse * * @author Magento Core Team + * @api */ class Csv { /** * @var int */ - protected $_lineLength = 0; + private $lineLength = 0; /** * @var string */ - protected $_delimiter = ','; + private $delimiter = ','; /** * @var string */ - protected $_enclosure = '"'; + private $enclosure = '"'; /** * @var string @@ -38,7 +39,7 @@ class Csv /** * @var File */ - protected $file; + private $file; /** * Constructor @@ -58,7 +59,7 @@ public function __construct(File $file) */ public function setLineLength($length) { - $this->_lineLength = $length; + $this->lineLength = $length; return $this; } @@ -70,7 +71,7 @@ public function setLineLength($length) */ public function setDelimiter($delimiter) { - $this->_delimiter = $delimiter; + $this->delimiter = $delimiter; return $this; } @@ -82,7 +83,7 @@ public function setDelimiter($delimiter) */ public function setEnclosure($enclosure) { - $this->_enclosure = $enclosure; + $this->enclosure = $enclosure; return $this; } @@ -101,7 +102,7 @@ public function getData($file) } $fh = fopen($file, 'r'); - while ($rowData = fgetcsv($fh, $this->_lineLength, $this->_delimiter, $this->_enclosure, $this->escape)) { + while ($rowData = fgetcsv($fh, $this->lineLength, $this->delimiter, $this->enclosure, $this->escape)) { $data[] = $rowData; } fclose($fh); @@ -158,7 +159,7 @@ public function appendData($file, $data, $mode = 'w') { $fileHandler = fopen($file, $mode); foreach ($data as $dataRow) { - $this->file->filePutCsv($fileHandler, $dataRow, $this->_delimiter, $this->_enclosure); + $this->file->filePutCsv($fileHandler, $dataRow, $this->delimiter, $this->enclosure); } fclose($fileHandler); diff --git a/lib/internal/Magento/Framework/Filesystem/Io/File.php b/lib/internal/Magento/Framework/Filesystem/Io/File.php index 70608194b726b..8dd49e71c2fac 100644 --- a/lib/internal/Magento/Framework/Filesystem/Io/File.php +++ b/lib/internal/Magento/Framework/Filesystem/Io/File.php @@ -13,23 +13,10 @@ * Filesystem client * * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @api */ class File extends AbstractIo { - /** - * Save initial working directory - * - * @var string - */ - protected $_iwd; - - /** - * Use virtual current working directory for application integrity - * - * @var string - */ - protected $_cwd; - /** * Used to grep ls() output * @@ -53,38 +40,52 @@ class File extends AbstractIo */ protected $_allowCreateFolders = false; + /** + * Save initial working directory + * + * @var string + */ + private $iwd; + + /** + * Use virtual current working directory for application integrity + * + * @var string + */ + private $cwd; + /** * Stream open file pointer * * @var resource */ - protected $_streamHandler; + private $streamHandler; /** * Stream mode filename * * @var string */ - protected $_streamFileName; + private $streamFileName; /** * Stream mode chmod * * @var string */ - protected $_streamChmod; + private $streamChmod; /** * Lock file * * @var bool */ - protected $_streamLocked = false; + private $streamLocked = false; /** * @var \Exception */ - private $_streamException; + private $streamException; /** * Destruct @@ -93,7 +94,7 @@ class File extends AbstractIo */ public function __destruct() { - if ($this->_streamHandler) { + if ($this->streamHandler) { $this->streamClose(); } } @@ -106,12 +107,12 @@ public function __destruct() */ public function streamLock($exclusive = true) { - if (!$this->_streamHandler) { + if (!$this->streamHandler) { return false; } - $this->_streamLocked = true; + $this->streamLocked = true; $lock = $exclusive ? LOCK_EX : LOCK_SH; - return flock($this->_streamHandler, $lock); + return flock($this->streamHandler, $lock); } /** @@ -121,11 +122,11 @@ public function streamLock($exclusive = true) */ public function streamUnlock() { - if (!$this->_streamHandler || !$this->_streamLocked) { + if (!$this->streamHandler || !$this->streamLocked) { return false; } - $this->_streamLocked = false; - return flock($this->_streamHandler, LOCK_UN); + $this->streamLocked = false; + return flock($this->streamHandler, LOCK_UN); } /** @@ -136,13 +137,13 @@ public function streamUnlock() */ public function streamRead($length = 1024) { - if (!$this->_streamHandler) { + if (!$this->streamHandler) { return false; } - if (feof($this->_streamHandler)) { + if (feof($this->streamHandler)) { return false; } - return @fgets($this->_streamHandler, $length); + return @fgets($this->streamHandler, $length); } /** @@ -154,10 +155,10 @@ public function streamRead($length = 1024) */ public function streamReadCsv($delimiter = ',', $enclosure = '"') { - if (!$this->_streamHandler) { + if (!$this->streamHandler) { return false; } - return @fgetcsv($this->_streamHandler, 0, $delimiter, $enclosure); + return @fgetcsv($this->streamHandler, 0, $delimiter, $enclosure); } /** @@ -168,10 +169,10 @@ public function streamReadCsv($delimiter = ',', $enclosure = '"') */ public function streamWrite($str) { - if (!$this->_streamHandler) { + if (!$this->streamHandler) { return false; } - return @fwrite($this->_streamHandler, $str); + return @fwrite($this->streamHandler, $str); } /** @@ -184,7 +185,7 @@ public function streamWrite($str) */ public function streamWriteCsv(array $row, $delimiter = ',', $enclosure = '"') { - if (!$this->_streamHandler) { + if (!$this->streamHandler) { return false; } /** @@ -201,7 +202,7 @@ public function streamWriteCsv(array $row, $delimiter = ',', $enclosure = '"') $row[$key] = ' ' . $value; } } - return @fputcsv($this->_streamHandler, $row, $delimiter, $enclosure); + return @fputcsv($this->streamHandler, $row, $delimiter, $enclosure); } /** @@ -213,15 +214,15 @@ public function streamWriteCsv(array $row, $delimiter = ',', $enclosure = '"') */ public function streamClose() { - if (!$this->_streamHandler) { + if (!$this->streamHandler) { return false; } - if ($this->_streamLocked) { + if ($this->streamLocked) { $this->streamUnlock(); } - @fclose($this->_streamHandler); - $this->chmod($this->_streamFileName, $this->_streamChmod); + @fclose($this->streamHandler); + $this->chmod($this->streamFileName, $this->streamChmod); return true; } @@ -234,10 +235,10 @@ public function streamClose() */ public function streamStat($part = null, $default = null) { - if (!$this->_streamHandler) { + if (!$this->streamHandler) { return false; } - $stat = @fstat($this->_streamHandler); + $stat = @fstat($this->streamHandler); if ($part !== null) { return $stat[$part] ?? $default; } @@ -251,7 +252,7 @@ public function streamStat($part = null, $default = null) */ public function getStreamException() { - return $this->_streamException; + return $this->streamException; } /** @@ -268,13 +269,13 @@ public function open(array $args = []) if (!empty($args['path'])) { if ($args['path']) { if ($this->_allowCreateFolders) { - $this->_createDestinationFolder($args['path']); + $this->createDestinationFolder($args['path']); } } } - $this->_iwd = getcwd(); - $this->cd(!empty($args['path']) ? $args['path'] : $this->_iwd); + $this->iwd = getcwd(); + $this->cd(!empty($args['path']) ? $args['path'] : $this->iwd); return true; } @@ -311,9 +312,9 @@ public function close() */ public function mkdir($dir, $mode = 0777, $recursive = true) { - $this->_cwd(); + $this->cwd(); $result = @mkdir($dir, $mode, $recursive); - $this->_iwd(); + $this->iwd(); return $result; } @@ -326,9 +327,9 @@ public function mkdir($dir, $mode = 0777, $recursive = true) */ public function rmdir($dir, $recursive = false) { - $this->_cwd(); + $this->cwd(); $result = self::rmdirRecursive($dir, $recursive); - $this->_iwd(); + $this->iwd(); return $result; } @@ -342,7 +343,7 @@ public function rmdir($dir, $recursive = false) public static function rmdirRecursive($dir, $recursive = true) { if ($recursive) { - $result = self::_recursiveCallback($dir, ['unlink'], ['rmdir']); + $result = self::recursiveCallback($dir, ['unlink'], ['rmdir']); } else { $result = @rmdir($dir); } @@ -364,7 +365,7 @@ public static function rmdirRecursive($dir, $recursive = true) * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ - protected static function _recursiveCallback($dir, array $fileCallback, array $dirCallback = []) + private static function recursiveCallback($dir, array $fileCallback, array $dirCallback = []) { if (empty($fileCallback) || !is_array($fileCallback) || !is_array($dirCallback)) { throw new \InvalidArgumentException("file/dir callback is not specified"); @@ -377,7 +378,7 @@ protected static function _recursiveCallback($dir, array $fileCallback, array $d if (!strcmp($item, '.') || !strcmp($item, '..')) { continue; } - self::_recursiveCallback($dir . '/' . $item, $fileCallback, $dirCallback); + self::recursiveCallback($dir . '/' . $item, $fileCallback, $dirCallback); } $callback = $dirCallback[0]; if (!is_callable($callback)) { @@ -404,7 +405,7 @@ protected static function _recursiveCallback($dir, array $fileCallback, array $d */ public function pwd() { - return $this->_cwd; + return $this->cwd; } /** @@ -418,8 +419,8 @@ public function pwd() public function cd($dir) { if (is_dir($dir)) { - $this->_iwd(); - $this->_cwd = realpath($dir); + $this->iwd(); + $this->cwd = realpath($dir); return true; } else { throw new LocalizedException( @@ -441,8 +442,8 @@ public function cd($dir) public function read($filename, $dest = null) { $result = false; - - $this->_cwd(); + + $this->cwd(); if ($dest === null) { $result = @file_get_contents($filename); } elseif (is_resource($dest)) { @@ -451,7 +452,7 @@ public function read($filename, $dest = null) } elseif (is_string($dest)) { $result = @copy($filename, $dest); } - $this->_iwd(); + $this->iwd(); return $result; } @@ -475,7 +476,7 @@ public function write($filename, $src, $mode = null) } else { return false; } - $this->_cwd(); + $this->cwd(); if (file_exists($filename)) { if (!is_writeable($filename)) { @@ -496,7 +497,7 @@ public function write($filename, $src, $mode = null) if ($mode !== null && $result !== false) { @chmod($filename, $mode); } - $this->_iwd(); + $this->iwd(); return $result; } @@ -509,12 +510,12 @@ public function write($filename, $src, $mode = null) */ public function fileExists($file, $onlyFile = true) { - $this->_cwd(); + $this->cwd(); $result = file_exists($file); if ($result && $onlyFile) { $result = is_file($file); } - $this->_iwd(); + $this->iwd(); return $result; } @@ -526,9 +527,9 @@ public function fileExists($file, $onlyFile = true) */ public function isWriteable($path) { - $this->_cwd(); + $this->cwd(); $result = is_writeable($path); - $this->_iwd(); + $this->iwd(); return $result; } @@ -558,7 +559,7 @@ public function createDestinationDir($path) if (!$this->_allowCreateFolders) { return false; } - return $this->_createDestinationFolder($this->getCleanPath($path)); + return $this->createDestinationFolder($this->getCleanPath($path)); } /** @@ -591,7 +592,7 @@ public function checkAndCreateFolder($folder, $mode = 0777) * @param string $destinationFolder * @return bool */ - private function _createDestinationFolder($destinationFolder) + private function createDestinationFolder($destinationFolder) { return $this->checkAndCreateFolder($destinationFolder); } @@ -605,9 +606,9 @@ private function _createDestinationFolder($destinationFolder) */ public function rm($filename) { - $this->_cwd(); + $this->cwd(); $result = @unlink($filename); - $this->_iwd(); + $this->iwd(); return $result; } @@ -621,9 +622,9 @@ public function rm($filename) */ public function mv($src, $destination) { - $this->_cwd(); + $this->cwd(); $result = @rename($src, $destination); - $this->_iwd(); + $this->iwd(); return $result; } @@ -637,9 +638,9 @@ public function mv($src, $destination) */ public function cp($src, $destination) { - $this->_cwd(); + $this->cwd(); $result = @copy($src, $destination); - $this->_iwd(); + $this->iwd(); return $result; } @@ -653,13 +654,13 @@ public function cp($src, $destination) */ public function chmod($filename, $mode, $recursive = false) { - $this->_cwd(); + $this->cwd(); if ($recursive) { $result = self::chmodRecursive($filename, $mode); } else { $result = @chmod($filename, $mode); } - $this->_iwd(); + $this->iwd(); return $result; } @@ -673,7 +674,7 @@ public function chmod($filename, $mode, $recursive = false) */ public static function chmodRecursive($dir, $mode) { - return self::_recursiveCallback($dir, ['chmod', [$mode]]); + return self::recursiveCallback($dir, ['chmod', [$mode]]); } /** @@ -696,10 +697,10 @@ public function ls($grep = null) { $ignoredDirectories = ['.', '..']; - if (is_dir($this->_cwd)) { - $dir = $this->_cwd; - } elseif (is_dir($this->_iwd)) { - $dir = $this->_iwd; + if (is_dir($this->cwd)) { + $dir = $this->cwd; + } elseif (is_dir($this->iwd)) { + $dir = $this->iwd; } else { throw new LocalizedException( new Phrase('Unable to list current working directory.') @@ -725,8 +726,8 @@ public function ls($grep = null) $listItem['text'] = $entry; $listItem['mod_date'] = date('Y-m-d H:i:s', filectime($fullPath)); - $listItem['permissions'] = $this->_parsePermissions(fileperms($fullPath)); - $listItem['owner'] = $this->_getFileOwner($fullPath); + $listItem['permissions'] = $this->parsePermissions(fileperms($fullPath)); + $listItem['owner'] = $this->getFileOwner($fullPath); if (is_file($fullPath)) { $pathInfo = pathinfo($fullPath); @@ -773,10 +774,10 @@ public function ls($grep = null) * * @return void */ - protected function _cwd() + private function cwd() { - if ($this->_cwd) { - chdir($this->_cwd); + if ($this->cwd) { + chdir($this->cwd); } } @@ -785,10 +786,10 @@ protected function _cwd() * * @return void */ - protected function _iwd() + private function iwd() { - if ($this->_iwd) { - chdir($this->_iwd); + if ($this->iwd) { + chdir($this->iwd); } } @@ -796,12 +797,12 @@ protected function _iwd() * Convert integer permissions format into human readable * * @param int $mode - * @access protected + * @access private * @return string * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ - protected function _parsePermissions($mode) + private function parsePermissions($mode) { if ($mode & 0x1000) { $type = 'p'; /* FIFO pipe */ @@ -856,7 +857,7 @@ protected function _parsePermissions($mode) * @param string $filename * @return string */ - protected function _getFileOwner($filename) + private function getFileOwner($filename) { if (!function_exists('posix_getpwuid')) { return 'n/a'; diff --git a/lib/internal/Magento/Framework/HTTP/Client/Curl.php b/lib/internal/Magento/Framework/HTTP/Client/Curl.php index 5379d481289f5..2c2533f8dea14 100644 --- a/lib/internal/Magento/Framework/HTTP/Client/Curl.php +++ b/lib/internal/Magento/Framework/HTTP/Client/Curl.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @api */ class Curl implements \Magento\Framework\HTTP\ClientInterface { @@ -23,73 +24,72 @@ class Curl implements \Magento\Framework\HTTP\ClientInterface * Hostname * @var string */ - protected $_host = 'localhost'; + private $host = 'localhost'; /** * Port * @var int */ - protected $_port = 80; + private $port = 80; /** * Stream resource * @var object */ - protected $_sock = null; + private $sock = null; /** * Request headers * @var array */ - protected $_headers = []; + private $headers = []; /** * Fields for POST method - hash * @var array */ - protected $_postFields = []; + private $postFields = []; /** * Request cookies * @var array */ - protected $_cookies = []; + private $cookies = []; /** * Response headers * @var array */ - protected $_responseHeaders = []; + private $responseHeaders = []; /** * Response body * @var string */ - protected $_responseBody = ''; + private $responseBody = ''; /** * Response status * @var int */ - protected $_responseStatus = 0; + private $responseStatus = 0; /** * Request timeout * @var int type */ - protected $_timeout = 300; + private $timeout = 300; /** - * TODO * @var int */ - protected $_redirectCount = 0; + private $redirectCount = 0; /** * Curl * @var resource */ - protected $_ch; + private $ch; /** * User overrides options hash @@ -97,14 +97,14 @@ class Curl implements \Magento\Framework\HTTP\ClientInterface * * @var array */ - protected $_curlUserOptions = []; + private $curlUserOptions = []; /** * Header count, used while parsing headers * in CURL callback function * @var int */ - protected $_headerCount = 0; + private $headerCount = 0; /** * Set request timeout @@ -114,7 +114,7 @@ class Curl implements \Magento\Framework\HTTP\ClientInterface */ public function setTimeout($value) { - $this->_timeout = (int)$value; + $this->timeout = (int)$value; } /** @@ -133,7 +133,7 @@ public function __construct($sslVersion = null) */ public function setHeaders($headers) { - $this->_headers = $headers; + $this->headers = $headers; } /** @@ -145,7 +145,7 @@ public function setHeaders($headers) */ public function addHeader($name, $value) { - $this->_headers[$name] = $value; + $this->headers[$name] = $value; } /** @@ -156,7 +156,7 @@ public function addHeader($name, $value) */ public function removeHeader($name) { - unset($this->_headers[$name]); + unset($this->headers[$name]); } /** @@ -183,7 +183,7 @@ public function setCredentials($login, $pass) */ public function addCookie($name, $value) { - $this->_cookies[$name] = $value; + $this->cookies[$name] = $value; } /** @@ -194,7 +194,7 @@ public function addCookie($name, $value) */ public function removeCookie($name) { - unset($this->_cookies[$name]); + unset($this->cookies[$name]); } /** @@ -205,7 +205,7 @@ public function removeCookie($name) */ public function setCookies($cookies) { - $this->_cookies = $cookies; + $this->cookies = $cookies; } /** @@ -253,7 +253,7 @@ public function post($uri, $params) */ public function getHeaders() { - return $this->_responseHeaders; + return $this->responseHeaders; } /** @@ -263,7 +263,7 @@ public function getHeaders() */ public function getBody() { - return $this->_responseBody; + return $this->responseBody; } /** @@ -273,11 +273,11 @@ public function getBody() */ public function getCookies() { - if (empty($this->_responseHeaders['Set-Cookie'])) { + if (empty($this->responseHeaders['Set-Cookie'])) { return []; } $out = []; - foreach ($this->_responseHeaders['Set-Cookie'] as $row) { + foreach ($this->responseHeaders['Set-Cookie'] as $row) { $values = explode("; ", $row); $c = count($values); if (!$c) { @@ -300,11 +300,11 @@ public function getCookies() */ public function getCookiesFull() { - if (empty($this->_responseHeaders['Set-Cookie'])) { + if (empty($this->responseHeaders['Set-Cookie'])) { return []; } $out = []; - foreach ($this->_responseHeaders['Set-Cookie'] as $row) { + foreach ($this->responseHeaders['Set-Cookie'] as $row) { $values = explode("; ", $row); $c = count($values); if (!$c) { @@ -337,7 +337,7 @@ public function getCookiesFull() */ public function getStatus() { - return $this->_responseStatus; + return $this->responseStatus; } /** @@ -354,9 +354,9 @@ public function getStatus() * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ - protected function makeRequest($method, $uri, $params = []) + private function makeRequest($method, $uri, $params = []) { - $this->_ch = curl_init(); + $this->ch = curl_init(); $this->curlOption(CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_FTP | CURLPROTO_FTPS); $this->curlOption(CURLOPT_URL, $uri); if ($method == 'POST') { @@ -368,28 +368,28 @@ protected function makeRequest($method, $uri, $params = []) $this->curlOption(CURLOPT_CUSTOMREQUEST, $method); } - if (count($this->_headers)) { + if (count($this->headers)) { $heads = []; - foreach ($this->_headers as $k => $v) { + foreach ($this->headers as $k => $v) { $heads[] = $k . ': ' . $v; } $this->curlOption(CURLOPT_HTTPHEADER, $heads); } - if (count($this->_cookies)) { + if (count($this->cookies)) { $cookies = []; - foreach ($this->_cookies as $k => $v) { + foreach ($this->cookies as $k => $v) { $cookies[] = "{$k}={$v}"; } $this->curlOption(CURLOPT_COOKIE, implode(";", $cookies)); } - if ($this->_timeout) { - $this->curlOption(CURLOPT_TIMEOUT, $this->_timeout); + if ($this->timeout) { + $this->curlOption(CURLOPT_TIMEOUT, $this->timeout); } - if ($this->_port != 80) { - $this->curlOption(CURLOPT_PORT, $this->_port); + if ($this->port != 80) { + $this->curlOption(CURLOPT_PORT, $this->port); } $this->curlOption(CURLOPT_RETURNTRANSFER, 1); @@ -398,20 +398,20 @@ protected function makeRequest($method, $uri, $params = []) $this->curlOption(CURLOPT_SSLVERSION, $this->sslVersion); } - if (count($this->_curlUserOptions)) { - foreach ($this->_curlUserOptions as $k => $v) { + if (count($this->curlUserOptions)) { + foreach ($this->curlUserOptions as $k => $v) { $this->curlOption($k, $v); } } - $this->_headerCount = 0; - $this->_responseHeaders = []; - $this->_responseBody = curl_exec($this->_ch); - $err = curl_errno($this->_ch); + $this->headerCount = 0; + $this->responseHeaders = []; + $this->responseBody = curl_exec($this->ch); + $err = curl_errno($this->ch); if ($err) { - $this->doError(curl_error($this->_ch)); + $this->doError(curl_error($this->ch)); } - curl_close($this->_ch); + curl_close($this->ch); } /** @@ -436,14 +436,14 @@ public function doError($string) * @throws \Exception * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - protected function parseHeaders($ch, $data) + private function parseHeaders($ch, $data) { - if ($this->_headerCount == 0) { + if ($this->headerCount == 0) { $line = explode(" ", trim($data), 3); if (count($line) < 2) { $this->doError("Invalid response line returned from server: " . $data); } - $this->_responseStatus = (int)$line[1]; + $this->responseStatus = (int)$line[1]; } else { $name = $value = ''; $out = explode(": ", trim($data), 2); @@ -454,13 +454,13 @@ protected function parseHeaders($ch, $data) if (strlen($name)) { if ('set-cookie' === strtolower($name)) { - $this->_responseHeaders['Set-Cookie'][] = $value; + $this->responseHeaders['Set-Cookie'][] = $value; } else { - $this->_responseHeaders[$name] = $value; + $this->responseHeaders[$name] = $value; } } } - $this->_headerCount++; + $this->headerCount++; return strlen($data); } @@ -472,9 +472,9 @@ protected function parseHeaders($ch, $data) * @param string $value * @return void */ - protected function curlOption($name, $value) + private function curlOption($name, $value) { - curl_setopt($this->_ch, $name, $value); + curl_setopt($this->ch, $name, $value); } /** @@ -483,9 +483,9 @@ protected function curlOption($name, $value) * @param array $arr * @return void */ - protected function curlOptions($arr) + private function curlOptions($arr) { - curl_setopt_array($this->_ch, $arr); + curl_setopt_array($this->ch, $arr); } /** @@ -496,7 +496,7 @@ protected function curlOptions($arr) */ public function setOptions($arr) { - $this->_curlUserOptions = $arr; + $this->curlUserOptions = $arr; } /** @@ -508,6 +508,6 @@ public function setOptions($arr) */ public function setOption($name, $value) { - $this->_curlUserOptions[$name] = $value; + $this->curlUserOptions[$name] = $value; } } diff --git a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/RemoteAddress.php b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/RemoteAddress.php index c505c82789f81..16cedcc1d5eb4 100644 --- a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/RemoteAddress.php +++ b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/RemoteAddress.php @@ -17,19 +17,19 @@ class RemoteAddress * * @var RequestInterface */ - protected $request; + private $request; /** * Remote address cache. * * @var string */ - protected $remoteAddress; + private $remoteAddress; /** * @var array */ - protected $alternativeHeaders; + private $alternativeHeaders; /** * @var string[]|null diff --git a/lib/internal/Magento/Framework/Module/Manager.php b/lib/internal/Magento/Framework/Module/Manager.php index 73ea68ac367c3..9cbb6ab9783bf 100644 --- a/lib/internal/Magento/Framework/Module/Manager.php +++ b/lib/internal/Magento/Framework/Module/Manager.php @@ -18,39 +18,23 @@ * ```php * $manager->isEnabled('Vendor_Module'); * ``` + * + * @api */ class Manager { - /** - * @var Output\ConfigInterface - * @deprecated 101.0.0 - */ - private $outputConfig; - /** * @var ModuleListInterface */ private $moduleList; /** - * @var array - * @deprecated 101.0.0 - */ - private $outputConfigPaths; - - /** - * @param Output\ConfigInterface $outputConfig * @param ModuleListInterface $moduleList - * @param array $outputConfigPaths */ public function __construct( - Output\ConfigInterface $outputConfig, - ModuleListInterface $moduleList, - array $outputConfigPaths = [] + ModuleListInterface $moduleList ) { - $this->outputConfig = $outputConfig; $this->moduleList = $moduleList; - $this->outputConfigPaths = $outputConfigPaths; } /** @@ -63,41 +47,4 @@ public function isEnabled($moduleName) { return $this->moduleList->has($moduleName); } - - /** - * Whether a module output is permitted by the configuration or not - * - * @param string $moduleName Fully-qualified module name - * @return boolean - * @deprecated 101.0.0 Magento does not support disabling/enabling modules output from the Admin Panel since 2.2.0 - * version. Module output can still be enabled/disabled in configuration files. However, this functionality should - * not be used in future development. Module design should explicitly state dependencies to avoid requiring output - * disabling. This functionality will temporarily be kept in Magento core, as there are unresolved modularity - * issues that will be addressed in future releases. - */ - public function isOutputEnabled($moduleName) - { - return $this->isEnabled($moduleName) - && $this->_isCustomOutputConfigEnabled($moduleName) - && !$this->outputConfig->isEnabled($moduleName); - } - - /** - * Whether a configuration switch for a module output permits output or not - * - * @param string $moduleName Fully-qualified module name - * @return boolean - * @deprecated 101.0.0 - */ - protected function _isCustomOutputConfigEnabled($moduleName) - { - if (isset($this->outputConfigPaths[$moduleName])) { - $configPath = $this->outputConfigPaths[$moduleName]; - if (defined($configPath)) { - $configPath = constant($configPath); - } - return $this->outputConfig->isSetFlag($configPath); - } - return true; - } } diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php index a619525704a70..34faefc966d37 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php @@ -30,11 +30,6 @@ class ManagerTest extends TestCase */ private $_moduleList; - /** - * @var MockObject - */ - private $_outputConfig; - /** * @inheritdoc */ @@ -50,9 +45,7 @@ protected function setUp(): void ['Module_Three', ['name' => 'Two_Three']], ] ); - $this->_outputConfig = $this->getMockForAbstractClass(ConfigInterface::class); $this->_model = new Manager( - $this->_outputConfig, $this->_moduleList, [ 'Module_Two' => self::XML_PATH_OUTPUT_ENABLED, @@ -71,59 +64,4 @@ public function testIsEnabled() $this->assertTrue($this->_model->isEnabled('Module_Exists')); $this->assertFalse($this->_model->isEnabled('Module_NotExists')); } - - public function testIsOutputEnabledReturnsFalseForDisabledModule() - { - $this->_outputConfig->expects($this->any())->method('isSetFlag')->willReturn(true); - $this->assertFalse($this->_model->isOutputEnabled('Disabled_Module')); - } - - /** - * @param bool $configValue - * @param bool $expectedResult - * @dataProvider isOutputEnabledGenericConfigPathDataProvider - */ - public function testIsOutputEnabledGenericConfigPath($configValue, $expectedResult) - { - $this->_moduleList->expects($this->once())->method('has')->willReturn(true); - $this->_outputConfig->expects($this->once()) - ->method('isEnabled') - ->with('Module_One') - ->willReturn($configValue); - $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_One')); - } - - /** - * @return array - */ - public function isOutputEnabledGenericConfigPathDataProvider() - { - return ['output disabled' => [true, false], 'output enabled' => [false, true]]; - } - - /** - * @param bool $configValue - * @param bool $expectedResult - * @dataProvider isOutputEnabledCustomConfigPathDataProvider - */ - public function testIsOutputEnabledCustomConfigPath($configValue, $expectedResult) - { - $this->_moduleList->expects($this->once())->method('has')->willReturn(true); - $this->_outputConfig->expects($this->at(0)) - ->method('isSetFlag') - ->with(self::XML_PATH_OUTPUT_ENABLED) - ->willReturn($configValue); - $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_Two')); - } - - /** - * @return array - */ - public function isOutputEnabledCustomConfigPathDataProvider() - { - return [ - 'path literal, output disabled' => [false, false], - 'path literal, output enabled' => [true, true], - ]; - } } diff --git a/lib/internal/Magento/Framework/Webapi/Exception.php b/lib/internal/Magento/Framework/Webapi/Exception.php index 97ebbc40865ab..c5e391f9a951c 100644 --- a/lib/internal/Magento/Framework/Webapi/Exception.php +++ b/lib/internal/Magento/Framework/Webapi/Exception.php @@ -16,6 +16,8 @@ * * During web API requests, all exceptions are converted to this exception, * which is then used for proper error response generation. + * + * @api */ class Exception extends LocalizedException { @@ -49,35 +51,35 @@ class Exception extends LocalizedException * * @var array */ - protected $_details; + private $details; /** * HTTP status code associated with current exception. * * @var int */ - protected $_httpCode; + private $httpCode; /** * Exception name is used for SOAP faults generation. * * @var string */ - protected $_name; + private $name; /** * Stacktrace * * @var string */ - protected $_stackTrace; + private $stackTrace; /** * List of errors * * @var null|\Magento\Framework\Exception\LocalizedException[] */ - protected $_errors; + private $errors; /** * Initialize exception with HTTP code. @@ -107,11 +109,11 @@ public function __construct( } parent::__construct($phrase, null, $code); $this->code = $code; - $this->_httpCode = $httpCode; - $this->_details = $details; - $this->_name = $name; - $this->_errors = $errors; - $this->_stackTrace = $stackTrace; + $this->httpCode = $httpCode; + $this->details = $details; + $this->name = $name; + $this->errors = $errors; + $this->stackTrace = $stackTrace; } /** @@ -121,7 +123,7 @@ public function __construct( */ public function getHttpCode() { - return $this->_httpCode; + return $this->httpCode; } /** @@ -141,7 +143,7 @@ public function getOriginator() */ public function getDetails() { - return $this->_details; + return $this->details; } /** @@ -151,7 +153,7 @@ public function getDetails() */ public function getName() { - return $this->_name; + return $this->name; } /** @@ -161,7 +163,7 @@ public function getName() */ public function getErrors() { - return $this->_errors; + return $this->errors; } /** @@ -171,6 +173,6 @@ public function getErrors() */ public function getStackTrace() { - return $this->_stackTrace; + return $this->stackTrace; } }