Skip to content

Commit 513d6d0

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents 9acb9d6 + d0c8f05 commit 513d6d0

File tree

35 files changed

+245
-111
lines changed

35 files changed

+245
-111
lines changed

app/code/Magento/Backend/Block/Widget/Grid.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@ protected function _addColumnFilterToCollection($column)
300300
if ($this->getCollection()) {
301301
$field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
302302
if ($column->getFilterConditionCallback()) {
303-
call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
303+
$column->getFilterConditionCallback()[0]->{$column->getFilterConditionCallback()[1]}(
304+
$this->getCollection(),
305+
$column
306+
);
304307
} else {
305308
$condition = $column->getFilter()->getCondition();
306309
if ($field && isset($condition)) {
@@ -363,7 +366,7 @@ protected function _prepareCollection()
363366
$this->_setFilterValues($data);
364367
} elseif ($filter && is_array($filter)) {
365368
$this->_setFilterValues($filter);
366-
} elseif (0 !== sizeof($this->_defaultFilter)) {
369+
} elseif (0 !== count($this->_defaultFilter)) {
367370
$this->_setFilterValues($this->_defaultFilter);
368371
}
369372

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function render(\Magento\Framework\DataObject $row)
4747
return ' ';
4848
}
4949

50-
if (sizeof($actions) == 1 && !$this->getColumn()->getNoLink()) {
50+
if (count($actions) == 1 && !$this->getColumn()->getNoLink()) {
5151
foreach ($actions as $action) {
5252
if (is_array($action)) {
5353
return $this->_toLinkHtml($action, $row);
@@ -104,6 +104,7 @@ protected function _toLinkHtml($action, \Magento\Framework\DataObject $row)
104104
$this->_transformActionData($action, $actionCaption, $row);
105105

106106
if (isset($action['confirm'])) {
107+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
107108
$action['onclick'] = 'return window.confirm(\'' . addslashes(
108109
$this->escapeHtml($action['confirm'])
109110
) . '\')';
@@ -117,8 +118,8 @@ protected function _toLinkHtml($action, \Magento\Framework\DataObject $row)
117118
/**
118119
* Prepares action data for html render
119120
*
120-
* @param array &$action
121-
* @param string &$actionCaption
121+
* @param &array $action
122+
* @param &string $actionCaption
122123
* @param \Magento\Framework\DataObject $row
123124
* @return $this
124125
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -144,7 +145,7 @@ protected function _transformActionData(&$action, &$actionCaption, \Magento\Fram
144145
if (is_array($action['url']) && isset($action['field'])) {
145146
$params = [$action['field'] => $this->_getValue($row)];
146147
if (isset($action['url']['params'])) {
147-
$params = array_merge($action['url']['params'], $params);
148+
$params[] = $action['url']['params'];
148149
}
149150
$action['href'] = $this->getUrl($action['url']['base'], $params);
150151
unset($action['field']);

app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/**
99
* Adminhtml abstract dashboard helper.
1010
*
11+
* phpcs:disable Magento2.Classes.AbstractApi
1112
* @api
1213
* @since 100.0.2
1314
*/
@@ -28,6 +29,8 @@ abstract class AbstractDashboard extends \Magento\Framework\App\Helper\AbstractH
2829
protected $_params = [];
2930

3031
/**
32+
* Return collections
33+
*
3134
* @return array|\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
3235
*/
3336
public function getCollection()
@@ -39,6 +42,8 @@ public function getCollection()
3942
}
4043

4144
/**
45+
* Init collections
46+
*
4247
* @return void
4348
*/
4449
abstract protected function _initCollection();
@@ -54,14 +59,18 @@ public function getItems()
5459
}
5560

5661
/**
62+
* Return items count
63+
*
5764
* @return int
5865
*/
5966
public function getCount()
6067
{
61-
return sizeof($this->getItems());
68+
return count($this->getItems());
6269
}
6370

6471
/**
72+
* Return column
73+
*
6574
* @param string $index
6675
* @return array
6776
*/
@@ -85,6 +94,8 @@ public function getColumn($index)
8594
}
8695

8796
/**
97+
* Set params with value
98+
*
8899
* @param string $name
89100
* @param mixed $value
90101
* @return void
@@ -95,6 +106,8 @@ public function setParam($name, $value)
95106
}
96107

97108
/**
109+
* Set params
110+
*
98111
* @param array $params
99112
* @return void
100113
*/
@@ -104,6 +117,8 @@ public function setParams(array $params)
104117
}
105118

106119
/**
120+
* Get params with name
121+
*
107122
* @param string $name
108123
* @return mixed
109124
*/
@@ -117,6 +132,8 @@ public function getParam($name)
117132
}
118133

119134
/**
135+
* Get params
136+
*
120137
* @return array
121138
*/
122139
public function getParams()

app/code/Magento/Backend/Helper/Dashboard/Data.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function getStores()
6868
*/
6969
public function countStores()
7070
{
71-
return sizeof($this->_stores->getItems());
71+
return count($this->_stores->getItems());
7272
}
7373

7474
/**
@@ -88,15 +88,15 @@ public function getDatePeriods()
8888
}
8989

9090
/**
91-
* Create data hash to ensure that we got valid
92-
* data and it is not changed by some one else.
91+
* Create data hash to ensure that we got valid data and it is not changed by some one else.
9392
*
9493
* @param string $data
9594
* @return string
9695
*/
9796
public function getChartDataHash($data)
9897
{
9998
$secret = $this->_installDate;
99+
// phpcs:disable Magento2.Security.InsecureFunction.FoundWithAlternative
100100
return md5($data . $secret);
101101
}
102102
}

