diff --git a/.gitattributes b/.gitattributes index ee08e84..526c96a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,5 +6,6 @@ Makefile export-ignore README.md export-ignore phpstan.neon export-ignore +phpstan-baseline.neon export-ignore ruleset.xml export-ignore tests export-ignore diff --git a/.github/.kodiak.toml b/.github/.kodiak.toml deleted file mode 100644 index 60c34b6..0000000 --- a/.github/.kodiak.toml +++ /dev/null @@ -1,10 +0,0 @@ -version = 1 - -[merge] -automerge_label = "automerge" -blacklist_title_regex = "^WIP.*" -blacklist_labels = ["WIP"] -method = "rebase" -delete_branch_on_merge = true -notify_on_conflict = true -optimistic_updates = false diff --git a/.github/workflows/codesniffer.yml b/.github/workflows/codesniffer.yml index a58ac4f..d5ff803 100644 --- a/.github/workflows/codesniffer.yml +++ b/.github/workflows/codesniffer.yml @@ -15,4 +15,4 @@ jobs: name: "Codesniffer" uses: contributte/.github/.github/workflows/codesniffer.yml@master with: - php: "8.2" + php: "8.3" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 860c47e..9b105e9 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -8,11 +8,11 @@ on: branches: ["*"] schedule: - - cron: "0 8 * * 1" + - cron: "0 9 * * 1" jobs: coverage: name: "Nette Tester" uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master with: - php: "8.2" + php: "8.3" diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index eb916bf..c0dccb4 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -8,11 +8,11 @@ on: branches: ["*"] schedule: - - cron: "0 8 * * 1" + - cron: "0 10 * * 1" jobs: phpstan: name: "Phpstan" uses: contributte/.github/.github/workflows/phpstan.yml@master with: - php: "8.2" + php: "8.3" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a574bd1..6462f70 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,30 +8,36 @@ on: branches: [ "*" ] schedule: - - cron: "0 8 * * 1" + - cron: "0 10 * * 1" jobs: - test83: + test85: name: "Nette Tester" uses: contributte/.github/.github/workflows/nette-tester.yml@master with: - php: "8.3" + php: "8.5" - test82: + test84: name: "Nette Tester" uses: contributte/.github/.github/workflows/nette-tester.yml@master with: - php: "8.2" + php: "8.4" - test81: + test83: name: "Nette Tester" uses: contributte/.github/.github/workflows/nette-tester.yml@master with: - php: "8.1" + php: "8.3" + + test82: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.2" testlower: name: "Nette Tester" uses: contributte/.github/.github/workflows/nette-tester.yml@master with: - php: "8.1" + php: "8.2" composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest" diff --git a/composer.json b/composer.json index c0384a5..5434324 100644 --- a/composer.json +++ b/composer.json @@ -10,12 +10,8 @@ "resize", "upload" ], - "license": [ - "MIT" - ], - "support": { - "issues": "https://github.com/contributte/image-storage/issues" - }, + "license": "MIT", + "homepage": "https://github.com/contributte/image-storage", "authors": [ { "name": "Pavel Janda", @@ -23,40 +19,40 @@ } ], "require": { - "php": ">=8.1", + "php": ">=8.2", + "latte/latte": "^3.0.12", "nette/application": "^3.1.14", - "nette/utils": "^4.0.3", "nette/di": "^3.1.8", "nette/http": "^3.2.3", - "latte/latte": "^3.0.12" + "nette/utils": "^4.0.3" }, "require-dev": { - "contributte/qa": "^0.4", - "contributte/tester": "^0.3", - "contributte/phpstan": "^0.1", + "contributte/phpstan": "^0.2.0", + "contributte/qa": "^0.4.0", + "contributte/tester": "^0.3.0", "tracy/tracy": "^2.10.5" }, - "autoload": { - "psr-4": { - "Contributte\\ImageStorage\\": "src" - } - }, - "autoload-dev": { - "psr-4": { - "Tests\\": "tests" - } - }, - "minimum-stability": "dev", - "prefer-stable": true, - "config": { - "sort-packages": true, - "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true - } - }, - "extra": { - "branch-alias": { - "dev-master": "3.1.x-dev" - } - } + "autoload": { + "psr-4": { + "Contributte\\ImageStorage\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "config": { + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, + "extra": { + "branch-alias": { + "dev-master": "3.1.x-dev" + } + } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 829fb07..8aca681 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,146 +1,211 @@ parameters: ignoreErrors: - - message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#" + message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#' + identifier: ternary.shortNotAllowed count: 1 path: src/Image.php - - message: "#^Variable property access on \\$this\\(Contributte\\\\ImageStorage\\\\Image\\)\\.$#" + message: '#^Variable property access on \$this\(Contributte\\ImageStorage\\Image\)\.$#' + identifier: property.dynamicName count: 1 path: src/Image.php - - message: "#^Only booleans are allowed in &&, array\\ given on the left side\\.$#" + message: '#^Only booleans are allowed in &&, array\ given on the left side\.$#' + identifier: booleanAnd.leftNotBoolean count: 1 path: src/ImageNameScript.php - - message: "#^Only booleans are allowed in &&, int given on the right side\\.$#" + message: '#^Only booleans are allowed in &&, int given on the right side\.$#' + identifier: booleanAnd.rightNotBoolean count: 2 path: src/ImageNameScript.php - - message: "#^Only booleans are allowed in &&, string given on the left side\\.$#" + message: '#^Only booleans are allowed in &&, string given on the left side\.$#' + identifier: booleanAnd.leftNotBoolean count: 1 path: src/ImageNameScript.php - - message: "#^Only booleans are allowed in &&, string given on the right side\\.$#" + message: '#^Only booleans are allowed in &&, string given on the right side\.$#' + identifier: booleanAnd.rightNotBoolean count: 3 path: src/ImageNameScript.php - - message: "#^Only booleans are allowed in an if condition, array\\ given\\.$#" + message: '#^Only booleans are allowed in an if condition, array\ given\.$#' + identifier: if.condNotBoolean count: 1 path: src/ImageNameScript.php - - message: "#^Only booleans are allowed in an if condition, int given\\.$#" + message: '#^Only booleans are allowed in an if condition, int given\.$#' + identifier: if.condNotBoolean count: 2 path: src/ImageNameScript.php - - message: "#^Only booleans are allowed in an if condition, int\\<0, max\\> given\\.$#" + message: '#^Only booleans are allowed in an if condition, int\<0, max\> given\.$#' + identifier: if.condNotBoolean count: 2 path: src/ImageNameScript.php - - message: "#^Parameter \\#1 \\$pattern of function preg_match expects string, string\\|null given\\.$#" + message: '#^Parameter \#1 \$pattern of function preg_match expects string, string\|null given\.$#' + identifier: argument.type count: 1 path: src/ImageNameScript.php - - message: "#^Cannot use array destructuring on array\\\\|Contributte\\\\ImageStorage\\\\Image\\.$#" + message: '#^Cannot use array destructuring on Contributte\\ImageStorage\\Image\|list\\.$#' + identifier: offsetAccess.nonArray count: 2 path: src/ImageStorage.php - - message: "#^Method Contributte\\\\ImageStorage\\\\ImageStorage\\:\\:fromIdentifier\\(\\) should return Contributte\\\\ImageStorage\\\\Image but returns array\\\\|Contributte\\\\ImageStorage\\\\Image\\.$#" + message: '#^Method Contributte\\ImageStorage\\ImageStorage\:\:fromIdentifier\(\) should return Contributte\\ImageStorage\\Image but returns Contributte\\ImageStorage\\Image\|list\\.$#' + identifier: return.type count: 1 path: src/ImageStorage.php - - message: "#^Only booleans are allowed in &&, int given on the right side\\.$#" + message: '#^Negated boolean expression is always false\.$#' + identifier: booleanNot.alwaysFalse count: 1 path: src/ImageStorage.php - - message: "#^Only booleans are allowed in a negated boolean, int given\\.$#" + message: '#^Only booleans are allowed in &&, int given on the right side\.$#' + identifier: booleanAnd.rightNotBoolean + count: 1 + path: src/ImageStorage.php + + - + message: '#^Only booleans are allowed in a negated boolean, int given\.$#' + identifier: booleanNot.exprNotBoolean count: 2 path: src/ImageStorage.php - - message: "#^Only booleans are allowed in a negated boolean, int\\|false given\\.$#" + message: '#^Only booleans are allowed in a negated boolean, int\|false given\.$#' + identifier: booleanNot.exprNotBoolean count: 1 path: src/ImageStorage.php - - message: "#^Only booleans are allowed in a negated boolean, string given\\.$#" + message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#' + identifier: booleanNot.exprNotBoolean + count: 2 + path: src/ImageStorage.php + + - + message: '#^Only booleans are allowed in a negated boolean, string given\.$#' + identifier: booleanNot.exprNotBoolean count: 1 path: src/ImageStorage.php - - message: "#^Only booleans are allowed in a negated boolean, string\\|null given\\.$#" + message: '#^Only booleans are allowed in a negated boolean, string\|null given\.$#' + identifier: booleanNot.exprNotBoolean count: 2 path: src/ImageStorage.php - - message: "#^Parameter \\#1 \\$name of static method Contributte\\\\ImageStorage\\\\ImageNameScript\\:\\:fromName\\(\\) expects string, mixed given\\.$#" + message: '#^Parameter \#1 \$identifier of static method Contributte\\ImageStorage\\ImageNameScript\:\:fromIdentifier\(\) expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: src/ImageStorage.php + + - + message: '#^Parameter \#1 \$name of static method Contributte\\ImageStorage\\ImageNameScript\:\:fromName\(\) expects string, mixed given\.$#' + identifier: argument.type count: 1 path: src/ImageStorage.php - - message: "#^Parameter \\#1 \\$pattern of function preg_match expects string, string\\|null given\\.$#" + message: '#^Parameter \#1 \$pattern of function preg_match expects string, string\|null given\.$#' + identifier: argument.type count: 1 path: src/ImageStorage.php - - message: "#^Parameter \\#1 \\$s of static method Nette\\\\Utils\\\\Image\\:\\:fromString\\(\\) expects string, string\\|false given\\.$#" + message: '#^Parameter \#1 \$s of static method Nette\\Utils\\Image\:\:fromString\(\) expects string, string\|false given\.$#' + identifier: argument.type count: 1 path: src/ImageStorage.php - - message: "#^Parameter \\#3 \\$checksum of method Contributte\\\\ImageStorage\\\\ImageStorage\\:\\:getSavePath\\(\\) expects string, mixed given\\.$#" + message: '#^Parameter \#2 \$quality of method Nette\\Utils\\Image\:\:save\(\) expects int\|null, mixed given\.$#' + identifier: argument.type + count: 1 + path: src/ImageStorage.php + + - + message: '#^Parameter \#3 \$checksum of method Contributte\\ImageStorage\\ImageStorage\:\:getSavePath\(\) expects string, mixed given\.$#' + identifier: argument.type count: 2 path: src/ImageStorage.php - - message: "#^Parameter \\#3 \\$mode of method Nette\\\\Utils\\\\Image\\:\\:resize\\(\\) expects int\\<0, 15\\>, int given\\.$#" + message: '#^Parameter \#3 \$mode of method Nette\\Utils\\Image\:\:resize\(\) expects int\<0, 15\>, int given\.$#' + identifier: argument.type count: 1 path: src/ImageStorage.php - - message: "#^Parameter \\#5 \\$props of class Contributte\\\\ImageStorage\\\\Image constructor expects array\\, array\\ given\\.$#" + message: '#^Parameter \#4 \$identifier of class Contributte\\ImageStorage\\Image constructor expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: src/ImageStorage.php + + - + message: '#^Parameter \#5 \$props of class Contributte\\ImageStorage\\Image constructor expects array\, array\ given\.$#' + identifier: argument.type count: 2 path: src/ImageStorage.php - - message: "#^Right side of && is always true\\.$#" + message: '#^Right side of && is always true\.$#' + identifier: booleanAnd.rightAlwaysTrue count: 1 path: src/ImageStorage.php - - message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#" + message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#' + identifier: ternary.shortNotAllowed count: 1 path: src/ImageStorage.php - - message: "#^Undefined variable\\: \\$i$#" + message: '#^Undefined variable\: \$i$#' + identifier: variable.undefined count: 1 path: src/ImageStorage.php - - message: "#^Variable \\$i might not be defined\\.$#" + message: '#^Variable \$i might not be defined\.$#' + identifier: variable.undefined count: 1 path: src/ImageStorage.php - - message: "#^Variable \\$path might not be defined\\.$#" + message: '#^Variable \$path might not be defined\.$#' + identifier: variable.undefined count: 1 path: src/ImageStorage.php - - message: "#^Return type \\(array\\) of method Contributte\\\\ImageStorage\\\\Latte\\\\LatteExtension\\:\\:getTags\\(\\) should be covariant with return type \\(array\\\\) of method Latte\\\\Extension\\:\\:getTags\\(\\)$#" + message: '#^Trait Contributte\\ImageStorage\\ImageStoragePresenterTrait is used zero times and is not analysed\.$#' + identifier: trait.unused + count: 1 + path: src/ImageStoragePresenterTrait.php + + - + message: '#^Return type \(array\\) of method Contributte\\ImageStorage\\Latte\\LatteExtension\:\:getTags\(\) should be covariant with return type \(array\\) of method Latte\\Extension\:\:getTags\(\)$#' + identifier: method.childReturnType count: 1 path: src/Latte/LatteExtension.php diff --git a/phpstan.neon b/phpstan.neon index d0fc1d3..2a59ed5 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,7 +4,7 @@ includes: parameters: level: 9 - phpVersion: 80100 + phpVersion: 80200 scanDirectories: - src diff --git a/ruleset.xml b/ruleset.xml index 4a6186e..6a84ad0 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,7 +1,7 @@ - + diff --git a/tests/Cases/ImageStorageTest.php b/tests/Cases/ImageStorageTest.php index 65687ad..61da4af 100644 --- a/tests/Cases/ImageStorageTest.php +++ b/tests/Cases/ImageStorageTest.php @@ -109,7 +109,7 @@ public function testUpload(): void $upload = new FileUpload([ 'name' => 'upload.jpg', 'type' => 'image/jpg', - 'size' => '20', + 'size' => 20, 'tmp_name' => $tempImagePath, 'error' => 0, ]); diff --git a/tests/Cases/QualityConversionTest.php b/tests/Cases/QualityConversionTest.php index 606256f..c9fca44 100644 --- a/tests/Cases/QualityConversionTest.php +++ b/tests/Cases/QualityConversionTest.php @@ -24,6 +24,8 @@ final class QualityConversionTest extends TestCase private ReflectionMethod $getQualityMethod; + private ImageStorage $storage; + public function setUp(): void { $storage = new ImageStorage( @@ -40,12 +42,9 @@ public function setUp(): void // Access private method for testing $this->getQualityMethod = new ReflectionMethod(ImageStorage::class, 'getQualityForFormat'); - $this->getQualityMethod->setAccessible(true); $this->storage = $storage; } - private ImageStorage $storage; - public function testJpegQuality(): void { // JPEG should return configured value (85) @@ -106,7 +105,6 @@ public function testCustomQualityConfiguration(): void ); $method = new ReflectionMethod(ImageStorage::class, 'getQualityForFormat'); - $method->setAccessible(true); Assert::same(95, $method->invoke($storage, 'jpg')); Assert::same(2, $method->invoke($storage, 'png'));