diff --git a/composer.json b/composer.json index 85536f3..7032d10 100644 --- a/composer.json +++ b/composer.json @@ -28,15 +28,14 @@ "require-dev": { "nette/tester": "2.4.1", "mockery/mockery": "1.4.4", - "phpstan/phpstan": "0.12.99", - "phpstan/phpstan-strict-rules": "0.12.11", - "pepakriz/phpstan-exception-rules": "0.11.7", - "phpstan/phpstan-nette": "0.12.21", - "nepada/phpstan-nette-tester": "0.3.2", - "spaze/phpstan-disallowed-calls": "1.11.0", - "phpstan/phpstan-mockery": "0.12.14", + "phpstan/phpstan": "1.1.1", + "phpstan/phpstan-strict-rules": "1.0.0", + "phpstan/phpstan-nette": "1.0.0", + "nepada/phpstan-nette-tester": "0.4.0", + "spaze/phpstan-disallowed-calls": "2.0.0", + "phpstan/phpstan-mockery": "1.0.0", "php-parallel-lint/php-parallel-lint": "1.3.1", - "nepada/coding-standard": "7.4.0", + "nepada/coding-standard": "7.4.1", "nette/di": "^3.0.6@dev", "nette/schema": "^1.0.3@dev", "nette/bootstrap": ">=3.0@dev", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index b0c6219..38747c1 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,6 +1,5 @@ includes: - vendor/phpstan/phpstan-strict-rules/rules.neon - - vendor/pepakriz/phpstan-exception-rules/extension.neon - vendor/phpstan/phpstan-nette/extension.neon - vendor/phpstan/phpstan-nette/rules.neon - vendor/spaze/phpstan-disallowed-calls/extension.neon @@ -13,8 +12,12 @@ parameters: paths: - src - exceptionRules: - uncheckedExceptions: + exceptions: + implicitThrows: false + check: + missingCheckedExceptionInThrows: true + tooWideThrowType: true + uncheckedExceptionClasses: - LogicException - Nette\Application\AbortException - Nette\Application\UI\InvalidLinkException @@ -25,21 +28,12 @@ parameters: ignoreErrors: - - message: '~Missing @throws Exception annotation~' + message: "~Method Nepada\\\\FileUploadControl\\\\Utils\\\\NetteFileSystem::.* throws checked exception Exception but it's missing from the PHPDoc @throws tag~" path: src/FileUploadControl/Utils/NetteFileSystem.php - - - - message: "#^PHPDoc tag @throws with type Nette\\\\Application\\\\BadRequestException is not compatible with parent$#" - count: 2 - path: src/FileUploadControl/FileUploadControl.php - message: "#^Parameter \\#1 \\$value \\(bool\\) of method Nepada\\\\FileUploadControl\\\\FileUploadControl\\:\\:setDisabled\\(\\) should be contravariant with parameter \\$value \\(mixed\\) of method Nextras\\\\FormComponents\\\\Fragments\\\\UIControl\\\\BaseControl\\:\\:setDisabled\\(\\)$#" count: 1 path: src/FileUploadControl/FileUploadControl.php - - - message: "#^Variable property access on Nette\\\\Utils\\\\Html\\.$#" - count: 1 - path: src/FileUploadControl/FileUploadControl.php - message: "#^Parameter \\#1 \\$caption \\(Nette\\\\Utils\\\\Html\\|string\\|null\\) of method Nepada\\\\FileUploadControl\\\\FileUploadControl\\:\\:getLabel\\(\\) should be contravariant with parameter \\$caption \\(object\\|string(?:\\|null)?\\) of method Nextras\\\\FormComponents\\\\Fragments\\\\UIControl\\\\BaseControl\\:\\:getLabel\\(\\)$#" count: 1 @@ -48,10 +42,6 @@ parameters: message: "#^Parameter \\#2 \\$errorMessage \\(Nette\\\\Utils\\\\Html\\|string\\|null\\) of method Nepada\\\\FileUploadControl\\\\FileUploadControl\\:\\:addRule\\(\\) should be contravariant with parameter \\$errorMessage \\(object\\|string(?:\\|null)?\\) of method Nextras\\\\FormComponents\\\\Fragments\\\\UIControl\\\\BaseControl\\:\\:addRule\\(\\)$#" count: 1 path: src/FileUploadControl/FileUploadControl.php - - - message: "#^Throwable is never thrown in the corresponding try block$#" - count: 1 - path: src/FileUploadControl/FileUploadControl.php - message: "#^Parameter \\#1 \\$value \\(bool\\|Nette\\\\Utils\\\\Html\\|string\\) of method Nepada\\\\FileUploadControl\\\\FileUploadControl\\:\\:setRequired\\(\\) should be contravariant with parameter \\$value \\(bool\\|object\\|string\\) of method Nextras\\\\FormComponents\\\\Fragments\\\\UIControl\\\\BaseControl\\:\\:setRequired\\(\\)$#" count: 1 @@ -80,3 +70,31 @@ parameters: message: "#^Parameter \\#2 \\$validator \\(\\(callable\\(\\)\\: mixed\\)\\|string\\) of method Nepada\\\\FileUploadControl\\\\FileUploadControl\\:\\:addConditionOn\\(\\) should be contravariant with parameter \\$validator \\(mixed\\) of method Nextras\\\\FormComponents\\\\Fragments\\\\UIControl\\\\BaseControl\\:\\:addConditionOn\\(\\)$#" count: 1 path: src/FileUploadControl/FileUploadControl.php + - + message: "#^Cannot cast mixed to string\\.$#" + count: 1 + path: src/FileUploadControl/FileUploadControl.php + - + message: "#^Dead catch \\- Throwable is never thrown in the try block\\.$#" + count: 1 + path: src/FileUploadControl/FileUploadControl.php + - + message: "#^Parameter \\#2 \\$error of method Nepada\\\\FileUploadControl\\\\FileUploadControl\\:\\:createUploadErrorResponse\\(\\) expects string, mixed given\\.$#" + count: 2 + path: src/FileUploadControl/FileUploadControl.php + - + message: "#^Variable property access on Nette\\\\Utils\\\\Html\\.$#" + count: 1 + path: src/FileUploadControl/FileUploadControl.php + - + message: "#^Parameter \\#1 \\$data of static method Nepada\\\\FileUploadControl\\\\Storage\\\\Metadata\\\\FileUploadMetadata\\:\\:fromArray\\(\\) expects array, mixed given\\.$#" + count: 1 + path: src/FileUploadControl/Storage/Metadata/FileSystemMetadataJournal.php + - + message: "#^Parameter \\#1 \\$name of class Nepada\\\\FileUploadControl\\\\Storage\\\\Metadata\\\\FileUploadMetadata constructor expects string, mixed given\\.$#" + count: 1 + path: src/FileUploadControl/Storage/Metadata/FileUploadMetadata.php + - + message: "#^Parameter \\#2 \\$size of class Nepada\\\\FileUploadControl\\\\Storage\\\\Metadata\\\\FileUploadMetadata constructor expects int, mixed given\\.$#" + count: 1 + path: src/FileUploadControl/Storage/Metadata/FileUploadMetadata.php diff --git a/phpstan.tests.neon.dist b/phpstan.tests.neon.dist index c98aeeb..223b9d4 100644 --- a/phpstan.tests.neon.dist +++ b/phpstan.tests.neon.dist @@ -18,7 +18,7 @@ parameters: - php - phpt - excludes_analyse: + excludePaths: - tests/temp/* ignoreErrors: @@ -26,3 +26,11 @@ parameters: - # intended for test message: '~Call to an undefined method Nette\\Application\\UI\\Form::addFileUpload\(\)\.~' path: tests/Bridges/FileUploadControlDI/FileUploadControlExtensionTest.phpt + - + message: "#^Dead catch \\- Nette\\\\Application\\\\AbortException is never thrown in the try block\\.$#" + count: 1 + path: tests/FileUploadControl/FileUploadControlTest.phpt + - + message: "#^Cannot cast mixed to string\\.$#" + count: 1 + path: tests/FileUploadControl/Fixtures/DummyTranslator.php diff --git a/src/FileUploadControl/FileUploadControl.php b/src/FileUploadControl/FileUploadControl.php index dba69cd..85f83ed 100644 --- a/src/FileUploadControl/FileUploadControl.php +++ b/src/FileUploadControl/FileUploadControl.php @@ -487,7 +487,7 @@ protected function parseFileUploadId(string $value): FileUploadId protected function getFileUploadChunks(): array { $httpRequest = $this->getHttpRequest(); - /** @var FileUpload[] $files */ + /** @var array $files */ $files = Nette\Forms\Helpers::extractHttpData($httpRequest->getFiles(), $this->getUploadControl()->getHtmlName() . '[]', Form::DATA_FILE); if (count($files) === 0) { return []; diff --git a/tests/FileUploadControl/FileUploadControlValidationTest.phpt b/tests/FileUploadControl/FileUploadControlValidationTest.phpt index 45a035f..d7d74a6 100644 --- a/tests/FileUploadControl/FileUploadControlValidationTest.phpt +++ b/tests/FileUploadControl/FileUploadControlValidationTest.phpt @@ -235,6 +235,10 @@ class FileUploadControlValidationTest extends TestCase return new FileUploadControl($storageManager, 'Test control'); } + /** + * @param string $file + * @param int<0, max> $size + */ private function readChunk(string $file, int $size): string { $fp = fopen($file, 'r');