Skip to content

Commit

Permalink
MAGETWO-43236: [GITHUB] use return value instead of reference parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Medinskiy committed Sep 24, 2015
2 parents c077da6 + eebdcb7 commit 9621f58
Show file tree
Hide file tree
Showing 29 changed files with 83 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$store = $this->storeManager->getStore(
Expand All @@ -64,5 +64,7 @@ public function prepareDataSource(array & $dataSource)
}
}
}

return $dataSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array &$dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$storeId = $this->context->getFilterParam('store_id');
Expand All @@ -60,5 +60,7 @@ public function prepareDataSource(array &$dataSource)
];
}
}

return $dataSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$fieldName = $this->getData('name');
Expand All @@ -58,6 +58,8 @@ public function prepareDataSource(array & $dataSource)
$item[$fieldName . '_orig_src'] = $origImageHelper->getUrl();
}
}

return $dataSource;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
$websiteNames = [];
foreach ($this->getData('options') as $website) {
Expand All @@ -60,6 +60,8 @@ public function prepareDataSource(array & $dataSource)
$item[$fieldName] = implode(', ', $websites);
}
}

return $dataSource;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function testPrepareItemsByPageId()
);

$model->setName($name);
$model->prepareDataSource($items);
$items = $model->prepareDataSource($items);
// Run test
$this->assertEquals($expectedItems, $items['data']['items']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
Expand Down Expand Up @@ -98,5 +98,7 @@ public function prepareDataSource(array & $dataSource)
}
}
}

return $dataSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
Expand Down Expand Up @@ -92,5 +92,7 @@ public function prepareDataSource(array & $dataSource)
}
}
}

return $dataSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testPrepareDataSource()
)
->willReturn('http://magento.com/customer/index/edit');

$this->component->prepareDataSource($dataSource);
$dataSource = $this->component->prepareDataSource($dataSource);

$this->assertEquals($expectedDataSource, $dataSource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,6 @@ public function setup()
$this->component->setData('name', 'gender');
}

public function testPrepareDataSourceWithoutItems()
{
$dataSource = [
'data' => [

]
];
$this->attributeRepository->expects($this->never())
->method('getMetadataByCode');

$this->assertNull($this->component->prepareDataSource($dataSource));
}

public function testPrepareDataSource()
{
$genderOptionId = 1;
Expand Down Expand Up @@ -125,7 +112,7 @@ public function testPrepareDataSource()
'is_searchable_in_grid' => true,
]);

$this->component->prepareDataSource($dataSource);
$dataSource = $this->component->prepareDataSource($dataSource);

$this->assertEquals($expectedSource, $dataSource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array &$dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$storeId = $this->context->getFilterParam('store_id');
Expand All @@ -60,5 +60,7 @@ public function prepareDataSource(array &$dataSource)
];
}
}

return $dataSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array &$dataSource)
public function prepareDataSource(array $dataSource)
{
if (!isset($dataSource['data']['items'])) {
return null;
}

$metaData = $this->attributeRepository->getMetadataByCode($this->getName());
if ($metaData && count($metaData[AttributeMetadata::OPTIONS])) {
foreach ($dataSource['data']['items'] as &$item) {
Expand All @@ -60,5 +56,7 @@ public function prepareDataSource(array &$dataSource)
}
}
}

return $dataSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Type extends Column
* @param array $dataSource
* @return void
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
Expand All @@ -28,5 +28,7 @@ public function prepareDataSource(array & $dataSource)
: __('Customer');
}
}

return $dataSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testPrepareDataSource()
];

$this->model->setData('name', $itemName);
$this->model->prepareDataSource($dataSource);
$dataSource = $this->model->prepareDataSource($dataSource);
$this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testPrepareDataSource()
->willReturn($group);

$this->model->setData('name', $itemName);
$this->model->prepareDataSource($dataSource);
$dataSource = $this->model->prepareDataSource($dataSource);
$this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testPrepareDataSource()
->willReturn($payment);

$this->model->setData('name', $itemName);
$this->model->prepareDataSource($dataSource);
$dataSource = $this->model->prepareDataSource($dataSource);
$this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testPrepareDataSource()
->willReturn($newItemValue);

$this->model->setData('name', $itemName);
$this->model->prepareDataSource($dataSource);
$dataSource = $this->model->prepareDataSource($dataSource);
$this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testPrepareDataSource()
['collectionFactory' => $collectionFactoryMock]
);
$model->setData('name', $itemName);
$model->prepareDataSource($dataSource);
$dataSource = $model->prepareDataSource($dataSource);
$this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ class Address extends Column
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
$item[$this->getData('name')] = str_replace("\n", '<br/>', $item[$this->getData('name')]);
}
}

return $dataSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
Expand All @@ -55,5 +55,7 @@ public function prepareDataSource(array & $dataSource)
: $item[$this->getData('name')];
}
}

return $dataSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
Expand All @@ -62,5 +62,7 @@ public function prepareDataSource(array & $dataSource)
}
}
}

return $dataSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
Expand All @@ -55,5 +55,7 @@ public function prepareDataSource(array & $dataSource)
: $item[$this->getData('name')];
}
}

return $dataSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
Expand All @@ -59,5 +59,7 @@ public function prepareDataSource(array & $dataSource)
}
}
}

return $dataSource;
}
}
6 changes: 4 additions & 2 deletions app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ public function __construct(
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
*/
public function prepareDataSource(array & $dataSource)
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
$item[$this->getData('name')] = $this->priceFormatter->format($item[$this->getData('name')], false);
}
}

return $dataSource;
}
}
Loading

0 comments on commit 9621f58

Please sign in to comment.