Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
- upgrade PHPStan
- fixed code reported by PHPStan
- CS fix
  • Loading branch information
petrparolek authored and Pavel Janda committed Dec 22, 2021
1 parent 364cc37 commit 6cd893c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -15,7 +15,7 @@ csf:
vendor/bin/codefixer src tests

phpstan:
vendor/bin/phpstan analyse -l max -c phpstan.neon src
vendor/bin/phpstan analyse -l 8 -c phpstan.neon src

tests:
vendor/bin/tester -s -p php --colors 1 -C tests/cases
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Expand Up @@ -34,17 +34,19 @@
},
"require": {
"php": ">=7.1",
"nette/application": "^3.0",
"nette/application": "^3.1",
"nette/utils": "^3.0",
"nette/di": "^3.0",
"nette/http": "^3.0",
"nette/http": "^3.1",
"latte/latte": "^2.5"
},
"require-dev": {
"ninjify/qa": "^0.12",
"ninjify/nunjuck": "^0.4.0",
"phpstan/phpstan": "^0.12.33",
"phpstan/phpstan-nette": "^0.12.8",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-nette": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"tracy/tracy": "^2.6"
},
"minimum-stability": "dev",
Expand Down
48 changes: 28 additions & 20 deletions phpstan.neon
@@ -1,21 +1,29 @@
includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-nette/extension.neon
- vendor/phpstan/phpstan-nette/rules.neon
#- vendor/phpstan/phpstan-strict-rules/rules.neon

parameters:
paths:
- src
level: max
ignoreErrors:
-
message: '~^Parameter #1 \$pattern of function preg_match expects string, string\|null given\.$~'
path: '*/src/ImageNameScript.php'
count: 1
-
message: '~^Parameter #1 \$pattern of function preg_match expects string, string\|null given\.$~'
path: '*/src/ImageStorage.php'
count: 1
-
message: '~^Right side of && is always true\.$~'
path: '*/src/ImageStorage.php'
count: 1
-
message: '~^Method Contributte\\ImageStorage\\ImageStorage::fromIdentifier\(\) should return Contributte\\ImageStorage\\Image but returns array<int, Contributte\\ImageStorage\\ImageNameScript\|string>\|Contributte\\ImageStorage\\Image\.$~'
path: '*/src/ImageStorage.php'
count: 1
ignoreErrors:
-
message: '~^Parameter #1 \$pattern of function preg_match expects string, string\|null given\.$~'
path: '*/src/ImageNameScript.php'
count: 1
-
message: '~^Parameter #1 \$pattern of function preg_match expects string, string\|null given\.$~'
path: '*/src/ImageStorage.php'
count: 1
-
message: '~^Right side of && is always true\.$~'
path: '*/src/ImageStorage.php'
count: 1
-
message: '~^Method Contributte\\ImageStorage\\ImageStorage::fromIdentifier\(\) should return Contributte\\ImageStorage\\Image but returns array<int, Contributte\\ImageStorage\\ImageNameScript\|string>\|Contributte\\ImageStorage\\Image\.$~'
path: '*/src/ImageStorage.php'
count: 1

-
message: '#Cannot use array destructuring on array<int, Contributte\\ImageStorage\\ImageNameScript|string>|Contributte\\ImageStorage\\Image.#'
path: '*/src/ImageStorage.php'
count: 2
4 changes: 2 additions & 2 deletions src/ImageStorage.php
Expand Up @@ -115,7 +115,7 @@ public function saveUpload(FileUpload $upload, string $namespace, ?string $check
}

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

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

Expand Down

0 comments on commit 6cd893c

Please sign in to comment.