Skip to content

Commit a6e5876

Browse files
committed
Merge branch 'v1-develop' into v1
2 parents bfdc12f + 1841b28 commit a6e5876

File tree

24 files changed

+4123
-3797
lines changed

24 files changed

+4123
-3797
lines changed

Block/Adminhtml/Metadata.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class Metadata extends Template
1313
{
1414
private $metaStorage;
1515

16+
/**
17+
* @param array<mixed> $data
18+
*/
1619
public function __construct(
1720
BackendBlockContext $context,
1821
MetaStorage $metaStorage,
@@ -23,6 +26,9 @@ public function __construct(
2326
$this->metaStorage = $metaStorage;
2427
}
2528

29+
/**
30+
* @return array<string, mixed>
31+
*/
2632
public function getMetadata()
2733
{
2834
$storageIdentifier = $this->getStorageIdentifier();
@@ -36,6 +42,11 @@ public function getMetadata()
3642
return $metaData;
3743
}
3844

45+
/**
46+
* @param array<string, mixed> $metaData
47+
*
48+
* @return array<string, mixed>
49+
*/
3950
private function format(array $metaData): array
4051
{
4152
$formatted = [];

Checker/Catalog/Category/UrlPath.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class UrlPath
2626
private $categoryCollectionFactory;
2727
private $attributeScopeOverriddenValueFactory;
2828

29+
/** @var array<string, string> */
2930
private $calculatedUrlPathPerCategoryAndStoreId;
3031

3132
public function __construct(
@@ -38,13 +39,19 @@ public function __construct(
3839
$this->attributeScopeOverriddenValueFactory = $attributeScopeOverriddenValueFactory;
3940
}
4041

42+
/**
43+
* @return array<array<string, mixed>>
44+
*/
4145
public function execute(): array
4246
{
4347
$categoryData = $this->checkForIncorrectUrlPathAttributeValues();
4448

4549
return $categoryData;
4650
}
4751

52+
/**
53+
* @return array<array<string, mixed>>
54+
*/
4855
public function checkForIncorrectUrlPathAttributeValues(): array
4956
{
5057
$problems = [];
@@ -81,7 +88,10 @@ public function checkForIncorrectUrlPathAttributeValues(): array
8188
return $problems;
8289
}
8390

84-
private function getAllVisibleCategoriesWithStoreId($storeId): CategoryCollection
91+
/**
92+
* @return CategoryCollection<Category>
93+
*/
94+
private function getAllVisibleCategoriesWithStoreId(int $storeId): CategoryCollection
8595
{
8696
$categories = $this->categoryCollectionFactory->create()
8797
->addAttributeToSelect('name')
@@ -132,9 +142,9 @@ private function fetchAllCategoriesWithUrlPathCalculatedByUrlKey()
132142
foreach ($allCategories as $category) {
133143
$categoryId = (int) $category->getId();
134144

135-
$path = $category->getPath();
145+
$path = $category->getPath() ?: '';
136146
foreach ($invisibleRootIds as $rootId) {
137-
$path = preg_replace('#^' . preg_quote($rootId) . self::URL_PATH_SEPARATOR . '#', '', $path);
147+
$path = preg_replace('#^' . preg_quote($rootId) . self::URL_PATH_SEPARATOR . '#', '', $path) ?: '';
138148
}
139149

140150
$tempCatData[$categoryId] = [
@@ -164,6 +174,9 @@ private function fetchAllCategoriesWithUrlPathCalculatedByUrlKey()
164174
}
165175
}
166176

177+
/**
178+
* @return array<string>
179+
*/
167180
private function getAllInvisibleRootIds(): array
168181
{
169182
$categoryIds = $this->categoryCollectionFactory->create()

Checker/Catalog/Product/UrlKey.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public function __construct(
2727
$this->progress = $progress;
2828
}
2929

30+
/**
31+
* @return array<array<string, mixed>>
32+
*/
3033
public function execute(): array
3134
{
3235
$productData = array_merge(

Checker/Catalog/Product/UrlKey/DuplicateUrlKey.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Baldwin\UrlDataIntegrityChecker\Util\Stores as StoresUtil;
1010
use Magento\Catalog\Api\Data\ProductInterface;
1111
use Magento\Catalog\Model\Attribute\ScopeOverriddenValueFactory as AttributeScopeOverriddenValueFactory;
12+
use Magento\Catalog\Model\Product as ProductModel;
1213
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
1314
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
1415
use Magento\Store\Model\Store;
@@ -37,8 +38,15 @@ public function __construct(
3738
$this->progress = $progress;
3839
$this->productCollectionFactory = $productCollectionFactory;
3940
$this->attributeScopeOverriddenValueFactory = $attributeScopeOverriddenValueFactory;
41+
42+
$this->progressIndex = 0;
43+
$this->cachedProductUrlKeyData = [];
44+
$this->cachedProductSkusByIds = [];
4045
}
4146

47+
/**
48+
* @return array<array<string, mixed>>
49+
*/
4250
public function execute(): array
4351
{
4452
$this->cachedProductUrlKeyData = [];
@@ -49,6 +57,9 @@ public function execute(): array
4957
return $productData;
5058
}
5159

60+
/**
61+
* @return array<array<string, mixed>>
62+
*/
5263
private function checkForDuplicatedUrlKeyAttributeValues(): array
5364
{
5465
$this->progress->initProgressBar(
@@ -95,6 +106,9 @@ private function checkForDuplicatedUrlKeyAttributeValues(): array
95106
return $productsWithProblems;
96107
}
97108

109+
/**
110+
* @param ProductCollection<ProductModel> $collection
111+
*/
98112
private function storeProductUrlKeyData(int $storeId, ProductCollection $collection)
99113
{
100114
foreach ($collection as $product) {
@@ -121,6 +135,9 @@ private function storeProductUrlKeyData(int $storeId, ProductCollection $collect
121135
}
122136
}
123137

138+
/**
139+
* @return array<array<string, mixed>>
140+
*/
124141
private function getProductsWithDuplicatedUrlKeyProblems(): array
125142
{
126143
$problems = [];

Checker/Catalog/Product/UrlKey/EmptyUrlKey.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Baldwin\UrlDataIntegrityChecker\Util\Stores as StoresUtil;
1010
use Magento\Catalog\Api\Data\ProductInterface;
1111
use Magento\Catalog\Model\Attribute\ScopeOverriddenValueFactory as AttributeScopeOverriddenValueFactory;
12+
use Magento\Catalog\Model\Product as ProductModel;
1213
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
1314
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
1415
use Magento\Store\Model\Store;
@@ -33,15 +34,23 @@ public function __construct(
3334
$this->progress = $progress;
3435
$this->productCollectionFactory = $productCollectionFactory;
3536
$this->attributeScopeOverriddenValueFactory = $attributeScopeOverriddenValueFactory;
37+
38+
$this->progressIndex = 0;
3639
}
3740

41+
/**
42+
* @return array<array<string, mixed>>
43+
*/
3844
public function execute(): array
3945
{
4046
$productData = $this->checkForEmptyUrlKeyAttributeValues();
4147

4248
return $productData;
4349
}
4450

51+
/**
52+
* @return array<array<string, mixed>>
53+
*/
4554
private function checkForEmptyUrlKeyAttributeValues(): array
4655
{
4756
$productsWithProblems = [];
@@ -96,6 +105,11 @@ private function checkForEmptyUrlKeyAttributeValues(): array
96105
return $productsWithProblems;
97106
}
98107

108+
/**
109+
* @param ProductCollection<ProductModel> $collection
110+
*
111+
* @return array<array<string, mixed>>
112+
*/
99113
private function getProductsWithProblems(int $storeId, ProductCollection $collection): array
100114
{
101115
$problems = [];

Checker/Catalog/Product/UrlPath.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Baldwin\UrlDataIntegrityChecker\Util\Stores as StoresUtil;
88
use Magento\Catalog\Api\Data\ProductInterface;
99
use Magento\Catalog\Model\Attribute\ScopeOverriddenValueFactory as AttributeScopeOverriddenValueFactory;
10+
use Magento\Catalog\Model\Product as ProductModel;
1011
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
1112
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
1213
use Magento\Store\Model\Store;
@@ -33,13 +34,19 @@ public function __construct(
3334
$this->attributeScopeOverriddenValueFactory = $attributeScopeOverriddenValueFactory;
3435
}
3536

37+
/**
38+
* @return array<array<string, mixed>>
39+
*/
3640
public function execute(): array
3741
{
3842
$productData = $this->checkForNonEmptyUrlPathAttributeValues();
3943

4044
return $productData;
4145
}
4246

47+
/**
48+
* @return array<array<string, mixed>>
49+
*/
4350
private function checkForNonEmptyUrlPathAttributeValues(): array
4451
{
4552
$productsWithProblems = [];
@@ -67,6 +74,11 @@ private function checkForNonEmptyUrlPathAttributeValues(): array
6774
return $productsWithProblems;
6875
}
6976

77+
/**
78+
* @param ProductCollection<ProductModel> $collection
79+
*
80+
* @return array<array<string, mixed>>
81+
*/
7082
private function getProductsWithProblems(int $storeId, ProductCollection $collection): array
7183
{
7284
$problems = [];

Console/CategoryResultOutput.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
class CategoryResultOutput
1212
{
13+
/**
14+
* @param array<array<string, mixed>> $categoryData
15+
*/
1316
public function outputResult(array $categoryData, OutputInterface $output): int
1417
{
1518
if (empty($categoryData)) {

Console/ProductResultOutput.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
class ProductResultOutput
1212
{
13+
/**
14+
* @param array<array<string, mixed>> $productData
15+
*/
1316
public function outputResult(array $productData, OutputInterface $output): int
1417
{
1518
if (empty($productData)) {

Console/Progress.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@
99

1010
class Progress
1111
{
12+
/** @var ProgressBar */
1213
private $progressBar;
14+
15+
/** @var OutputInterface */
1316
private $output;
17+
1418
private $sizeByIndex;
1519
private $format;
1620

21+
public function __construct()
22+
{
23+
$this->sizeByIndex = [];
24+
$this->format = '';
25+
}
26+
1727
public function setOutput(OutputInterface $output)
1828
{
1929
$this->output = $output;
@@ -60,6 +70,10 @@ public function setMessage(string $message)
6070
}
6171
}
6272

73+
/**
74+
* @psalm-suppress ReservedWord
75+
* When we remove PHP 7.0 support from the composer.json file, we can remove this suppress line
76+
*/
6377
public function finish()
6478
{
6579
if ($this->canOutput()) {
@@ -75,7 +89,7 @@ private function canOutput(): bool
7589
private function updateMaxSteps()
7690
{
7791
if ($this->canOutput()) {
78-
$newMaxStepsValue = array_sum($this->sizeByIndex);
92+
$newMaxStepsValue = (int) array_sum($this->sizeByIndex);
7993

8094
// ugly solution for the fact that the setMaxSteps method only became
8195
// publicly accesible in symfony/console > 4.1.0

Cron/ScheduleJob.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Baldwin\UrlDataIntegrityChecker\Cron;
66

77
use Magento\Cron\Model\ResourceModel\Schedule\Collection as CronScheduleCollection;
8-
use Magento\Cron\Model\Schedule;
8+
use Magento\Cron\Model\Schedule as CronScheduleModel;
99
use Magento\Framework\App\ProductMetadataInterface;
1010
use Magento\Framework\Stdlib\DateTime\DateTime;
1111
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
@@ -17,6 +17,9 @@ class ScheduleJob
1717
private $timezone;
1818
private $cronScheduleCollection;
1919

20+
/**
21+
* @param CronScheduleCollection<CronScheduleModel> $cronScheduleCollection
22+
*/
2023
public function __construct(
2124
ProductMetadataInterface $productMetadata,
2225
DateTime $dateTime,
@@ -34,10 +37,11 @@ public function schedule(string $jobCode): bool
3437
$createdAtTime = $this->getCronTimestamp();
3538
$scheduledAtTime = $createdAtTime + (60 - ($createdAtTime % 60)); // set scheduledAtTime to next minute
3639

40+
/** @var CronScheduleModel */
3741
$schedule = $this->cronScheduleCollection->getNewEmptyItem();
3842
$schedule
3943
->setJobCode($jobCode)
40-
->setStatus(Schedule::STATUS_PENDING)
44+
->setStatus(CronScheduleModel::STATUS_PENDING)
4145
->setCreatedAt(strftime('%Y-%m-%d %H:%M:%S', $createdAtTime))
4246
->setScheduledAt(strftime('%Y-%m-%d %H:%M', $scheduledAtTime))
4347
->save();

0 commit comments

Comments
 (0)