From 6bf3b21702877491cef28cc10c2d904dfbe8f314 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Tue, 7 Mar 2023 14:20:38 +0000 Subject: [PATCH 1/4] Remove forbidden @author tag --- .../Framework/Data/Form/Element/Renderer/RendererInterface.php | 2 -- lib/internal/Magento/Framework/Data/Form/Element/Reset.php | 2 -- lib/internal/Magento/Framework/Data/Form/Element/Select.php | 1 - lib/internal/Magento/Framework/Data/Form/Element/Submit.php | 2 -- lib/internal/Magento/Framework/Data/Form/Element/Textarea.php | 2 -- lib/internal/Magento/Framework/Data/Form/Element/Time.php | 2 -- lib/internal/Magento/Framework/Data/Form/Filter/Escapehtml.php | 2 -- .../Magento/Framework/Data/Form/Filter/FilterInterface.php | 2 -- lib/internal/Magento/Framework/Data/Form/Filter/Striptags.php | 2 -- lib/internal/Magento/Framework/Data/Form/Filter/Trim.php | 2 -- lib/internal/Magento/Framework/Data/Helper/PostHelper.php | 2 -- lib/internal/Magento/Framework/Data/Tree.php | 1 - lib/internal/Magento/Framework/Data/Tree/Db.php | 2 -- lib/internal/Magento/Framework/Data/Tree/Dbp.php | 2 -- lib/internal/Magento/Framework/Data/Tree/Node.php | 1 - lib/internal/Magento/Framework/DataObject/Cache.php | 2 -- lib/internal/Magento/Framework/Event.php | 2 -- lib/internal/Magento/Framework/Event/Collection.php | 2 -- lib/internal/Magento/Framework/Event/Observer/Collection.php | 2 -- lib/internal/Magento/Framework/Event/Observer/Cron.php | 2 -- lib/internal/Magento/Framework/Event/Observer/Regex.php | 2 -- lib/internal/Magento/Framework/File/CsvMulty.php | 2 -- lib/internal/Magento/Framework/HTTP/Client/Curl.php | 1 - lib/internal/Magento/Framework/HTTP/Client/Socket.php | 2 -- lib/internal/Magento/Framework/HTTP/ClientFactory.php | 2 -- lib/internal/Magento/Framework/HTTP/ZendClient.php | 2 -- lib/internal/Magento/Framework/Image.php | 2 -- lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php | 1 - lib/internal/Magento/Framework/Url/Helper/Data.php | 2 -- lib/internal/Magento/Framework/View/Helper/Js.php | 2 -- 30 files changed, 55 deletions(-) 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..72e5bc8f2562a 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Renderer/RendererInterface.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Renderer/RendererInterface.php @@ -6,8 +6,6 @@ /** * Form field renderer interface - * - * @author Magento Core Team */ 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..0bad496106307 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Reset.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Reset.php @@ -6,8 +6,6 @@ /** * Form relset element - * - * @author Magento Core Team */ 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..7249bd5f33d35 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Select.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Select.php @@ -14,7 +14,6 @@ * Form select element * * @api - * @author Magento Core Team * @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..780b32c7be275 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Submit.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Submit.php @@ -6,8 +6,6 @@ /** * Form submit element - * - * @author Magento Core Team */ namespace Magento\Framework\Data\Form\Element; diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Textarea.php b/lib/internal/Magento/Framework/Data/Form/Element/Textarea.php index 1970ebeb9544e..253c060166873 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Textarea.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Textarea.php @@ -10,8 +10,6 @@ /** * Form textarea element. - * - * @author Magento Core Team */ class Textarea extends AbstractElement { diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Time.php b/lib/internal/Magento/Framework/Data/Form/Element/Time.php index 713c3460262c0..bda01660e6fd7 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Time.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Time.php @@ -12,8 +12,6 @@ /** * Form time element - * - * @author Magento Core Team */ 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 5f9f3ea6d08a3..dc2965a9d6be2 100644 --- a/lib/internal/Magento/Framework/Data/Form/Filter/Escapehtml.php +++ b/lib/internal/Magento/Framework/Data/Form/Filter/Escapehtml.php @@ -6,8 +6,6 @@ /** * Form Input/Output Escape HTML entities Filter - * - * @author Magento Core Team */ 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..2913be3c04165 100644 --- a/lib/internal/Magento/Framework/Data/Form/Filter/FilterInterface.php +++ b/lib/internal/Magento/Framework/Data/Form/Filter/FilterInterface.php @@ -6,8 +6,6 @@ /** * Form Input/Output Filter Interface - * - * @author Magento Core Team */ 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..a64baf747fbfd 100644 --- a/lib/internal/Magento/Framework/Data/Form/Filter/Striptags.php +++ b/lib/internal/Magento/Framework/Data/Form/Filter/Striptags.php @@ -6,8 +6,6 @@ /** * Form Input/Output Strip HTML tags Filter - * - * @author Magento Core Team */ 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..1b629a7e63fa3 100644 --- a/lib/internal/Magento/Framework/Data/Form/Filter/Trim.php +++ b/lib/internal/Magento/Framework/Data/Form/Filter/Trim.php @@ -6,8 +6,6 @@ /** * Form Input/Output Trim Filter - * - * @author Magento Core Team */ 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..f0671b6f3612c 100644 --- a/lib/internal/Magento/Framework/Data/Helper/PostHelper.php +++ b/lib/internal/Magento/Framework/Data/Helper/PostHelper.php @@ -2,8 +2,6 @@ /** * Helper to obtain post data for postData widget * - * @author Magento Core Team - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ diff --git a/lib/internal/Magento/Framework/Data/Tree.php b/lib/internal/Magento/Framework/Data/Tree.php index 14197eb20c00c..1dec347209340 100644 --- a/lib/internal/Magento/Framework/Data/Tree.php +++ b/lib/internal/Magento/Framework/Data/Tree.php @@ -12,7 +12,6 @@ * Data tree * * @api - * @author Magento Core Team * @since 100.0.2 */ class Tree diff --git a/lib/internal/Magento/Framework/Data/Tree/Db.php b/lib/internal/Magento/Framework/Data/Tree/Db.php index f114fd3508eb6..050b3349caf49 100644 --- a/lib/internal/Magento/Framework/Data/Tree/Db.php +++ b/lib/internal/Magento/Framework/Data/Tree/Db.php @@ -10,8 +10,6 @@ * * Data model: * id | pid | level | order - * - * @author Magento Core Team */ class Db extends \Magento\Framework\Data\Tree { diff --git a/lib/internal/Magento/Framework/Data/Tree/Dbp.php b/lib/internal/Magento/Framework/Data/Tree/Dbp.php index 58c46888e7ada..2a92fce7c8ecf 100644 --- a/lib/internal/Magento/Framework/Data/Tree/Dbp.php +++ b/lib/internal/Magento/Framework/Data/Tree/Dbp.php @@ -12,8 +12,6 @@ * * Data model: * id | path | order - * - * @author Magento Core Team */ 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..9658695c59e6d 100644 --- a/lib/internal/Magento/Framework/Data/Tree/Node.php +++ b/lib/internal/Magento/Framework/Data/Tree/Node.php @@ -12,7 +12,6 @@ * Data tree node * * @api - * @author Magento Core Team * @since 100.0.2 */ class Node extends \Magento\Framework\DataObject diff --git a/lib/internal/Magento/Framework/DataObject/Cache.php b/lib/internal/Magento/Framework/DataObject/Cache.php index 07394412d9be4..ffcf52420ad2c 100644 --- a/lib/internal/Magento/Framework/DataObject/Cache.php +++ b/lib/internal/Magento/Framework/DataObject/Cache.php @@ -9,8 +9,6 @@ * Object Cache * * Stores objects for reuse, cleanup and to avoid circular references - * - * @author Magento Core Team */ class Cache { diff --git a/lib/internal/Magento/Framework/Event.php b/lib/internal/Magento/Framework/Event.php index 9df9c315ccad8..d67738b0a6e68 100644 --- a/lib/internal/Magento/Framework/Event.php +++ b/lib/internal/Magento/Framework/Event.php @@ -6,8 +6,6 @@ /** * Event object and dispatcher - * - * @author Magento Core Team */ namespace Magento\Framework; diff --git a/lib/internal/Magento/Framework/Event/Collection.php b/lib/internal/Magento/Framework/Event/Collection.php index a851ed440f340..8041caedc3041 100644 --- a/lib/internal/Magento/Framework/Event/Collection.php +++ b/lib/internal/Magento/Framework/Event/Collection.php @@ -6,8 +6,6 @@ /** * Collection of events - * - * @author Magento Core Team */ 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..bec0f2dba57db 100644 --- a/lib/internal/Magento/Framework/Event/Observer/Collection.php +++ b/lib/internal/Magento/Framework/Event/Observer/Collection.php @@ -6,8 +6,6 @@ /** * Event observer collection - * - * @author Magento Core Team */ 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..a2f8c9faebdb7 100644 --- a/lib/internal/Magento/Framework/Event/Observer/Cron.php +++ b/lib/internal/Magento/Framework/Event/Observer/Cron.php @@ -6,8 +6,6 @@ /** * Event cron observer object - * - * @author Magento Core Team */ 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..6bc8ba63906dc 100644 --- a/lib/internal/Magento/Framework/Event/Observer/Regex.php +++ b/lib/internal/Magento/Framework/Event/Observer/Regex.php @@ -6,8 +6,6 @@ /** * Event regex observer object - * - * @author Magento Core Team */ 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..5f37857040000 100644 --- a/lib/internal/Magento/Framework/File/CsvMulty.php +++ b/lib/internal/Magento/Framework/File/CsvMulty.php @@ -6,8 +6,6 @@ /** * Csv parse - * - * @author Magento Core Team */ 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..0861ba34a859d 100644 --- a/lib/internal/Magento/Framework/HTTP/Client/Curl.php +++ b/lib/internal/Magento/Framework/HTTP/Client/Curl.php @@ -11,7 +11,6 @@ /** * Class to work with HTTP protocol using curl library * - * @author Magento Core Team * @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 f0261e397ea88..42a10261d842b 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..196c180d38247 100644 --- a/lib/internal/Magento/Framework/HTTP/ClientFactory.php +++ b/lib/internal/Magento/Framework/HTTP/ClientFactory.php @@ -8,8 +8,6 @@ /** * Factory for HTTP client classes - * - * @author Magento Core Team */ class ClientFactory { diff --git a/lib/internal/Magento/Framework/HTTP/ZendClient.php b/lib/internal/Magento/Framework/HTTP/ZendClient.php index 1ffb26fffacf2..81ea015e00b01 100644 --- a/lib/internal/Magento/Framework/HTTP/ZendClient.php +++ b/lib/internal/Magento/Framework/HTTP/ZendClient.php @@ -6,8 +6,6 @@ /** * Magento HTTP Client - * - * @author Magento Core Team */ namespace Magento\Framework\HTTP; diff --git a/lib/internal/Magento/Framework/Image.php b/lib/internal/Magento/Framework/Image.php index 5b49e9f303ca0..10e4a60dfd5e8 100644 --- a/lib/internal/Magento/Framework/Image.php +++ b/lib/internal/Magento/Framework/Image.php @@ -7,8 +7,6 @@ /** * Image handler library - * - * @author Magento Core Team */ class Image { diff --git a/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php b/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php index c49ca72dc0c56..b36bbe5e69106 100644 --- a/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php +++ b/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php @@ -8,7 +8,6 @@ /** * Algorithm for layer value filter * - * @author Magento Core Team * @api * @since 100.0.2 */ diff --git a/lib/internal/Magento/Framework/Url/Helper/Data.php b/lib/internal/Magento/Framework/Url/Helper/Data.php index 4f1caab3af781..be5bdfc61a41d 100644 --- a/lib/internal/Magento/Framework/Url/Helper/Data.php +++ b/lib/internal/Magento/Framework/Url/Helper/Data.php @@ -6,8 +6,6 @@ /** * Core URL helper - * - * @author Magento Core Team */ 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..9d8ec29feb89f 100644 --- a/lib/internal/Magento/Framework/View/Helper/Js.php +++ b/lib/internal/Magento/Framework/View/Helper/Js.php @@ -2,8 +2,6 @@ /** * JavaScript helper * - * @author Magento Core Team - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ From 322047d01d98b584892c6058ed93c5bf6715add8 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 20 Mar 2023 21:40:22 +0000 Subject: [PATCH 2/4] Conform to coding standard --- .../Framework/Data/Form/Element/Submit.php | 9 ++- .../Framework/Data/Form/Element/Textarea.php | 6 +- .../Framework/Data/Helper/PostHelper.php | 11 ++- lib/internal/Magento/Framework/Data/Tree.php | 23 +++++-- .../Magento/Framework/Data/Tree/Db.php | 45 +++++++++--- .../Magento/Framework/Data/Tree/Node.php | 45 ++++++++++-- .../Magento/Framework/DataObject/Cache.php | 47 ++++++++++--- lib/internal/Magento/Framework/Event.php | 15 ++-- .../Framework/Search/Dynamic/Algorithm.php | 68 +++++++++++++------ .../Magento/Framework/View/Helper/Js.php | 5 +- 10 files changed, 209 insertions(+), 65 deletions(-) diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Submit.php b/lib/internal/Magento/Framework/Data/Form/Element/Submit.php index 780b32c7be275..f4237acdc50af 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Submit.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Submit.php @@ -1,16 +1,17 @@ getRows()) { $this->setRows(self::DEFAULT_ROWS); } + if (!$this->getCols()) { $this->setCols(self::DEFAULT_COLS); } diff --git a/lib/internal/Magento/Framework/Data/Helper/PostHelper.php b/lib/internal/Magento/Framework/Data/Helper/PostHelper.php index f0671b6f3612c..68e9b479a1430 100644 --- a/lib/internal/Magento/Framework/Data/Helper/PostHelper.php +++ b/lib/internal/Magento/Framework/Data/Helper/PostHelper.php @@ -1,15 +1,18 @@ 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 1dec347209340..92687dc3ebb08 100644 --- a/lib/internal/Magento/Framework/Data/Tree.php +++ b/lib/internal/Magento/Framework/Data/Tree.php @@ -1,8 +1,10 @@ _nodes = new NodeCollection($this); @@ -46,6 +45,7 @@ public function getTree() * Enter description here... * * @param Node $parentNode + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -57,6 +57,7 @@ public function load($parentNode = null) * Enter description here... * * @param int|string $nodeId + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -70,6 +71,7 @@ public function loadNode($nodeId) * @param array|Node $data * @param Node $parentNode * @param Node $prevNode + * * @return Node * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -80,6 +82,7 @@ public function appendChild($data, $parentNode, $prevNode = null) } elseif ($data instanceof Node) { $node = $this->addNode($data, $parentNode); } + return $node; } @@ -88,6 +91,7 @@ public function appendChild($data, $parentNode, $prevNode = null) * * @param Node $node * @param Node $parent + * * @return Node */ public function addNode($node, $parent = null) @@ -97,6 +101,7 @@ public function addNode($node, $parent = null) if ($parent !== null && $parent instanceof Node) { $parent->addChild($node); } + return $node; } @@ -106,6 +111,7 @@ public function addNode($node, $parent = null) * @param Node $node * @param Node $parentNode * @param Node $prevNode + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -119,6 +125,7 @@ public function moveNodeTo($node, $parentNode, $prevNode = null) * @param Node $node * @param Node $parentNode * @param Node $prevNode + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -130,6 +137,7 @@ public function copyNodeTo($node, $parentNode, $prevNode = null) * Remove node * * @param Node $node + * * @return $this */ public function removeNode($node) @@ -138,6 +146,7 @@ public function removeNode($node) if ($node->getParent()) { $node->getParent()->removeChild($node); } + unset($node); return $this; } @@ -147,6 +156,7 @@ public function removeNode($node) * * @param Node $parentNode * @param Node $prevNode + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -158,6 +168,7 @@ public function createNode($parentNode, $prevNode = null) * Get child * * @param Node $node + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -169,6 +180,7 @@ public function getChild($node) * Get children * * @param Node $node + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -190,6 +202,7 @@ public function getNodes() * Enter description here... * * @param Node $nodeId + * * @return Node */ public function getNodeById($nodeId) @@ -201,6 +214,7 @@ public function getNodeById($nodeId) * Get path * * @param Node $node + * * @return array */ public function getPath($node) @@ -211,6 +225,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 050b3349caf49..5e39e9c63d169 100644 --- a/lib/internal/Magento/Framework/Data/Tree/Db.php +++ b/lib/internal/Magento/Framework/Data/Tree/Db.php @@ -1,8 +1,10 @@ string, * \Magento\Framework\Data\Tree\Db::PARENT_FIELD => string, @@ -83,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) @@ -119,6 +117,8 @@ public function __construct(\Magento\Framework\DB\Adapter\AdapterInterface $conn } /** + * Get database select + * * @return \Magento\Framework\DB\Select */ public function getDbSelect() @@ -127,7 +127,10 @@ public function getDbSelect() } /** + * Set database select + * * @param \Magento\Framework\DB\Select $select + * * @return void */ public function setDbSelect($select) @@ -139,8 +142,9 @@ public function setDbSelect($select) * Load tree * * @param int|Node $parentNode - * @param int $recursionLevel recursion level - * @return $this + * @param int $recursionLevel + * + * @return $this * @throws \Exception */ public function load($parentNode = null, $recursionLevel = 100) @@ -170,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) @@ -188,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) @@ -220,6 +231,7 @@ public function appendChild($data, $parentNode, $prevNode = null) * @param Node $node * @param Node $parentNode * @param Node $prevNode + * * @return void * @throws \Exception */ @@ -234,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 @@ -277,8 +290,11 @@ public function moveNodeTo($node, $parentNode, $prevNode = null) } /** + * Update child levels + * * @param mixed $parentId * @param int $parentLevel + * * @return $this */ protected function _updateChildLevels($parentId, $parentLevel) @@ -302,10 +318,13 @@ protected function _updateChildLevels($parentId, $parentLevel) $this->_updateChildLevels($id, $parentLevel + 1); } } + return $this; } /** + * Load full tree + * * @return $this */ protected function _loadFullTree() @@ -325,7 +344,10 @@ protected function _loadFullTree() } /** + * Remove node + * * @param Node $node + * * @return $this * @throws \Exception */ @@ -356,6 +378,7 @@ public function removeNode($node) $this->_conn->rollBack(); throw new \Exception('Can\'t remove tree node'); } + parent::removeNode($node); return $this; } diff --git a/lib/internal/Magento/Framework/Data/Tree/Node.php b/lib/internal/Magento/Framework/Data/Tree/Node.php index 9658695c59e6d..f20f976e4dd58 100644 --- a/lib/internal/Magento/Framework/Data/Tree/Node.php +++ b/lib/internal/Magento/Framework/Data/Tree/Node.php @@ -1,8 +1,10 @@ _parent->getPath($prevNodes); } + return $prevNodes; } /** + * Get is active + * * @return mixed */ public function getIsActive() @@ -295,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 ffcf52420ad2c..ad6ffb65b01bd 100644 --- a/lib/internal/Magento/Framework/DataObject/Cache.php +++ b/lib/internal/Magento/Framework/DataObject/Cache.php @@ -1,8 +1,10 @@ _references[$idx])) { $idx = $this->_references[$idx]; } + if (isset($this->_objects[$idx])) { return $this->_objects[$idx]; } + return $default; } @@ -119,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) @@ -126,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; } @@ -135,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])) { @@ -170,7 +177,6 @@ public function save($object, $idx = null, $tags = null) $this->_objectTags[$idx][$t] = true; } } - //\Magento\Framework\Profiler::stop('OBJECT_SAVE'); return $idx; } @@ -180,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 */ @@ -189,6 +196,7 @@ public function reference($refName, $idx) foreach ($refName as $ref) { $this->reference($ref, $idx); } + return; } @@ -200,6 +208,7 @@ public function reference($refName, $idx) ) ); } + $this->_references[$refName] = $idx; $this->_objectReferences[$idx][$refName] = true; @@ -210,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; } @@ -237,6 +244,7 @@ public function delete($idx) foreach ($this->_objectTags[$idx] as $t => $dummy) { unset($this->_tags[$t][$idx]); } + unset($this->_objectTags[$idx]); } @@ -244,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; } @@ -255,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) @@ -270,6 +279,7 @@ public function deleteByClass($class) * Cleanup objects by tags * * @param array|string $tags + * * @return true * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ @@ -278,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; } @@ -290,6 +302,7 @@ public function deleteByTags($tags) * Check whether object id exists in registry * * @param string $idx + * * @return boolean */ public function has($idx) @@ -301,6 +314,7 @@ public function has($idx) * Find an object id * * @param object $object + * * @return string|boolean */ public function find($object) @@ -310,6 +324,7 @@ public function find($object) return $idx; } } + return false; } @@ -317,6 +332,7 @@ public function find($object) * Find objects by ids * * @param string[] $ids + * * @return array */ public function findByIds($ids) @@ -327,6 +343,7 @@ public function findByIds($ids) $objects[$idx] = $obj; } } + return $objects; } @@ -334,6 +351,7 @@ public function findByIds($ids) * Find object by hash * * @param string $hash + * * @return object */ public function findByHash($hash) @@ -345,6 +363,7 @@ public function findByHash($hash) * Find objects by tags * * @param array|string $tags + * * @return array * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ @@ -353,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; } @@ -369,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) @@ -379,6 +402,7 @@ public function findByClass($class) $objects[$idx] = $object; } } + return $objects; } @@ -387,6 +411,7 @@ public function findByClass($class) * * @param string $idx * @param object|null $object + * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -401,6 +426,7 @@ public function debug($idx, $object = null) 'function' => isset($step['function']) ? $step['function'] : null, ]; } + $this->_debug[$idx] = $debug; } @@ -408,6 +434,7 @@ public function debug($idx, $object = null) * Return debug information by ids * * @param array|string $ids + * * @return array */ public function debugByIds($ids) @@ -415,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 d67738b0a6e68..d15cad8f9b2f7 100644 --- a/lib/internal/Magento/Framework/Event.php +++ b/lib/internal/Magento/Framework/Event.php @@ -1,15 +1,15 @@ _intervalsNumber = max(ceil($intervalsNumber), self::MIN_INTERVALS_NUMBER); $this->_intervalsNumber = (int)min($this->_intervalsNumber, self::MAX_INTERVALS_NUMBER); @@ -163,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) @@ -179,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; @@ -230,6 +233,7 @@ public function calculateSeparators(IntervalInterface $interval) } } } + if ($this->_lastValueLimiter[0] < $this->_count) { $isEqualValue = $intervalFirstValue == $this->_maxValue ? $intervalFirstValue : false; $result[$this->getIntervalsNumber()] = [ @@ -259,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) @@ -279,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( @@ -288,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 = []; @@ -316,6 +324,7 @@ protected function _findValueSeparator($quantileNumber, IntervalInterface $inter ); } } + if ($quantileNumber == $this->getIntervalsNumber() - 1) { $valuesCount = count($values); if ($values[$valuesCount - 1] > $lastValue) { @@ -327,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], @@ -378,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) @@ -386,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 = [ @@ -401,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]; @@ -409,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) @@ -424,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) @@ -444,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)); @@ -467,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( @@ -483,6 +501,7 @@ protected function _findRoundValue($lowerValue, $upperValue, $returnEmpty = true $result[$index] = $roundValues; } } + $tenPower /= 10; } @@ -492,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) @@ -525,6 +545,7 @@ protected function _getCalculatedIntervalsNumber() * * @param int $quantileNumber * @param array $separators + * * @return array|false [deflection, separatorValue, $valueIndex] */ protected function _findBestSeparator($quantileNumber, $separators) @@ -560,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) @@ -574,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/View/Helper/Js.php b/lib/internal/Magento/Framework/View/Helper/Js.php index 9d8ec29feb89f..7d9e4a29fabe6 100644 --- a/lib/internal/Magento/Framework/View/Helper/Js.php +++ b/lib/internal/Magento/Framework/View/Helper/Js.php @@ -1,10 +1,10 @@ Date: Thu, 27 Jun 2024 08:57:05 +0530 Subject: [PATCH 3/4] Fixed static test failures --- lib/internal/Magento/Framework/Data/Tree.php | 3 +++ lib/internal/Magento/Framework/Data/Tree/Db.php | 14 +++++++------- lib/internal/Magento/Framework/Data/Tree/Node.php | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/internal/Magento/Framework/Data/Tree.php b/lib/internal/Magento/Framework/Data/Tree.php index 92687dc3ebb08..f177bd4e3fe87 100644 --- a/lib/internal/Magento/Framework/Data/Tree.php +++ b/lib/internal/Magento/Framework/Data/Tree.php @@ -26,6 +26,9 @@ class Tree */ protected $_nodes; + /** + * Initialize Tree + */ public function __construct() { $this->_nodes = new NodeCollection($this); diff --git a/lib/internal/Magento/Framework/Data/Tree/Db.php b/lib/internal/Magento/Framework/Data/Tree/Db.php index 5e39e9c63d169..7f6352a9ee16e 100644 --- a/lib/internal/Magento/Framework/Data/Tree/Db.php +++ b/lib/internal/Magento/Framework/Data/Tree/Db.php @@ -88,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; @@ -104,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]; @@ -141,8 +141,8 @@ public function setDbSelect($select) /** * Load tree * - * @param int|Node $parentNode - * @param int $recursionLevel + * @param int|Node $parentNode + * @param int $recursionLevel * * @return $this * @throws \Exception @@ -158,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; @@ -285,7 +285,7 @@ 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 } } @@ -376,7 +376,7 @@ 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); diff --git a/lib/internal/Magento/Framework/Data/Tree/Node.php b/lib/internal/Magento/Framework/Data/Tree/Node.php index f20f976e4dd58..d9e00ec92fffe 100644 --- a/lib/internal/Magento/Framework/Data/Tree/Node.php +++ b/lib/internal/Magento/Framework/Data/Tree/Node.php @@ -178,9 +178,9 @@ 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) { From 8660d8531b8cbadc512ed451eb56bc1aac53873a Mon Sep 17 00:00:00 2001 From: glo24157 Date: Fri, 16 May 2025 14:48:51 +0530 Subject: [PATCH 4/4] Fix copyright static test failure --- .../Data/Form/Element/Renderer/RendererInterface.php | 4 ++-- lib/internal/Magento/Framework/Data/Form/Element/Reset.php | 4 ++-- lib/internal/Magento/Framework/Data/Form/Element/Select.php | 4 ++-- lib/internal/Magento/Framework/Data/Form/Element/Submit.php | 4 ++-- lib/internal/Magento/Framework/Data/Form/Element/Textarea.php | 4 ++-- lib/internal/Magento/Framework/Data/Form/Element/Time.php | 4 ++-- .../Magento/Framework/Data/Form/Filter/Escapehtml.php | 4 ++-- .../Magento/Framework/Data/Form/Filter/FilterInterface.php | 4 ++-- lib/internal/Magento/Framework/Data/Form/Filter/Striptags.php | 4 ++-- lib/internal/Magento/Framework/Data/Form/Filter/Trim.php | 4 ++-- lib/internal/Magento/Framework/Data/Helper/PostHelper.php | 4 ++-- lib/internal/Magento/Framework/Data/Tree.php | 4 ++-- lib/internal/Magento/Framework/Data/Tree/Db.php | 4 ++-- lib/internal/Magento/Framework/Data/Tree/Dbp.php | 4 ++-- lib/internal/Magento/Framework/Data/Tree/Node.php | 4 ++-- lib/internal/Magento/Framework/DataObject/Cache.php | 4 ++-- lib/internal/Magento/Framework/Event.php | 4 ++-- lib/internal/Magento/Framework/Event/Collection.php | 4 ++-- lib/internal/Magento/Framework/Event/Observer/Collection.php | 4 ++-- lib/internal/Magento/Framework/Event/Observer/Cron.php | 4 ++-- lib/internal/Magento/Framework/Event/Observer/Regex.php | 4 ++-- lib/internal/Magento/Framework/File/CsvMulty.php | 4 ++-- lib/internal/Magento/Framework/HTTP/Client/Curl.php | 4 ++-- lib/internal/Magento/Framework/HTTP/ClientFactory.php | 4 ++-- lib/internal/Magento/Framework/HTTP/ZendClient.php | 4 ++-- lib/internal/Magento/Framework/Image.php | 4 ++-- lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php | 4 ++-- lib/internal/Magento/Framework/Url/Helper/Data.php | 4 ++-- lib/internal/Magento/Framework/View/Helper/Js.php | 4 ++-- 29 files changed, 58 insertions(+), 58 deletions(-) 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 72e5bc8f2562a..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,7 +1,7 @@