Skip to content

Commit 0886ba9

Browse files
committed
Fix complaints from static code analysers
1 parent 020de6d commit 0886ba9

File tree

2 files changed

+23
-4
lines changed
  • app/code/Magento/Sitemap

2 files changed

+23
-4
lines changed

app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
7+
68
namespace Magento\Sitemap\Model\ResourceModel\Cms;
79

10+
use Magento\Framework\DataObject;
811
use Magento\Cms\Api\Data\PageInterface;
912
use Magento\Cms\Api\GetUtilityPageIdentifiersInterface;
1013
use Magento\Cms\Model\Page as CmsPage;
@@ -21,6 +24,8 @@
2124
*
2225
* @api
2326
* @since 100.0.2
27+
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
28+
* @SuppressWarnings(PHPMD.LongVariable)
2429
*/
2530
class Page extends AbstractDb
2631
{
@@ -85,6 +90,7 @@ public function getConnection()
8590
* Retrieve cms page collection array
8691
*
8792
* @param int $storeId
93+
*
8894
* @return array
8995
*/
9096
public function getCollection($storeId)
@@ -133,11 +139,12 @@ static function ($urlKey) {
133139
* Prepare page object
134140
*
135141
* @param array $data
136-
* @return \Magento\Framework\DataObject
142+
*
143+
* @return DataObject
137144
*/
138145
protected function _prepareObject(array $data)
139146
{
140-
$object = new \Magento\Framework\DataObject();
147+
$object = new DataObject();
141148
$object->setId($data[$this->getIdFieldName()]);
142149
$object->setUrl($data['url']);
143150
$object->setUpdatedAt($data['updated_at']);
@@ -150,7 +157,8 @@ protected function _prepareObject(array $data)
150157
*
151158
* @param CmsPage|AbstractModel $object
152159
* @param mixed $value
153-
* @param string $field field to load by (defaults to model id)
160+
* @param string $field Field to load by (defaults to model id).
161+
*
154162
* @return $this
155163
* @since 100.1.0
156164
*/
@@ -178,6 +186,7 @@ public function load(AbstractModel $object, $value, $field = null)
178186
if ($isId) {
179187
$this->entityManager->load($object, $value);
180188
}
189+
181190
return $this;
182191
}
183192

@@ -200,6 +209,7 @@ public function save(AbstractModel $object)
200209
$object->setHasDataChanges(false);
201210
return $this;
202211
}
212+
203213
$object->validateBeforeSave();
204214
$object->beforeSave();
205215
if ($object->isSaveAllowed()) {
@@ -211,13 +221,15 @@ public function save(AbstractModel $object)
211221
$this->unserializeFields($object);
212222
$this->processAfterSaves($object);
213223
}
224+
214225
$this->addCommitCallback([$object, 'afterCommitCallback'])->commit();
215226
$object->setHasDataChanges(false);
216227
} catch (\Exception $e) {
217228
$this->rollBack();
218229
$object->setHasDataChanges(true);
219230
throw $e;
220231
}
232+
221233
return $this;
222234
}
223235

app/code/Magento/Sitemap/Test/Unit/Model/ResourceModel/Cms/PageTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
7+
68
declare(strict_types=1);
79

810
namespace Magento\Sitemap\Test\Unit\Model\ResourceModel\Cms;
@@ -25,6 +27,8 @@
2527
/**
2628
* Provide tests for Cms Page resource model.
2729
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
30+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
31+
* @SuppressWarnings(PHPMD.LongVariable)
2832
*/
2933
class PageTest extends TestCase
3034
{
@@ -151,7 +155,10 @@ public function testGetCollection()
151155
->method('where')
152156
->withConsecutive(
153157
[$this->identicalTo('main_table.is_active = 1')],
154-
[$this->identicalTo('main_table.identifier NOT IN (?)'), $this->identicalTo(array_values($pageIdentifiers))],
158+
[
159+
$this->identicalTo('main_table.identifier NOT IN (?)'),
160+
$this->identicalTo(array_values($pageIdentifiers))
161+
],
155162
[$this->identicalTo('store_table.store_id IN(?)'), $this->identicalTo([0, $storeId])]
156163
)->willReturnSelf();
157164

0 commit comments

Comments
 (0)