Skip to content

Commit a2c747e

Browse files
committed
Move to PHPStan 2
1 parent ff29438 commit a2c747e

File tree

9 files changed

+95
-50
lines changed

9 files changed

+95
-50
lines changed

.gitattributes

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
/.gitattributes export-ignore
2-
/.gitignore export-ignore
3-
/.php-auto-version export-ignore
4-
/.php-cs-fixer.php export-ignore
5-
/composer.lock export-ignore
6-
/Makefile export-ignore
7-
/phpstan.neon export-ignore
8-
/Test export-ignore
9-
/vendor-bin export-ignore
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore
3+
/.php-auto-version export-ignore
4+
/.php-cs-fixer.php export-ignore
5+
/composer.lock export-ignore
6+
/Makefile export-ignore
7+
/phpstan-baseline.neon export-ignore
8+
/phpstan.neon export-ignore
9+
/Test export-ignore
10+
/vendor-bin export-ignore

Block/Adminhtml/Metadata.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function getMetadata()
3535
if ($storageIdentifier === null || $storageIdentifier === '') {
3636
throw new MissingConfigurationException(__('No storage identifier was setup for this block!'));
3737
}
38+
assert(is_string($storageIdentifier));
3839

3940
$metaData = $this->metaStorage->getData($storageIdentifier);
4041
$metaData = $this->format($metaData);

Checker/Catalog/Category/UrlPath.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function checkForIncorrectUrlPathAttributeValues(): array
7070
$correctUrlPath = $this->getCalculatedUrlPathForCategory($category, $storeId);
7171

7272
assert(is_numeric($category->getId()));
73+
assert(is_string($category->getUrlPath()));
7374

7475
$problems[] = [
7576
'catId' => (int) $category->getId(),

Checker/Catalog/Product/UrlKey/DuplicateUrlKey.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ private function storeProductUrlKeyData(int $storeId, ProductCollection $collect
122122
{
123123
foreach ($collection as $product) {
124124
assert(is_numeric($product->getEntityId()));
125+
assert(is_string($product->getUrlKey()));
125126

126127
$productId = $product->getEntityId();
127128
$productSku = $product->getSku();

Storage/StorageInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
interface StorageInterface
88
{
99
/**
10-
* @param array<string, mixed> $data
10+
* @param array<string, mixed>|array<array<string, mixed>> $data
1111
*/
1212
public function write(string $identifier, array $data): bool;
1313

1414
/**
15-
* @return array<string, mixed>
15+
* @return array<string, mixed>|array<array<string, mixed>>
1616
*/
1717
public function read(string $identifier): array;
1818

phpstan-baseline.neon

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Method Baldwin\\UrlDataIntegrityChecker\\Checker\\Catalog\\Category\\UrlPath\:\:getAllInvisibleRootIds\(\) should return array\<string\> but returns array\.$#'
5+
identifier: return.type
6+
count: 1
7+
path: Checker/Catalog/Category/UrlPath.php
8+
9+
-
10+
message: '#^Parameter \#1 \$arguments of method Baldwin\\UrlDataIntegrityChecker\\Model\\ResourceModel\\Catalog\\Category\\UrlKeyCollection\:\:createDataObject\(\) expects array\<string, mixed\>, array\<mixed, mixed\> given\.$#'
11+
identifier: argument.type
12+
count: 1
13+
path: Model/ResourceModel/Catalog/Category/UrlKeyCollection.php
14+
15+
-
16+
message: '#^Parameter \#1 \$arguments of method Baldwin\\UrlDataIntegrityChecker\\Model\\ResourceModel\\Catalog\\Category\\UrlPathCollection\:\:createDataObject\(\) expects array\<string, mixed\>, array\<mixed, mixed\> given\.$#'
17+
identifier: argument.type
18+
count: 1
19+
path: Model/ResourceModel/Catalog/Category/UrlPathCollection.php
20+
21+
-
22+
message: '#^Parameter \#1 \$arguments of method Baldwin\\UrlDataIntegrityChecker\\Model\\ResourceModel\\Catalog\\Product\\UrlKeyCollection\:\:createDataObject\(\) expects array\<string, mixed\>, array\<mixed, mixed\> given\.$#'
23+
identifier: argument.type
24+
count: 1
25+
path: Model/ResourceModel/Catalog/Product/UrlKeyCollection.php
26+
27+
-
28+
message: '#^Parameter \#1 \$arguments of method Baldwin\\UrlDataIntegrityChecker\\Model\\ResourceModel\\Catalog\\Product\\UrlPathCollection\:\:createDataObject\(\) expects array\<string, mixed\>, array\<mixed, mixed\> given\.$#'
29+
identifier: argument.type
30+
count: 1
31+
path: Model/ResourceModel/Catalog/Product/UrlPathCollection.php
32+
33+
-
34+
message: '#^Method Baldwin\\UrlDataIntegrityChecker\\Storage\\Meta\:\:getData\(\) should return array\<string, mixed\> but returns array\<mixed\>\.$#'
35+
identifier: return.type
36+
count: 1
37+
path: Storage/Meta.php

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
14
parameters:
25
level: max
36
inferPrivatePropertyTypeFromConstructor: true
47
checkDynamicProperties: true
8+
treatPhpDocTypesAsCertain: false
59
paths:
610
- .
711
excludePaths:

vendor-bin/phpstan/composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"require": {
3-
"bitexpert/phpstan-magento": "^0.32.0",
3+
"bitexpert/phpstan-magento": "^0.40.0",
44
"phpstan/extension-installer": "^1.0",
5-
"phpstan/phpstan": "^1.8",
6-
"phpstan/phpstan-deprecation-rules": "^1.0"
5+
"phpstan/phpstan": "^2.1",
6+
"phpstan/phpstan-deprecation-rules": "^2.0"
77
},
88
"config": {
99
"allow-plugins": {

vendor-bin/phpstan/composer.lock

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)