Skip to content

Commit 6cd893c

Browse files
petrparolekPavel Janda
authored andcommitted
improvements
- upgrade PHPStan - fixed code reported by PHPStan - CS fix
1 parent 364cc37 commit 6cd893c

4 files changed

Lines changed: 37 additions & 27 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ csf:
1515
vendor/bin/codefixer src tests
1616

1717
phpstan:
18-
vendor/bin/phpstan analyse -l max -c phpstan.neon src
18+
vendor/bin/phpstan analyse -l 8 -c phpstan.neon src
1919

2020
tests:
2121
vendor/bin/tester -s -p php --colors 1 -C tests/cases

composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,19 @@
3434
},
3535
"require": {
3636
"php": ">=7.1",
37-
"nette/application": "^3.0",
37+
"nette/application": "^3.1",
3838
"nette/utils": "^3.0",
3939
"nette/di": "^3.0",
40-
"nette/http": "^3.0",
40+
"nette/http": "^3.1",
4141
"latte/latte": "^2.5"
4242
},
4343
"require-dev": {
4444
"ninjify/qa": "^0.12",
4545
"ninjify/nunjuck": "^0.4.0",
46-
"phpstan/phpstan": "^0.12.33",
47-
"phpstan/phpstan-nette": "^0.12.8",
46+
"phpstan/phpstan": "^1.0",
47+
"phpstan/phpstan-deprecation-rules": "^1.0",
48+
"phpstan/phpstan-nette": "^1.0",
49+
"phpstan/phpstan-strict-rules": "^1.0",
4850
"tracy/tracy": "^2.6"
4951
},
5052
"minimum-stability": "dev",

phpstan.neon

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1+
includes:
2+
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
3+
- vendor/phpstan/phpstan-nette/extension.neon
4+
- vendor/phpstan/phpstan-nette/rules.neon
5+
#- vendor/phpstan/phpstan-strict-rules/rules.neon
6+
17
parameters:
2-
paths:
3-
- src
4-
level: max
5-
ignoreErrors:
6-
-
7-
message: '~^Parameter #1 \$pattern of function preg_match expects string, string\|null given\.$~'
8-
path: '*/src/ImageNameScript.php'
9-
count: 1
10-
-
11-
message: '~^Parameter #1 \$pattern of function preg_match expects string, string\|null given\.$~'
12-
path: '*/src/ImageStorage.php'
13-
count: 1
14-
-
15-
message: '~^Right side of && is always true\.$~'
16-
path: '*/src/ImageStorage.php'
17-
count: 1
18-
-
19-
message: '~^Method Contributte\\ImageStorage\\ImageStorage::fromIdentifier\(\) should return Contributte\\ImageStorage\\Image but returns array<int, Contributte\\ImageStorage\\ImageNameScript\|string>\|Contributte\\ImageStorage\\Image\.$~'
20-
path: '*/src/ImageStorage.php'
21-
count: 1
8+
ignoreErrors:
9+
-
10+
message: '~^Parameter #1 \$pattern of function preg_match expects string, string\|null given\.$~'
11+
path: '*/src/ImageNameScript.php'
12+
count: 1
13+
-
14+
message: '~^Parameter #1 \$pattern of function preg_match expects string, string\|null given\.$~'
15+
path: '*/src/ImageStorage.php'
16+
count: 1
17+
-
18+
message: '~^Right side of && is always true\.$~'
19+
path: '*/src/ImageStorage.php'
20+
count: 1
21+
-
22+
message: '~^Method Contributte\\ImageStorage\\ImageStorage::fromIdentifier\(\) should return Contributte\\ImageStorage\\Image but returns array<int, Contributte\\ImageStorage\\ImageNameScript\|string>\|Contributte\\ImageStorage\\Image\.$~'
23+
path: '*/src/ImageStorage.php'
24+
count: 1
25+
26+
-
27+
message: '#Cannot use array destructuring on array<int, Contributte\\ImageStorage\\ImageNameScript|string>|Contributte\\ImageStorage\\Image.#'
28+
path: '*/src/ImageStorage.php'
29+
count: 2

src/ImageStorage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function saveUpload(FileUpload $upload, string $namespace, ?string $check
115115
}
116116

117117
[$path, $identifier] = $this->getSavePath(
118-
self::fixName($upload->getName()),
118+
self::fixName($upload->getUntrustedName()),
119119
$namespace,
120120
$checksum
121121
);
@@ -124,7 +124,7 @@ public function saveUpload(FileUpload $upload, string $namespace, ?string $check
124124

125125
return new Image($this->friendly_url, $this->data_dir, $this->data_path, $identifier, [
126126
'sha' => $checksum,
127-
'name' => self::fixName($upload->getName()),
127+
'name' => self::fixName($upload->getUntrustedName()),
128128
]);
129129
}
130130

0 commit comments

Comments
 (0)