From 0d284bea3392a1dafc042eaeb7ef514095dc456b Mon Sep 17 00:00:00 2001 From: Daniel Jakob Date: Tue, 31 Oct 2023 20:19:20 +0100 Subject: [PATCH] Add type coverage phpstan extension --- composer.json | 3 +- composer.lock | 145 +++++++++++++++++- phpstan.neon | 4 + .../Cli/Wizard/UserCreationWizard.php | 2 +- .../Io/Transcoder/FfmpegTranscoder.php | 2 +- .../Io/Transcoder/TranscoderInterface.php | 2 +- 6 files changed, 153 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index d174afa..77b2752 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,8 @@ "phpstan/phpstan-strict-rules": "^1", "phpunit/phpunit": "^10", "rector/rector": "^0.18", - "tomasvotruba/cognitive-complexity": "^0.2" + "tomasvotruba/cognitive-complexity": "^0.2", + "tomasvotruba/type-coverage": "^0.2.1" }, "license": "MIT", "authors": [ diff --git a/composer.lock b/composer.lock index d2ebf4a..d6ceb26 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "021f86dc15f601d14e43236b1f3ce8b7", + "content-hash": "85b5abe5d7a284d9bc47034a14173654", "packages": [ { "name": "aaronddm/xml-builder", @@ -6501,6 +6501,92 @@ ], "time": "2023-03-08T13:26:56+00:00" }, + { + "name": "nette/utils", + "version": "v4.0.3", + "source": { + "type": "git", + "url": "https://github.com/nette/utils.git", + "reference": "a9d127dd6a203ce6d255b2e2db49759f7506e015" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/utils/zipball/a9d127dd6a203ce6d255b2e2db49759f7506e015", + "reference": "a9d127dd6a203ce6d255b2e2db49759f7506e015", + "shasum": "" + }, + "require": { + "php": ">=8.0 <8.4" + }, + "conflict": { + "nette/finder": "<3", + "nette/schema": "<1.2.2" + }, + "require-dev": { + "jetbrains/phpstorm-attributes": "dev-master", + "nette/tester": "^2.5", + "phpstan/phpstan": "^1.0", + "tracy/tracy": "^2.9" + }, + "suggest": { + "ext-gd": "to use Image", + "ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()", + "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", + "ext-json": "to use Nette\\Utils\\Json", + "ext-mbstring": "to use Strings::lower() etc...", + "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0-only", + "GPL-3.0-only" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", + "homepage": "https://nette.org", + "keywords": [ + "array", + "core", + "datetime", + "images", + "json", + "nette", + "paginator", + "password", + "slugify", + "string", + "unicode", + "utf-8", + "utility", + "validation" + ], + "support": { + "issues": "https://github.com/nette/utils/issues", + "source": "https://github.com/nette/utils/tree/v4.0.3" + }, + "time": "2023-10-29T21:02:13+00:00" + }, { "name": "nikic/php-parser", "version": "v4.17.1", @@ -9039,6 +9125,63 @@ } ], "time": "2023-09-08T09:56:00+00:00" + }, + { + "name": "tomasvotruba/type-coverage", + "version": "0.2.1", + "source": { + "type": "git", + "url": "https://github.com/TomasVotruba/type-coverage.git", + "reference": "a152ac431b2312ec173f3093a628ff988b7ed10f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/TomasVotruba/type-coverage/zipball/a152ac431b2312ec173f3093a628ff988b7ed10f", + "reference": "a152ac431b2312ec173f3093a628ff988b7ed10f", + "shasum": "" + }, + "require": { + "nette/utils": "^3.2 || ^4.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.3" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "config/extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "TomasVotruba\\TypeCoverage\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Measure type coverage of your project", + "keywords": [ + "phpstan-extension", + "static analysis" + ], + "support": { + "issues": "https://github.com/TomasVotruba/type-coverage/issues", + "source": "https://github.com/TomasVotruba/type-coverage/tree/0.2.1" + }, + "funding": [ + { + "url": "https://www.paypal.me/rectorphp", + "type": "custom" + }, + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2023-08-27T10:33:51+00:00" } ], "aliases": [], diff --git a/phpstan.neon b/phpstan.neon index 5b4cddb..85239dd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,6 +10,10 @@ parameters: cognitive_complexity: class: 50 function: 10 + type_coverage: + return_type: 100 + param_type: 100 + property_type: 100 includes: - vendor/phpstan/phpstan/conf/bleedingEdge.neon diff --git a/src/Component/Cli/Wizard/UserCreationWizard.php b/src/Component/Cli/Wizard/UserCreationWizard.php index 68a68da..01151ac 100644 --- a/src/Component/Cli/Wizard/UserCreationWizard.php +++ b/src/Component/Cli/Wizard/UserCreationWizard.php @@ -43,7 +43,7 @@ public function create( return; } - $validator = static function ($password): string { + $validator = static function (mixed $password): string { $password = trim((string) $password); if (mb_strlen($password) < PasswordVerificator::PASSWORD_MIN_LENGTH) { throw new InvalidArgumentException('Password too short'); diff --git a/src/Component/Io/Transcoder/FfmpegTranscoder.php b/src/Component/Io/Transcoder/FfmpegTranscoder.php index 2a110f3..25f670e 100644 --- a/src/Component/Io/Transcoder/FfmpegTranscoder.php +++ b/src/Component/Io/Transcoder/FfmpegTranscoder.php @@ -29,7 +29,7 @@ public function setFilePath(string $file_path): self /** * @return resource */ - public function getHandle() + public function getHandle(): mixed { $transcodingConfig = $this->configProvider->getTranscodingConfig(); diff --git a/src/Component/Io/Transcoder/TranscoderInterface.php b/src/Component/Io/Transcoder/TranscoderInterface.php index a0c398a..5df0408 100644 --- a/src/Component/Io/Transcoder/TranscoderInterface.php +++ b/src/Component/Io/Transcoder/TranscoderInterface.php @@ -11,5 +11,5 @@ public function setFilePath(string $file_path): self; /** * @return resource */ - public function getHandle(); + public function getHandle(): mixed; }