Skip to content

Commit 6d1be4e

Browse files
committed
MAGE-827 Add types for landing page validation on PHP connector v4
1 parent bb55772 commit 6d1be4e

File tree

4 files changed

+38
-15
lines changed

4 files changed

+38
-15
lines changed

Controller/Adminhtml/Landingpage/Delete.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Algolia\AlgoliaSearch\Controller\Adminhtml\Landingpage;
44

5+
use Algolia\AlgoliaSearch\Model\LandingPage;
56
use Magento\Framework\Controller\ResultFactory;
67

78
class Delete extends AbstractAction
@@ -15,7 +16,7 @@ public function execute()
1516
$landingPageId = $this->getRequest()->getParam('id');
1617
if ($landingPageId) {
1718
try {
18-
/** @var \Algolia\AlgoliaSearch\Model\LandingPage $landingPage */
19+
/** @var LandingPage $landingPage */
1920
$landingPage = $this->landingPageFactory->create();
2021
$landingPage->getResource()->load($landingPage, $landingPageId);
2122
$landingPage->getResource()->delete($landingPage);
@@ -35,7 +36,12 @@ public function execute()
3536
return $resultRedirect->setPath('*/*/');
3637
}
3738

38-
private function deleteQueryRules($landingPage)
39+
/**
40+
* @param LandingPage $landingPage
41+
* @return void
42+
* @throws \Magento\Framework\Exception\NoSuchEntityException
43+
*/
44+
private function deleteQueryRules(LandingPage $landingPage): void
3945
{
4046
$stores = [];
4147
if ($landingPage->getStoreId() == 0) {

Controller/Adminhtml/Landingpage/Duplicate.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Algolia\AlgoliaSearch\Controller\Adminhtml\Landingpage;
44

5+
use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;
6+
use Algolia\AlgoliaSearch\Model\LandingPage;
57
use Magento\Framework\Controller\ResultFactory;
68
use Magento\Framework\Exception\LocalizedException;
79

@@ -20,7 +22,7 @@ public function execute()
2022
return $resultRedirect->setPath('*/*/');
2123
}
2224

23-
/** @var \Algolia\AlgoliaSearch\Model\LandingPage $landingPage */
25+
/** @var LandingPage $landingPage */
2426
$landingPage = $this->landingPageFactory->create();
2527
$landingPage->getResource()->load($landingPage, $landingPageId);
2628

@@ -53,9 +55,13 @@ public function execute()
5355
return $resultRedirect->setPath('*/*/');
5456
}
5557

56-
private function duplicateLandingPage($landingPage)
58+
/**
59+
* @param LandingPage $landingPage
60+
* @return LandingPage
61+
*/
62+
private function duplicateLandingPage(LandingPage $landingPage): LandingPage
5763
{
58-
/** @var \Algolia\AlgoliaSearch\Model\LandingPage $newLandingPage */
64+
/** @var LandingPage $newLandingPage */
5965
$newLandingPage = $this->landingPageFactory->create();
6066
$newLandingPage->setData($landingPage->getData());
6167
$newLandingPage->setId(null);
@@ -65,7 +71,13 @@ private function duplicateLandingPage($landingPage)
6571
return $newLandingPage;
6672
}
6773

68-
private function copyQueryRules($landingPageFromId, $landingPageToId)
74+
/**
75+
* @param int $landingPageFromId
76+
* @param int $landingPageToId
77+
* @return void
78+
* @throws AlgoliaException|\Magento\Framework\Exception\NoSuchEntityException
79+
*/
80+
private function copyQueryRules(int $landingPageFromId, int $landingPageToId): void
6981
{
7082
$stores = [];
7183
if ($landingPageFromId) {

Controller/Adminhtml/Landingpage/Save.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,12 @@ public function execute()
154154
}
155155

156156
/**
157-
* @param $landingPageId
158-
* @param $data
157+
* @param int $landingPageId
158+
* @param array<string, mixed> $data
159159
* @return void
160+
* @throws \Magento\Framework\Exception\NoSuchEntityException
160161
*/
161-
protected function manageQueryRules($landingPageId, $data)
162+
protected function manageQueryRules(int $landingPageId, array $data): void
162163
{
163164
$positions = json_decode($data['algolia_merchandising_positions'], true);
164165
$stores = [];

Helper/MerchandisingHelper.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ public function deleteQueryRule(int $storeId, int $entityId, string $entityType)
109109
$this->algoliaHelper->deleteRule($productsIndexName, $ruleId);
110110
}
111111

112-
private function transformPositions($positions)
112+
/**
113+
* @param array $positions
114+
* @return array
115+
*/
116+
private function transformPositions(array $positions): array
113117
{
114118
$transformedPositions = [];
115119

@@ -125,13 +129,13 @@ private function transformPositions($positions)
125129

126130
/**
127131
* @param int $storeId
128-
* @param $entityIdFrom
129-
* @param $entityIdTo
130-
* @param $entityType
131-
*
132+
* @param int $entityIdFrom
133+
* @param int $entityIdTo
134+
* @param string $entityType
135+
* @return void
132136
* @throws AlgoliaException|\Magento\Framework\Exception\NoSuchEntityException
133137
*/
134-
public function copyQueryRules(int $storeId, $entityIdFrom, $entityIdTo, $entityType): void
138+
public function copyQueryRules(int $storeId, int $entityIdFrom, int $entityIdTo, string $entityType): void
135139
{
136140
$productsIndexName = $this->coreHelper->getIndexName($this->productHelper->getIndexNameSuffix(), $storeId);
137141
$client = $this->algoliaHelper->getClient();

0 commit comments

Comments
 (0)