Skip to content

Commit cbc85da

Browse files
committed
Make Api\SearchResults implement Api\SearchResultsInterface
Purpose == Make the implementation actually fulfill the contract defined by the interface. Background == The return type hints of almost all the repository implementations of the `getList()` method indicate a return type of `\Magento\Framework\Api\SearchResultsInterface` or one of its sub-interfaces. One example of many is `\Magento\Catalog\Api\ProductRepositoryInterface::getList()`. The return type hint states it returns `\Magento\Catalog\Api\Data\ProductSearchResultsInterface`, which in turn extends `\Magento\Framework\Api\SearchResultsInterface`. However, the concrete implementation preference for that interface is `\Magento\Framework\Api\SearchResults`, which does not implement `\Magento\Framework\Api\SearchResultsInterface` (or any interface for that matter). Reasons for this PR == This PR makes `Api\SearchResults` actually implement `Api\SearchResultsInterface`, forcing all implementations to match the contract. It also improves developer experience because this is pretty much what should be expected of the code anyway. It also makes the preference configuration technically more correct, because the configured concrete class is guaranteed to at least partially fulfill the contract defined by the interface.
1 parent b67a5e0 commit cbc85da

File tree

37 files changed

+41
-40
lines changed

37 files changed

+41
-40
lines changed

app/code/Magento/Catalog/Api/Data/CategoryAttributeSearchResultsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ public function getItems();
2424
* @param \Magento\Catalog\Api\Data\CategoryAttributeInterface[] $items
2525
* @return $this
2626
*/
27-
public function setItems(array $items = null);
27+
public function setItems(array $items);
2828
}

app/code/Magento/Catalog/Api/Data/ProductAttributeSearchResultsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ public function getItems();
2424
* @param \Magento\Catalog\Api\Data\ProductAttributeInterface[] $items
2525
* @return $this
2626
*/
27-
public function setItems(array $items = null);
27+
public function setItems(array $items);
2828
}

app/code/Magento/Catalog/Api/Data/ProductSearchResultsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ public function getItems();
2424
* @param \Magento\Catalog\Api\Data\ProductInterface[] $items
2525
* @return $this
2626
*/
27-
public function setItems(array $items = null);
27+
public function setItems(array $items);
2828
}

app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ public function getItems();
3030
* @param \Magento\CatalogInventory\Api\Data\StockInterface[] $items
3131
* @return $this
3232
*/
33-
public function setItems(array $items = null);
33+
public function setItems(array $items);
3434
}

app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function getItems();
3030
* @param \Magento\CatalogInventory\Api\Data\StockItemInterface[] $items
3131
* @return $this
3232
*/
33-
public function setItems(array $items = null);
33+
public function setItems(array $items);
3434

3535
/**
3636
* Get search criteria.

app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function getItems();
2727
* @param \Magento\CatalogInventory\Api\Data\StockStatusInterface[] $items
2828
* @return $this
2929
*/
30-
public function setItems(array $items = null);
30+
public function setItems(array $items);
3131

3232
/**
3333
* Get search criteria.

app/code/Magento/Cms/Api/Data/BlockSearchResultsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ public function getItems();
2626
* @param \Magento\Cms\Api\Data\BlockInterface[] $items
2727
* @return $this
2828
*/
29-
public function setItems(array $items = null);
29+
public function setItems(array $items);
3030
}

app/code/Magento/Cms/Api/Data/PageSearchResultsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ public function getItems();
2626
* @param \Magento\Cms\Api\Data\PageInterface[] $items
2727
* @return $this
2828
*/
29-
public function setItems(array $items = null);
29+
public function setItems(array $items);
3030
}

app/code/Magento/Customer/Api/Data/AddressSearchResultsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ public function getItems();
2626
* @param \Magento\Customer\Api\Data\AddressInterface[] $items
2727
* @return $this
2828
*/
29-
public function setItems(array $items = null);
29+
public function setItems(array $items);
3030
}

app/code/Magento/Customer/Api/Data/CustomerSearchResultsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ public function getItems();
2626
* @param \Magento\Customer\Api\Data\CustomerInterface[] $items
2727
* @return $this
2828
*/
29-
public function setItems(array $items = null);
29+
public function setItems(array $items);
3030
}

0 commit comments

Comments
 (0)