Skip to content

Commit 186f63c

Browse files
committed
Update phpstan to ^2.1
Signed-off-by: Anton Fedurtsya <[email protected]>
1 parent e48c815 commit 186f63c

15 files changed

+42
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313
- Notices if sitemap directory does not exist
1414

1515
### Removed
16-
- PHP 8.1 support
16+
- PHP 8.0 support
1717

1818
## [v1.0.3] - Unreleased
1919

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
"minimum-stability": "dev",
1212
"prefer-stable": true,
1313
"require": {
14-
"php": ">8.2",
14+
"php": ">8.1",
1515
"oxid-esales/oxideshop-ce": "*"
1616
},
1717
"conflict": {
1818
"oxid-esales/oxideshop-ce": "<7.1.0"
1919
},
2020
"require-dev": {
2121
"phpunit/phpunit": "^11.5",
22-
"phpstan/phpstan": "^1.8.10",
22+
"phpstan/phpstan": "^2.1",
2323
"squizlabs/php_codesniffer": "3.*",
2424
"phpmd/phpmd": "^2.11",
2525
"mikey179/vfsstream": "~1.6.8",

src/ChangeFilter/Additional/AdditionalChangeFilter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public function getDisabledUrlIds(): array
7474
return $idsForRemoval;
7575
}
7676

77+
/**
78+
* @return array<string, string>
79+
*/
7780
protected function getAdditionalSitemapUrlKeys(): array
7881
{
7982
$additionalUrlsList = $this->moduleSettings->getAdditionalSitemapUrls();

src/ChangeFilter/Shared/DatabaseChangeFilter.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ public function __construct(
3333
$this->connection = $connectionProvider->get();
3434
}
3535

36+
/**
37+
* @param array<string, string|int|bool|null> $queryParameters
38+
*
39+
* @return Generator<ObjectUrl>
40+
*/
3641
public function queryAndFetchModelObjectUrl(string $query, array $queryParameters): Generator
3742
{
38-
/** @var Result $result */
3943
$result = $this->connection->executeQuery(
4044
$query,
4145
$queryParameters
@@ -58,6 +62,9 @@ public function queryAndFetchModelObjectUrl(string $query, array $queryParameter
5862
}
5963
}
6064

65+
/**
66+
* @return array<string, string|int|bool|null>
67+
*/
6168
protected function getQueryParameters(): array
6269
{
6370
return [
@@ -90,14 +97,18 @@ protected function getDisabledSitemapItemsSql(string $objectType, string $table)
9097
where s.object_type='{$objectType}' AND c.oxid is NULL";
9198
}
9299

100+
/**
101+
* @return array<int>
102+
*/
93103
protected function queryAndFetchDisabledSitemapObjectUrlIds(string $objectType, string $modelTable): array
94104
{
95-
/** @var Result $result */
96105
$result = $this->connection->executeQuery(
97106
$this->getDisabledSitemapItemsSql($objectType, $modelTable),
98107
$this->getQueryParameters()
99108
);
100109

101-
return $result->fetchFirstColumn();
110+
/** @var array<int> $ids */
111+
$ids = $result->fetchFirstColumn();
112+
return $ids;
102113
}
103114
}

src/Events.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ final class Events
2222
{
2323
/**
2424
* Execute action on activate event
25-
*
26-
* @throws Exception
2725
*/
2826
public static function onActivate(): void
2927
{
@@ -33,8 +31,6 @@ public static function onActivate(): void
3331

3432
/**
3533
* Execute action on deactivate event
36-
*
37-
* @throws Exception
3834
*/
3935
public static function onDeactivate(): void
4036
{

src/Integration/Command/UpdateAllTypesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(
2626
}
2727

2828
/**
29-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
29+
* @SuppressWarnings(PHPMD)
3030
*/
3131
protected function execute(InputInterface $input, OutputInterface $output): int
3232
{

src/Integration/Service/FilterFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515

1616
class FilterFactory implements FilterFactoryInterface
1717
{
18+
/** @var array<ChangeFilterInterface> */
1819
private array $filters = [];
1920

2021
/**
21-
* @param iterable<\FreshAdvance\Sitemap\Integration\Contract\ChangeFilterInterface> $filters
22+
* @param iterable<ChangeFilterInterface|object> $filters
2223
*/
2324
public function __construct(
2425
iterable $filters

src/Integration/Service/FilterFactoryInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ interface FilterFactoryInterface
1313
{
1414
public function getFilter(string $objectType): ChangeFilterInterface;
1515

16+
/**
17+
* @return array<ChangeFilterInterface>
18+
*/
1619
public function getFilters(): array;
1720
}

src/Settings/ModuleSettings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getSitemapInSourceDirectory(): string
3434

3535
public function getAdditionalSitemapUrls(): array
3636
{
37-
return $this->shopModuleSettings->getCollection(
37+
return $this->shopModuleSettings->getCollection( // @phpstan-ignore return.type
3838
self::SETTING_ADDITIONAL_SITEMAP_URLS,
3939
Module::MODULE_ID
4040
);

src/Settings/ModuleSettingsInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ interface ModuleSettingsInterface
1111
{
1212
public function getSitemapInSourceDirectory(): string;
1313

14+
/**
15+
* @return array<string>
16+
*/
1417
public function getAdditionalSitemapUrls(): array;
1518
}

src/Sitemap/Command/GenerateSitemapCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(
2323
}
2424

2525
/**
26-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
26+
* @SuppressWarnings(PHPMD)
2727
*/
2828
protected function execute(InputInterface $input, OutputInterface $output): int
2929
{

src/Sitemap/Service/XmlGenerator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public function generateSitemapItem(SitemapUrlInterface $url): string
3737
return $this->wrap(implode("", $attributes), "sitemap");
3838
}
3939

40+
/**
41+
* @param array<string,string> $tagAttributes
42+
*/
4043
protected function wrap(string $data, string $tag, array $tagAttributes = []): string
4144
{
4245
$attributes = '';

src/Url/DataTypeFactory/UrlTypeFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414

1515
class UrlTypeFactory implements UrlTypeFactoryInterface
1616
{
17+
/** @var array<UrlTypeInterface> $configurations */
1718
protected array $configurations = [];
1819

1920
/**
20-
* @param iterable<UrlTypeInterface> $configurations
21+
* @param iterable<UrlTypeInterface|object> $configurations
2122
* @throws \FreshAdvance\Sitemap\Url\Exception\UrlTypeFactorySetupException
2223
*/
2324
public function __construct(

src/Url/Repository/UrlRepositoryInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ public function getUrls(int $page, int $perPage): iterable;
2323

2424
public function getUrlsCount(): int;
2525

26+
/**
27+
* @param array<int> $ids
28+
*/
2629
public function deleteByIds(array $ids): void;
2730
}

tests/PhpStan/phpstan.neon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
parameters:
2-
checkMissingIterableValueType: false
2+
phpVersion:
3+
min: 80100
4+
max: 80400
35
bootstrapFiles:
46
- phpstan-bootstrap.php
57
level: max

0 commit comments

Comments
 (0)