diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Renderer/RendererInterface.php b/lib/internal/Magento/Framework/Data/Form/Element/Renderer/RendererInterface.php index 18a0d30ba3a6d..7df31cc0c2f76 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Renderer/RendererInterface.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Renderer/RendererInterface.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\Data\Form\Element\Renderer; diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Reset.php b/lib/internal/Magento/Framework/Data/Form/Element/Reset.php index 6ece2e243637b..3c3d1869828db 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Reset.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Reset.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\Data\Form\Element; diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Select.php b/lib/internal/Magento/Framework/Data/Form/Element/Select.php index e0563c6fa75ad..8882e69360c1a 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Select.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Select.php @@ -1,7 +1,7 @@ * @since 100.0.2 */ class Select extends AbstractElement diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Submit.php b/lib/internal/Magento/Framework/Data/Form/Element/Submit.php index 38a4be2371c0e..9c24c336bacb5 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Submit.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Submit.php @@ -1,18 +1,17 @@ + * Copyright 2011 Adobe + * All Rights Reserved. */ + namespace Magento\Framework\Data\Form\Element; use Magento\Framework\Escaper; +/** + * Form submit element + */ class Submit extends AbstractElement { /** @@ -33,6 +32,8 @@ public function __construct( } /** + * Get HTML + * * @return mixed */ public function getHtml() diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Textarea.php b/lib/internal/Magento/Framework/Data/Form/Element/Textarea.php index 1970ebeb9544e..336673ff9001a 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Textarea.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Textarea.php @@ -1,7 +1,8 @@ */ class Textarea extends AbstractElement { /** * Default number of rows */ - const DEFAULT_ROWS = 2; + public const DEFAULT_ROWS = 2; /** * Default number of columns */ - const DEFAULT_COLS = 15; + public const DEFAULT_COLS = 15; /** * @param Factory $factoryElement @@ -43,6 +42,7 @@ public function __construct( if (!$this->getRows()) { $this->setRows(self::DEFAULT_ROWS); } + if (!$this->getCols()) { $this->setCols(self::DEFAULT_COLS); } diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Time.php b/lib/internal/Magento/Framework/Data/Form/Element/Time.php index 713c3460262c0..40269e1984967 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Time.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Time.php @@ -1,7 +1,7 @@ */ class Time extends AbstractElement { diff --git a/lib/internal/Magento/Framework/Data/Form/Filter/Escapehtml.php b/lib/internal/Magento/Framework/Data/Form/Filter/Escapehtml.php index d5745fb94d183..058f1857cb1cd 100644 --- a/lib/internal/Magento/Framework/Data/Form/Filter/Escapehtml.php +++ b/lib/internal/Magento/Framework/Data/Form/Filter/Escapehtml.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\Data\Form\Filter; diff --git a/lib/internal/Magento/Framework/Data/Form/Filter/FilterInterface.php b/lib/internal/Magento/Framework/Data/Form/Filter/FilterInterface.php index a9bf479cfce05..9fd9080c838cf 100644 --- a/lib/internal/Magento/Framework/Data/Form/Filter/FilterInterface.php +++ b/lib/internal/Magento/Framework/Data/Form/Filter/FilterInterface.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\Data\Form\Filter; diff --git a/lib/internal/Magento/Framework/Data/Form/Filter/Striptags.php b/lib/internal/Magento/Framework/Data/Form/Filter/Striptags.php index 6188e6d7a9256..d485e4cae97fc 100644 --- a/lib/internal/Magento/Framework/Data/Form/Filter/Striptags.php +++ b/lib/internal/Magento/Framework/Data/Form/Filter/Striptags.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\Data\Form\Filter; diff --git a/lib/internal/Magento/Framework/Data/Form/Filter/Trim.php b/lib/internal/Magento/Framework/Data/Form/Filter/Trim.php index 7bb8de397156e..7aa21ef3f979f 100644 --- a/lib/internal/Magento/Framework/Data/Form/Filter/Trim.php +++ b/lib/internal/Magento/Framework/Data/Form/Filter/Trim.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\Data\Form\Filter; diff --git a/lib/internal/Magento/Framework/Data/Helper/PostHelper.php b/lib/internal/Magento/Framework/Data/Helper/PostHelper.php index e8796a97d47d3..51eae723a7e1c 100644 --- a/lib/internal/Magento/Framework/Data/Helper/PostHelper.php +++ b/lib/internal/Magento/Framework/Data/Helper/PostHelper.php @@ -1,17 +1,18 @@ - * - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. + * Copyright 2011 Adobe + * All Rights Reserved. */ + namespace Magento\Framework\Data\Helper; use Magento\Framework\App\Helper\Context; use Magento\Framework\Url\Helper\Data as UrlHelper; +/** + * Helper to obtain post data for postData widget + */ class PostHelper extends \Magento\Framework\App\Helper\AbstractHelper { /** @@ -32,10 +33,11 @@ public function __construct( } /** - * get data for post by javascript in format acceptable to $.mage.dataPost widget + * Get data for post by javascript in format acceptable to $.mage.dataPost widget * * @param string $url * @param array $data + * * @return string */ public function getPostData($url, array $data = []) @@ -43,6 +45,7 @@ public function getPostData($url, array $data = []) if (!isset($data[\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED])) { $data[\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED] = $this->urlHelper->getEncodedUrl(); } + return json_encode(['action' => $url, 'data' => $data]); } } diff --git a/lib/internal/Magento/Framework/Data/Tree.php b/lib/internal/Magento/Framework/Data/Tree.php index 14197eb20c00c..5dbb4a98ca09b 100644 --- a/lib/internal/Magento/Framework/Data/Tree.php +++ b/lib/internal/Magento/Framework/Data/Tree.php @@ -1,8 +1,10 @@ * @since 100.0.2 + * phpcs:disable Magento2.CodeAnalysis.EmptyBlock */ class Tree { @@ -25,8 +27,7 @@ class Tree protected $_nodes; /** - * Enter description here... - * + * Initialize Tree */ public function __construct() { @@ -47,6 +48,7 @@ public function getTree() * Enter description here... * * @param Node $parentNode + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -58,6 +60,7 @@ public function load($parentNode = null) * Enter description here... * * @param int|string $nodeId + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -71,6 +74,7 @@ public function loadNode($nodeId) * @param array|Node $data * @param Node $parentNode * @param Node $prevNode + * * @return Node * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -81,6 +85,7 @@ public function appendChild($data, $parentNode, $prevNode = null) } elseif ($data instanceof Node) { $node = $this->addNode($data, $parentNode); } + return $node; } @@ -89,6 +94,7 @@ public function appendChild($data, $parentNode, $prevNode = null) * * @param Node $node * @param Node $parent + * * @return Node */ public function addNode($node, $parent = null) @@ -98,6 +104,7 @@ public function addNode($node, $parent = null) if ($parent !== null && $parent instanceof Node) { $parent->addChild($node); } + return $node; } @@ -107,6 +114,7 @@ public function addNode($node, $parent = null) * @param Node $node * @param Node $parentNode * @param Node $prevNode + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -120,6 +128,7 @@ public function moveNodeTo($node, $parentNode, $prevNode = null) * @param Node $node * @param Node $parentNode * @param Node $prevNode + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -131,6 +140,7 @@ public function copyNodeTo($node, $parentNode, $prevNode = null) * Remove node * * @param Node $node + * * @return $this */ public function removeNode($node) @@ -139,6 +149,7 @@ public function removeNode($node) if ($node->getParent()) { $node->getParent()->removeChild($node); } + unset($node); return $this; } @@ -148,6 +159,7 @@ public function removeNode($node) * * @param Node $parentNode * @param Node $prevNode + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -159,6 +171,7 @@ public function createNode($parentNode, $prevNode = null) * Get child * * @param Node $node + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -170,6 +183,7 @@ public function getChild($node) * Get children * * @param Node $node + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -191,6 +205,7 @@ public function getNodes() * Enter description here... * * @param Node $nodeId + * * @return Node */ public function getNodeById($nodeId) @@ -202,6 +217,7 @@ public function getNodeById($nodeId) * Get path * * @param Node $node + * * @return array */ public function getPath($node) @@ -212,6 +228,7 @@ public function getPath($node) return $_node->getPath(); } } + return []; } } diff --git a/lib/internal/Magento/Framework/Data/Tree/Db.php b/lib/internal/Magento/Framework/Data/Tree/Db.php index f114fd3508eb6..8dd1d7e37add0 100644 --- a/lib/internal/Magento/Framework/Data/Tree/Db.php +++ b/lib/internal/Magento/Framework/Data/Tree/Db.php @@ -1,8 +1,10 @@ */ class Db extends \Magento\Framework\Data\Tree { - const ID_FIELD = 'id'; - - const PARENT_FIELD = 'parent'; - - const LEVEL_FIELD = 'level'; - - const ORDER_FIELD = 'order'; + public const ID_FIELD = 'id'; + public const PARENT_FIELD = 'parent'; + public const LEVEL_FIELD = 'level'; + public const ORDER_FIELD = 'order'; /** * DB connection @@ -73,8 +70,6 @@ class Db extends \Magento\Framework\Data\Tree protected $_orderField; /** - * Db tree constructor - * * $fields = array( * \Magento\Framework\Data\Tree\Db::ID_FIELD => string, * \Magento\Framework\Data\Tree\Db::PARENT_FIELD => string, @@ -85,6 +80,7 @@ class Db extends \Magento\Framework\Data\Tree * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection * @param string $table * @param array $fields + * * @throws \Exception */ public function __construct(\Magento\Framework\DB\Adapter\AdapterInterface $connection, $table, $fields) @@ -92,7 +88,7 @@ public function __construct(\Magento\Framework\DB\Adapter\AdapterInterface $conn parent::__construct(); if (!$connection) { - throw new \Exception('Wrong "$connection" parametr'); + throw new \Exception('Wrong "$connection" parametr'); // phpcs:ignore } $this->_conn = $connection; @@ -108,7 +104,7 @@ public function __construct(\Magento\Framework\DB\Adapter\AdapterInterface $conn $fields[self::ORDER_FIELD] ) ) { - throw new \Exception('"$fields" tree configuratin array'); + throw new \Exception('"$fields" tree configuratin array'); // phpcs:ignore } $this->_idField = $fields[self::ID_FIELD]; @@ -121,6 +117,8 @@ public function __construct(\Magento\Framework\DB\Adapter\AdapterInterface $conn } /** + * Get database select + * * @return \Magento\Framework\DB\Select */ public function getDbSelect() @@ -129,7 +127,10 @@ public function getDbSelect() } /** + * Set database select + * * @param \Magento\Framework\DB\Select $select + * * @return void */ public function setDbSelect($select) @@ -140,9 +141,10 @@ public function setDbSelect($select) /** * Load tree * - * @param int|Node $parentNode - * @param int $recursionLevel recursion level - * @return $this + * @param int|Node $parentNode + * @param int $recursionLevel + * + * @return $this * @throws \Exception */ public function load($parentNode = null, $recursionLevel = 100) @@ -156,7 +158,7 @@ public function load($parentNode = null, $recursionLevel = 100) $parentId = $parentNode; $parentNode = null; } else { - throw new \Exception('root node id is not defined'); + throw new \Exception('root node id is not defined'); // phpcs:ignore } $select = clone $this->_select; @@ -172,11 +174,15 @@ public function load($parentNode = null, $recursionLevel = 100) $node->loadChildren($recursionLevel - 1); } } + return $this; } /** + * Load node + * * @param mixed $nodeId + * * @return Node */ public function loadNode($nodeId) @@ -190,9 +196,12 @@ public function loadNode($nodeId) } /** + * Append child + * * @param Node $data * @param Node $parentNode * @param Node $prevNode + * * @return Node */ public function appendChild($data, $parentNode, $prevNode = null) @@ -222,6 +231,7 @@ public function appendChild($data, $parentNode, $prevNode = null) * @param Node $node * @param Node $parentNode * @param Node $prevNode + * * @return void * @throws \Exception */ @@ -236,6 +246,7 @@ public function moveNodeTo($node, $parentNode, $prevNode = null) } else { $data[$this->_orderField] = $prevNode->getData($this->_orderField) + 1; } + $condition = $this->_conn->quoteInto("{$this->_idField}=?", $node->getId()); // For reorder new node branch @@ -274,13 +285,16 @@ public function moveNodeTo($node, $parentNode, $prevNode = null) $this->_conn->commit(); } catch (\Exception $e) { $this->_conn->rollBack(); - throw new \Exception('Can\'t move tree node'); + throw new \Exception('Can\'t move tree node'); // phpcs:ignore } } /** + * Update child levels + * * @param mixed $parentId * @param int $parentLevel + * * @return $this */ protected function _updateChildLevels($parentId, $parentLevel) @@ -304,10 +318,13 @@ protected function _updateChildLevels($parentId, $parentLevel) $this->_updateChildLevels($id, $parentLevel + 1); } } + return $this; } /** + * Load full tree + * * @return $this */ protected function _loadFullTree() @@ -327,7 +344,10 @@ protected function _loadFullTree() } /** + * Remove node + * * @param Node $node + * * @return $this * @throws \Exception */ @@ -356,8 +376,9 @@ public function removeNode($node) $this->_conn->commit(); } catch (\Exception $e) { $this->_conn->rollBack(); - throw new \Exception('Can\'t remove tree node'); + throw new \Exception('Can\'t remove tree node'); // phpcs:ignore } + parent::removeNode($node); return $this; } diff --git a/lib/internal/Magento/Framework/Data/Tree/Dbp.php b/lib/internal/Magento/Framework/Data/Tree/Dbp.php index 58c46888e7ada..960aa4d719a7b 100644 --- a/lib/internal/Magento/Framework/Data/Tree/Dbp.php +++ b/lib/internal/Magento/Framework/Data/Tree/Dbp.php @@ -1,7 +1,7 @@ */ class Dbp extends \Magento\Framework\Data\Tree { diff --git a/lib/internal/Magento/Framework/Data/Tree/Node.php b/lib/internal/Magento/Framework/Data/Tree/Node.php index ac0ac57e72969..b6f0e9ae7f8e9 100644 --- a/lib/internal/Magento/Framework/Data/Tree/Node.php +++ b/lib/internal/Magento/Framework/Data/Tree/Node.php @@ -1,8 +1,10 @@ * @since 100.0.2 */ class Node extends \Magento\Framework\DataObject @@ -32,8 +33,6 @@ class Node extends \Magento\Framework\DataObject protected $_tree; /** - * Child nodes - * * @var Collection */ protected $_childNodes; @@ -46,8 +45,6 @@ class Node extends \Magento\Framework\DataObject protected $_idField; /** - * Data tree node constructor - * * @param array $data * @param string $idField * @param Tree $tree @@ -76,6 +73,7 @@ public function getId() * Set node id field name * * @param string $idField + * * @return $this */ public function setIdField($idField) @@ -98,6 +96,7 @@ public function getIdField() * Set node tree object * * @param Tree $tree + * * @return $this */ public function setTree(Tree $tree) @@ -120,6 +119,7 @@ public function getTree() * Set node parent * * @param Node $parent + * * @return $this */ public function setParent($parent) @@ -149,7 +149,10 @@ public function hasChildren() } /** + * Set level + * * @param mixed $level + * * @return $this */ public function setLevel($level) @@ -159,7 +162,10 @@ public function setLevel($level) } /** + * Set path ID + * * @param mixed $path + * * @return $this */ public function setPathId($path) @@ -169,9 +175,12 @@ public function setPathId($path) } /** + * Seemingyly useless method + * * @param Node $node * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @phpcs:disable Magento2.CodeAnalysis.EmptyBlock.DetectedFunction */ public function isChildOf($node) { @@ -181,6 +190,7 @@ public function isChildOf($node) * Load node children * * @param int $recursionLevel + * * @return \Magento\Framework\Data\Tree\Node */ public function loadChildren($recursionLevel = 0) @@ -200,7 +210,10 @@ public function getChildren() } /** + * Get all child nodes + * * @param array $nodes + * * @return array */ public function getAllChildNodes(&$nodes = []) @@ -213,6 +226,8 @@ public function getAllChildNodes(&$nodes = []) } /** + * Get last child + * * @return mixed */ public function getLastChild() @@ -224,6 +239,7 @@ public function getLastChild() * Add child node * * @param Node $node + * * @return Node */ public function addChild($node) @@ -233,7 +249,10 @@ public function addChild($node) } /** + * Append child + * * @param Node $prevNode + * * @return $this */ public function appendChild($prevNode = null) @@ -243,8 +262,11 @@ public function appendChild($prevNode = null) } /** + * Move to + * * @param Node $parentNode * @param Node $prevNode + * * @return $this */ public function moveTo($parentNode, $prevNode = null) @@ -254,8 +276,11 @@ public function moveTo($parentNode, $prevNode = null) } /** + * Copy to + * * @param Node $parentNode * @param Node $prevNode + * * @return $this */ public function copyTo($parentNode, $prevNode = null) @@ -265,7 +290,10 @@ public function copyTo($parentNode, $prevNode = null) } /** + * Remove child + * * @param Node $childNode + * * @return $this */ public function removeChild($childNode) @@ -275,7 +303,10 @@ public function removeChild($childNode) } /** + * Get path + * * @param array $prevNodes + * * @return array */ public function getPath(&$prevNodes = []) @@ -284,10 +315,13 @@ public function getPath(&$prevNodes = []) $prevNodes[] = $this; $this->_parent->getPath($prevNodes); } + return $prevNodes; } /** + * Get is active + * * @return mixed */ public function getIsActive() @@ -296,6 +330,8 @@ public function getIsActive() } /** + * Get name + * * @return mixed */ public function getName() diff --git a/lib/internal/Magento/Framework/DataObject/Cache.php b/lib/internal/Magento/Framework/DataObject/Cache.php index 07394412d9be4..654daac795333 100644 --- a/lib/internal/Magento/Framework/DataObject/Cache.php +++ b/lib/internal/Magento/Framework/DataObject/Cache.php @@ -1,16 +1,16 @@ */ class Cache { @@ -94,6 +94,7 @@ public static function singleton() if (!self::$_instance) { self::$_instance = new self(); } + return self::$_instance; } @@ -102,6 +103,7 @@ public static function singleton() * * @param string|object $idx * @param object $default + * * @return object */ public function load($idx, $default = null) @@ -109,9 +111,11 @@ public function load($idx, $default = null) if (isset($this->_references[$idx])) { $idx = $this->_references[$idx]; } + if (isset($this->_objects[$idx])) { return $this->_objects[$idx]; } + return $default; } @@ -121,6 +125,7 @@ public function load($idx, $default = null) * @param object $object * @param string $idx * @param array|string $tags + * * @return string * @throws \Magento\Framework\Exception\LocalizedException * @SuppressWarnings(PHPMD.CyclomaticComplexity) @@ -128,7 +133,6 @@ public function load($idx, $default = null) */ public function save($object, $idx = null, $tags = null) { - //\Magento\Framework\Profiler::start('OBJECT_SAVE'); if (!is_object($object)) { return false; } @@ -137,16 +141,17 @@ public function save($object, $idx = null, $tags = null) if ($idx !== null && strpos($idx, '{') !== false) { $idx = str_replace('{hash}', $hash, $idx); } + if (isset($this->_hashes[$hash])) { - //throw new \Exception('test'); if ($idx !== null) { $this->_references[$idx] = $this->_hashes[$hash]; } + return $this->_hashes[$hash]; } if ($idx === null) { - $idx = '#' . ++$this->_idx; + $idx = '#' . (++$this->_idx); } if (isset($this->_objects[$idx])) { @@ -172,7 +177,6 @@ public function save($object, $idx = null, $tags = null) $this->_objectTags[$idx][$t] = true; } } - //\Magento\Framework\Profiler::stop('OBJECT_SAVE'); return $idx; } @@ -182,6 +186,7 @@ public function save($object, $idx = null, $tags = null) * * @param string|array $refName * @param string $idx + * * @return bool|void * @throws \Magento\Framework\Exception\LocalizedException */ @@ -191,6 +196,7 @@ public function reference($refName, $idx) foreach ($refName as $ref) { $this->reference($ref, $idx); } + return; } @@ -202,6 +208,7 @@ public function reference($refName, $idx) ) ); } + $this->_references[$refName] = $idx; $this->_objectReferences[$idx][$refName] = true; @@ -212,22 +219,20 @@ public function reference($refName, $idx) * Delete an object from registry * * @param string|object $idx + * * @return boolean */ public function delete($idx) { - //\Magento\Framework\Profiler::start("OBJECT_DELETE"); if (is_object($idx)) { $idx = $this->find($idx); if (false === $idx) { - //\Magento\Framework\Profiler::stop("OBJECT_DELETE"); return false; } + unset($this->_objects[$idx]); - //\Magento\Framework\Profiler::stop("OBJECT_DELETE"); return false; } elseif (!isset($this->_objects[$idx])) { - //\Magento\Framework\Profiler::stop("OBJECT_DELETE"); return false; } @@ -239,6 +244,7 @@ public function delete($idx) foreach ($this->_objectTags[$idx] as $t => $dummy) { unset($this->_tags[$t][$idx]); } + unset($this->_objectTags[$idx]); } @@ -246,9 +252,9 @@ public function delete($idx) foreach ($this->_references as $r => $dummy) { unset($this->_references[$r]); } + unset($this->_objectReferences[$idx]); } - //\Magento\Framework\Profiler::stop("OBJECT_DELETE"); return true; } @@ -257,6 +263,7 @@ public function delete($idx) * Cleanup by class name for objects of subclasses too * * @param string $class + * * @return void */ public function deleteByClass($class) @@ -272,6 +279,7 @@ public function deleteByClass($class) * Cleanup objects by tags * * @param array|string $tags + * * @return true * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ @@ -280,11 +288,13 @@ public function deleteByTags($tags) if (is_string($tags)) { $tags = [$tags]; } + foreach ($tags as $t) { foreach ($this->_tags[$t] as $idx => $dummy) { $this->delete($idx); } } + return true; } @@ -292,6 +302,7 @@ public function deleteByTags($tags) * Check whether object id exists in registry * * @param string $idx + * * @return boolean */ public function has($idx) @@ -303,6 +314,7 @@ public function has($idx) * Find an object id * * @param object $object + * * @return string|boolean */ public function find($object) @@ -312,6 +324,7 @@ public function find($object) return $idx; } } + return false; } @@ -319,6 +332,7 @@ public function find($object) * Find objects by ids * * @param string[] $ids + * * @return array */ public function findByIds($ids) @@ -329,6 +343,7 @@ public function findByIds($ids) $objects[$idx] = $obj; } } + return $objects; } @@ -336,6 +351,7 @@ public function findByIds($ids) * Find object by hash * * @param string $hash + * * @return object */ public function findByHash($hash) @@ -347,6 +363,7 @@ public function findByHash($hash) * Find objects by tags * * @param array|string $tags + * * @return array * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ @@ -355,15 +372,18 @@ public function findByTags($tags) if (is_string($tags)) { $tags = [$tags]; } + $objects = []; foreach ($tags as $t) { foreach ($this->_tags[$t] as $idx => $dummy) { if (isset($objects[$idx])) { continue; } + $objects[$idx] = $this->load($idx); } } + return $objects; } @@ -371,6 +391,7 @@ public function findByTags($tags) * Find by class name for objects of subclasses too * * @param string $class + * * @return array */ public function findByClass($class) @@ -381,6 +402,7 @@ public function findByClass($class) $objects[$idx] = $object; } } + return $objects; } @@ -389,6 +411,7 @@ public function findByClass($class) * * @param string $idx * @param object|null $object + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -403,6 +426,7 @@ public function debug($idx, $object = null) 'function' => isset($step['function']) ? $step['function'] : null, ]; } + $this->_debug[$idx] = $debug; } @@ -410,6 +434,7 @@ public function debug($idx, $object = null) * Return debug information by ids * * @param array|string $ids + * * @return array */ public function debugByIds($ids) @@ -417,10 +442,12 @@ public function debugByIds($ids) if (is_string($ids)) { $ids = [$ids]; } + $debug = []; foreach ($ids as $idx) { $debug[$idx] = $this->_debug[$idx]; } + return $debug; } diff --git a/lib/internal/Magento/Framework/Event.php b/lib/internal/Magento/Framework/Event.php index 9df9c315ccad8..7ae4155d30e02 100644 --- a/lib/internal/Magento/Framework/Event.php +++ b/lib/internal/Magento/Framework/Event.php @@ -1,17 +1,15 @@ + * Copyright 2011 Adobe + * All Rights Reserved. */ + namespace Magento\Framework; /** + * Event object and dispatcher + * * @api * @since 100.0.2 */ @@ -25,8 +23,6 @@ class Event extends \Magento\Framework\DataObject protected $_observers; /** - * Constructor - * * Initializes observers collection * * @param array $data @@ -51,6 +47,7 @@ public function getObservers() * Register an observer for the event * * @param \Magento\Framework\Event\Observer $observer + * * @return $this */ public function addObserver(\Magento\Framework\Event\Observer $observer) @@ -63,6 +60,7 @@ public function addObserver(\Magento\Framework\Event\Observer $observer) * Removes an observer by its name * * @param string $observerName + * * @return $this */ public function removeObserverByName($observerName) @@ -93,7 +91,10 @@ public function getName() } /** + * Set name + * * @param string $data + * * @return $this */ public function setName($data) @@ -103,6 +104,8 @@ public function setName($data) } /** + * Get block + * * @return mixed */ public function getBlock() diff --git a/lib/internal/Magento/Framework/Event/Collection.php b/lib/internal/Magento/Framework/Event/Collection.php index 8540a25d5445d..b73f8d3a8cdbc 100644 --- a/lib/internal/Magento/Framework/Event/Collection.php +++ b/lib/internal/Magento/Framework/Event/Collection.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\Event; diff --git a/lib/internal/Magento/Framework/Event/Observer/Collection.php b/lib/internal/Magento/Framework/Event/Observer/Collection.php index 595ee8f70da3a..5719411cd0b59 100644 --- a/lib/internal/Magento/Framework/Event/Observer/Collection.php +++ b/lib/internal/Magento/Framework/Event/Observer/Collection.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\Event\Observer; diff --git a/lib/internal/Magento/Framework/Event/Observer/Cron.php b/lib/internal/Magento/Framework/Event/Observer/Cron.php index 67d864cbb310c..31b6c95c41f0f 100644 --- a/lib/internal/Magento/Framework/Event/Observer/Cron.php +++ b/lib/internal/Magento/Framework/Event/Observer/Cron.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\Event\Observer; diff --git a/lib/internal/Magento/Framework/Event/Observer/Regex.php b/lib/internal/Magento/Framework/Event/Observer/Regex.php index 0f3b075d02feb..e72d969e86f51 100644 --- a/lib/internal/Magento/Framework/Event/Observer/Regex.php +++ b/lib/internal/Magento/Framework/Event/Observer/Regex.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\Event\Observer; diff --git a/lib/internal/Magento/Framework/File/CsvMulty.php b/lib/internal/Magento/Framework/File/CsvMulty.php index da1833d4c6ac9..ab1ba79c69a81 100644 --- a/lib/internal/Magento/Framework/File/CsvMulty.php +++ b/lib/internal/Magento/Framework/File/CsvMulty.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\File; diff --git a/lib/internal/Magento/Framework/HTTP/Client/Curl.php b/lib/internal/Magento/Framework/HTTP/Client/Curl.php index 7ba4fb915e294..68be7f387c1dc 100644 --- a/lib/internal/Magento/Framework/HTTP/Client/Curl.php +++ b/lib/internal/Magento/Framework/HTTP/Client/Curl.php @@ -1,7 +1,7 @@ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @api */ diff --git a/lib/internal/Magento/Framework/HTTP/Client/Socket.php b/lib/internal/Magento/Framework/HTTP/Client/Socket.php index 21ee9bd325b42..f4a6a634dab89 100644 --- a/lib/internal/Magento/Framework/HTTP/Client/Socket.php +++ b/lib/internal/Magento/Framework/HTTP/Client/Socket.php @@ -6,8 +6,6 @@ /** * Class to work with HTTP protocol using sockets - * - * @author Magento Core Team */ namespace Magento\Framework\HTTP\Client; diff --git a/lib/internal/Magento/Framework/HTTP/ClientFactory.php b/lib/internal/Magento/Framework/HTTP/ClientFactory.php index 06139b75c39d5..701fe3f692f0b 100644 --- a/lib/internal/Magento/Framework/HTTP/ClientFactory.php +++ b/lib/internal/Magento/Framework/HTTP/ClientFactory.php @@ -1,15 +1,13 @@ */ class ClientFactory { diff --git a/lib/internal/Magento/Framework/HTTP/ZendClient.php b/lib/internal/Magento/Framework/HTTP/ZendClient.php index 1ffb26fffacf2..be5a10663e9f7 100644 --- a/lib/internal/Magento/Framework/HTTP/ZendClient.php +++ b/lib/internal/Magento/Framework/HTTP/ZendClient.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\HTTP; diff --git a/lib/internal/Magento/Framework/Image.php b/lib/internal/Magento/Framework/Image.php index 5b49e9f303ca0..6085ed4555617 100644 --- a/lib/internal/Magento/Framework/Image.php +++ b/lib/internal/Magento/Framework/Image.php @@ -1,14 +1,12 @@ */ class Image { diff --git a/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php b/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php index c49ca72dc0c56..28bdeeb55f539 100644 --- a/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php +++ b/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php @@ -1,14 +1,15 @@ * @api * @since 100.0.2 */ @@ -17,30 +18,29 @@ class Algorithm /** * Minimal possible value */ - const MIN_POSSIBLE_VALUE = .01; + public const MIN_POSSIBLE_VALUE = .01; /** * Rounding factor coefficient */ - const TEN_POWER_ROUNDING_FACTOR = 4; + public const TEN_POWER_ROUNDING_FACTOR = 4; /** * Interval deflection coefficient */ - const INTERVAL_DEFLECTION_LIMIT = .3; + public const INTERVAL_DEFLECTION_LIMIT = .3; /** * Standard normal distribution's a/2 quantile * Depends on predefined a. In case of a=0.05 */ - const STANDARD_NORMAL_DISTRIBUTION = 1.96; + public const STANDARD_NORMAL_DISTRIBUTION = 1.96; /** * Min and Max number of intervals */ - const MIN_INTERVALS_NUMBER = 2; - - const MAX_INTERVALS_NUMBER = 10; + public const MIN_INTERVALS_NUMBER = 2; + public const MAX_INTERVALS_NUMBER = 10; /** * Upper values limit @@ -92,15 +92,11 @@ class Algorithm protected $_values = []; /** - * Max value - * * @var float */ protected $_maxValue = 0; /** - * Min value - * * @var float */ protected $_minValue = 0; @@ -117,6 +113,7 @@ class Algorithm * * @param null|float $lowerLimit * @param null|float $upperLimit + * * @return \Magento\Framework\Search\Dynamic\Algorithm */ public function setLimits($lowerLimit = null, $upperLimit = null) @@ -134,6 +131,7 @@ public function setLimits($lowerLimit = null, $upperLimit = null) * @param float $max * @param float $standardDeviation * @param int $count + * * @return $this */ public function setStatistics($min, $max, $standardDeviation, $count) @@ -154,6 +152,7 @@ public function setStatistics($min, $max, $standardDeviation, $count) } else { $intervalsNumber = $valueRange * pow($count, 1 / 3) / (3.5 * $standardDeviation); } + $this->_intervalsNumber = max(ceil($intervalsNumber), self::MIN_INTERVALS_NUMBER); $this->_intervalsNumber = (int)min($this->_intervalsNumber, self::MAX_INTERVALS_NUMBER); @@ -164,6 +163,7 @@ public function setStatistics($min, $max, $standardDeviation, $count) * Calculate separators, each contains 'from', 'to' and 'count' * * @param IntervalInterface $interval + * * @return array * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) @@ -180,9 +180,11 @@ public function calculateSeparators(IntervalInterface $interval) if (empty($separator)) { continue; } + if ($this->_quantileInterval[0] == 0) { $intervalFirstValue = $this->_values[0]; } + $separatorCandidate = false; $newIntervalFirstValue = $intervalFirstValue; $newLastSeparator = $lastSeparator; @@ -231,6 +233,7 @@ public function calculateSeparators(IntervalInterface $interval) } } } + if ($this->_lastValueLimiter[0] < $this->_count) { $isEqualValue = $intervalFirstValue == $this->_maxValue ? $intervalFirstValue : false; $result[$this->getIntervalsNumber()] = [ @@ -260,8 +263,9 @@ protected function getIntervalsNumber() /** * Find value separator for the quantile * - * @param int $quantileNumber should be from 1 to n-1 where n is number of intervals + * @param int $quantileNumber Should be from 1 to n-1 where n is number of intervals. * @param IntervalInterface $interval + * * @return array|null * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) @@ -280,6 +284,7 @@ protected function _findValueSeparator($quantileNumber, IntervalInterface $inter if ($this->_lastValueLimiter[0] !== null) { $offset -= $this->_lastValueLimiter[0]; } + if ($offset < 0) { $intervalValuesCount += $offset; $values = array_slice( @@ -289,17 +294,19 @@ protected function _findValueSeparator($quantileNumber, IntervalInterface $inter ); $offset = 0; } + $lowerValue = $this->_lastValueLimiter[1]; if ($this->_lowerLimit !== null) { $lowerValue = max($lowerValue, $this->_lowerLimit); } + if ($intervalValuesCount >= 0) { $values = array_merge( $values, $interval->load($intervalValuesCount + 1, $offset, $lowerValue, $this->_upperLimit) ); } - // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall + $lastValue = $this->offsetLimits($intervalValuesCount, $values); $bestRoundValue = []; @@ -317,6 +324,7 @@ protected function _findValueSeparator($quantileNumber, IntervalInterface $inter ); } } + if ($quantileNumber == $this->getIntervalsNumber() - 1) { $valuesCount = count($values); if ($values[$valuesCount - 1] > $lastValue) { @@ -328,12 +336,14 @@ protected function _findValueSeparator($quantileNumber, IntervalInterface $inter $this->_upperLimit ); } + if ($additionalValues) { $quantileInterval[1] = $quantileInterval[0] + count($values) - 1; if ($values[$valuesCount - 1] <= $lastValue) { $quantileInterval[1] += count($additionalValues); $values = array_merge($values, $additionalValues); } + $upperBestRoundValue = $this->_findRoundValue( $lastValue + self::MIN_POSSIBLE_VALUE / 10, $values[count($values) - 1], @@ -379,7 +389,8 @@ protected function _findValueSeparator($quantileNumber, IntervalInterface $inter /** * Get quantile interval * - * @param int $quantileNumber should be from 1 to n-1 where n is number of intervals + * @param int $quantileNumber Should be from 1 to n-1 where n is number of intervals. + * * @return null|float[] [floatMin,floatMax] */ protected function _getQuantileInterval($quantileNumber) @@ -387,6 +398,7 @@ protected function _getQuantileInterval($quantileNumber) if ($quantileNumber < 1 || $quantileNumber >= $this->getIntervalsNumber()) { return null; } + $quantile = $this->_getQuantile($quantileNumber); $deflectionLimit = floor($this->_count / 2 / $this->getIntervalsNumber()); $limits = [ @@ -402,6 +414,7 @@ protected function _getQuantileInterval($quantileNumber) ) { $left = $this->_skippedQuantilesUpperLimits[$quantileNumber - 1]; } + $right = min(ceil($quantile + $deflection), $limits[1], $this->_count - 1); return [$left, $right]; @@ -410,7 +423,8 @@ protected function _getQuantileInterval($quantileNumber) /** * Get quantile * - * @param int $quantileNumber should be from 1 to n-1 where n is number of intervals + * @param int $quantileNumber Should be from 1 to n-1 where n is number of intervals. + * * @return float|null */ protected function _getQuantile($quantileNumber) @@ -425,10 +439,11 @@ protected function _getQuantile($quantileNumber) /** * Find max rounding factor with given value range * - * @param float $lowerValue - * @param float $upperValue - * @param bool $returnEmpty whether empty result is acceptable - * @param null|float $roundingFactor if given, checks for range to contain the factor + * @param float $lowerValue + * @param float $upperValue + * @param bool $returnEmpty Whether empty result is acceptable. + * @param null|float $roundingFactor If given, checks for range to contain the factor. + * * @return false|array * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) @@ -445,6 +460,7 @@ protected function _findRoundValue($lowerValue, $upperValue, $returnEmpty = true return false; } } + // round is used for such examples: (1194.32 / 0.02) or (5 / 100000) $lowerDivision = ceil(round($lowerValue / $roundingFactor, self::TEN_POWER_ROUNDING_FACTOR + 3)); $upperDivision = floor(round($upperValue / $roundingFactor, self::TEN_POWER_ROUNDING_FACTOR + 3)); @@ -468,6 +484,7 @@ protected function _findRoundValue($lowerValue, $upperValue, $returnEmpty = true if ($tenPower == self::MIN_POSSIBLE_VALUE) { $roundingFactorCoefficients[] = 1; } + foreach ($roundingFactorCoefficients as $roundingFactorCoefficient) { $roundingFactorCoefficient *= $tenPower; $roundValues = $this->_findRoundValue( @@ -484,6 +501,7 @@ protected function _findRoundValue($lowerValue, $upperValue, $returnEmpty = true $result[$index] = $roundValues; } } + $tenPower /= 10; } @@ -493,8 +511,9 @@ protected function _findRoundValue($lowerValue, $upperValue, $returnEmpty = true /** * Merge new round values with old ones * - * @param array &$oldRoundValues - * @param array &$newRoundValues + * @param array $oldRoundValues + * @param array $newRoundValues + * * @return void */ protected function _mergeRoundValues(&$oldRoundValues, &$newRoundValues) @@ -526,6 +545,7 @@ protected function _getCalculatedIntervalsNumber() * * @param int $quantileNumber * @param array $separators + * * @return array|false [deflection, separatorValue, $valueIndex] */ protected function _findBestSeparator($quantileNumber, $separators) @@ -561,7 +581,8 @@ protected function _findBestSeparator($quantileNumber, $separators) * Returns -1 if index was not found * * @param float $value - * @param null|float[] $limits search [from, to] + * @param null|float[] $limits Search [from, to]. + * * @return int * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) @@ -575,9 +596,11 @@ protected function _binarySearch($value, $limits = null) if (!is_array($limits)) { $limits = []; } + if (!isset($limits[0])) { $limits[0] = 0; } + if (!isset($limits[1])) { $limits[1] = count($this->_values) - 1; } diff --git a/lib/internal/Magento/Framework/Url/Helper/Data.php b/lib/internal/Magento/Framework/Url/Helper/Data.php index 4f1caab3af781..bfb4f77c98cc3 100644 --- a/lib/internal/Magento/Framework/Url/Helper/Data.php +++ b/lib/internal/Magento/Framework/Url/Helper/Data.php @@ -1,13 +1,11 @@ */ namespace Magento\Framework\Url\Helper; diff --git a/lib/internal/Magento/Framework/View/Helper/Js.php b/lib/internal/Magento/Framework/View/Helper/Js.php index c4b14ad88d45a..0a632abba5840 100644 --- a/lib/internal/Magento/Framework/View/Helper/Js.php +++ b/lib/internal/Magento/Framework/View/Helper/Js.php @@ -1,12 +1,10 @@ - * - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. + * Copyright 2011 Adobe + * All Rights Reserved. */ + namespace Magento\Framework\View\Helper; use Magento\Framework\App\ObjectManager; @@ -34,6 +32,7 @@ public function __construct( * Retrieve framed javascript * * @param string $script + * * @return string */ public function getScript($script)