app/code/Magento/Catalog/Model/Entity/Product/Attribute/Design/Options/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Container extends \Magento\Eav\Model\Entity\Attribute\Source\Config
2121
public function getOptionText($value)
2222
{
2323
$options = $this->getAllOptions();
24-
if (sizeof($options) > 0) {
24+
if (count($options) > 0) {
2525
foreach ($options as $option) {
2626
if (isset($option['value']) && $option['value'] == $value) {
2727
return __($option['label']);

app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,13 @@ public function testTierPrices($priceScope, $expectedWebsiteId)
165165
$this->websiteMock->expects($this->any())->method('getId')->will($this->returnValue($expectedWebsiteId));
166166
$this->tpFactory->expects($this->any())
167167
->method('create')
168-
->will($this->returnCallback(function () {
169-
return $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\TierPrice::class);
170-
}));
168+
->will(
169+
$this->returnCallback(
170+
function () {
171+
return $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\TierPrice::class);
172+
}
173+
)
174+
);
171175

172176
// create sample TierPrice objects that would be coming from a REST call
173177
$tierPriceExtensionMock = $this->getMockBuilder(ProductTierPriceExtensionInterface::class)
@@ -198,9 +202,10 @@ public function testTierPrices($priceScope, $expectedWebsiteId)
198202
$tpArray = $this->product->getData($this::KEY_TIER_PRICE);
199203
$this->assertNotNull($tpArray);
200204
$this->assertTrue(is_array($tpArray));
201-
$this->assertEquals(sizeof($tps), sizeof($tpArray));
205+
$this->assertEquals(count($tps), count($tpArray));
202206

203-
for ($i = 0; $i < sizeof($tps); $i++) {
207+
$count = count($tps);
208+
for ($i = 0; $i < $count; $i++) {
204209
$tpData = $tpArray[$i];
205210
$this->assertEquals($expectedWebsiteId, $tpData['website_id'], 'Website Id does not match');
206211
$this->assertEquals($tps[$i]->getValue(), $tpData['price'], 'Price/Value does not match');
@@ -226,12 +231,13 @@ public function testTierPrices($priceScope, $expectedWebsiteId)
226231
$tpRests = $this->model->getTierPrices($this->product);
227232
$this->assertNotNull($tpRests);
228233
$this->assertTrue(is_array($tpRests));
229-
$this->assertEquals(sizeof($tps), sizeof($tpRests));
234+
$this->assertEquals(count($tps), count($tpRests));
230235
foreach ($tpRests as $tpRest) {
231236
$this->assertEquals(50, $tpRest->getExtensionAttributes()->getPercentageValue());
232237
}
233238

234-
for ($i = 0; $i < sizeof($tps); $i++) {
239+
$count = count($tps);
240+
for ($i = 0; $i < $count; $i++) {
235241
$this->assertEquals(
236242
$tps[$i]->getValue(),
237243
$tpRests[$i]->getValue(),

app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ protected function generalTestGetDirsCollection($path, $collectionArray = [], $e
454454
$storageCollectionMock->expects($this->once())
455455
->method('getIterator')
456456
->willReturn(new \ArrayIterator($collectionArray));
457-
$storageCollectionInvMock = $storageCollectionMock->expects($this->exactly(sizeof($expectedRemoveKeys)))
457+
$storageCollectionInvMock = $storageCollectionMock->expects($this->exactly(count($expectedRemoveKeys)))
458458
->method('removeItemByKey');
459459
call_user_func_array([$storageCollectionInvMock, 'withConsecutive'], $expectedRemoveKeys);
460460

app/code/Magento/Cron/Model/Schedule.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function _construct()
9797
public function setCronExpr($expr)
9898
{
9999
$e = preg_split('#\s+#', $expr, null, PREG_SPLIT_NO_EMPTY);
100-
if (sizeof($e) < 5 || sizeof($e) > 6) {
100+
if (count($e) < 5 || count($e) > 6) {
101101
throw new CronException(__('Invalid cron expression: %1', $expr));
102102
}
103103

@@ -168,7 +168,7 @@ public function matchCronExpression($expr, $num)
168168
// handle modulus
169169
if (strpos($expr, '/') !== false) {
170170
$e = explode('/', $expr);
171-
if (sizeof($e) !== 2) {
171+
if (count($e) !== 2) {
172172
throw new CronException(__('Invalid cron expression, expecting \'match/modulus\': %1', $expr));
173173
}
174174
if (!is_numeric($e[1])) {
@@ -187,7 +187,7 @@ public function matchCronExpression($expr, $num)
187187
} elseif (strpos($expr, '-') !== false) {
188188
// handle range
189189
$e = explode('-', $expr);
190-
if (sizeof($e) !== 2) {
190+
if (count($e) !== 2) {
191191
throw new CronException(__('Invalid cron expression, expecting \'from-to\' structure: %1', $expr));
192192
}
193193

app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currency/Rate/Matrix.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
*/
1212
namespace Magento\CurrencySymbol\Block\Adminhtml\System\Currency\Rate;
1313

14+
/**
15+
* Manage currency block
16+
*/
1417
class Matrix extends \Magento\Backend\Block\Template
1518
{
1619
/**
@@ -105,7 +108,7 @@ protected function _prepareRates($array)
105108
foreach ($array as $key => $rate) {
106109
foreach ($rate as $code => $value) {
107110
$parts = explode('.', $value);
108-
if (sizeof($parts) == 2) {
111+
if (count($parts) == 2) {
109112
$parts[1] = str_pad(rtrim($parts[1], 0), 4, '0', STR_PAD_RIGHT);
110113
$array[$key][$code] = join('.', $parts);
111114
} elseif ($value > 0) {

app/code/Magento/Directory/Model/ResourceModel/Currency.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function getAnyRate($currencyFrom, $currencyTo)
138138
*/
139139
public function saveRates($rates)
140140
{
141-
if (is_array($rates) && sizeof($rates) > 0) {
141+
if (is_array($rates) && count($rates) > 0) {
142142
$connection = $this->getConnection();
143143
$data = [];
144144
foreach ($rates as $currencyCode => $rate) {
@@ -176,7 +176,7 @@ public function getConfigCurrencies($model, $path)
176176
$result = [];
177177
$rowSet = $connection->fetchAll($select, $bind);
178178
foreach ($rowSet as $row) {
179-
$result = array_merge($result, explode(',', $row['value']));
179+
$result[] = explode(',', $row['value']);
180180
}
181181
sort($result);
182182

0 commit comments

Comments
 (0)