Skip to content

Commit

Permalink
Update phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurk committed Nov 7, 2021
1 parent e2a1ced commit 1442eab
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 27 deletions.
15 changes: 7 additions & 8 deletions composer.json
Expand Up @@ -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",
Expand Down
52 changes: 35 additions & 17 deletions 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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
10 changes: 9 additions & 1 deletion phpstan.tests.neon.dist
Expand Up @@ -18,11 +18,19 @@ parameters:
- php
- phpt

excludes_analyse:
excludePaths:
- tests/temp/*

ignoreErrors:
- '~Call to static method Tester\\Assert::(type|count|same|notSame)\(\) with .* and .* will always evaluate to true\.~'
- # 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
2 changes: 1 addition & 1 deletion src/FileUploadControl/FileUploadControl.php
Expand Up @@ -487,7 +487,7 @@ protected function parseFileUploadId(string $value): FileUploadId
protected function getFileUploadChunks(): array
{
$httpRequest = $this->getHttpRequest();
/** @var FileUpload[] $files */
/** @var array<int, FileUpload> $files */
$files = Nette\Forms\Helpers::extractHttpData($httpRequest->getFiles(), $this->getUploadControl()->getHtmlName() . '[]', Form::DATA_FILE);
if (count($files) === 0) {
return [];
Expand Down
4 changes: 4 additions & 0 deletions tests/FileUploadControl/FileUploadControlValidationTest.phpt
Expand Up @@ -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');
Expand Down

0 comments on commit 1442eab

Please sign in to comment.