From 41c4baf01310ce3e19f9e506d99f2e769bc08163 Mon Sep 17 00:00:00 2001 From: mondrake Date: Sat, 14 May 2022 12:29:09 +0200 Subject: [PATCH 1/2] Add Psalm badges (#64) --- .github/workflows/code-quality.yml | 2 +- README.md | 6 +++++- src/Map/AbstractMap.php | 2 +- src/Map/BaseMap.php | 2 +- src/Map/DefaultMap.php | 2 +- src/Map/EmptyMap.php | 2 +- src/Map/MiniMap.php.test | 2 +- src/TypeParser.php | 4 ++-- 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index e5550466..0d8b848b 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -35,7 +35,7 @@ jobs: run: "vendor/bin/phpstan" - name: "Run static analysis with vimeo/psalm" - run: ./vendor/bin/psalm + run: ./vendor/bin/psalm --shepherd - name: "Run code style check with squizlabs/php_codesniffer" run: ./vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1 diff --git a/README.md b/README.md index 3a3b80de..a74cd4a7 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![Tests](https://github.com/FileEye/MimeMap/actions/workflows/php-unit.yml/badge.svg)](https://github.com/FileEye/MimeMap/actions/workflows/php-unit.yml) [![PHPStan](https://img.shields.io/badge/PHPStan-level%20max-brightgreen.svg?style=flat)](https://github.com/FileEye/MimeMap/actions/workflows/code-quality.yml) +[![Psalm coverage](https://shepherd.dev/github/FileEye/MimeMap/coverage.svg?)](https://shepherd.dev/github/FileEye/MimeMap) +[![Psalm level](https://shepherd.dev/github/FileEye/MimeMap/level.svg?)](https://psalm.dev/) [![codecov](https://codecov.io/gh/FileEye/MimeMap/branch/master/graph/badge.svg?token=SUAMNKZLEW)](https://codecov.io/gh/FileEye/MimeMap) [![Latest Stable Version](https://poser.pugx.org/fileeye/mimemap/v/stable)](https://packagist.org/packages/fileeye/mimemap) [![Total Downloads](https://poser.pugx.org/fileeye/mimemap/downloads)](https://packagist.org/packages/fileeye/mimemap) @@ -22,6 +24,8 @@ extensions. the most authoritative sources available, [Apache's documentation](http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=log) and the [freedesktop.org project](http://freedesktop.org). - PHPUnit tested, 100% test coverage +- PHPStan tested +- Psalm tested ## Credits @@ -128,7 +132,7 @@ associated to it: // will print 'text/plain (Unstructured text); charset="utf-8" (UTF8, not ASCII), lang="it" (Italian)' ``` -4. You have a MIME Content-Type string and want to the type's description as a comment: +4. You have a MIME Content-Type string and want to add the type's description as a comment: ```php use FileEye\MimeMap\Type; diff --git a/src/Map/AbstractMap.php b/src/Map/AbstractMap.php index baaaa707..b4492513 100644 --- a/src/Map/AbstractMap.php +++ b/src/Map/AbstractMap.php @@ -43,7 +43,7 @@ protected function normalizeType(string $type_string): string throw new MalformedTypeException('Media subtype not found'); } - return strtolower((string) $media['string']) . '/' . strtolower((string) $sub['string']); + return strtolower($media['string']) . '/' . strtolower($sub['string']); } public function hasType(string $type): bool diff --git a/src/Map/BaseMap.php b/src/Map/BaseMap.php index 85ec7b79..a8591851 100644 --- a/src/Map/BaseMap.php +++ b/src/Map/BaseMap.php @@ -14,7 +14,7 @@ abstract class BaseMap implements MapInterface /** * Singleton instance. * - * @var MapInterface + * @var MapInterface|null */ protected static $instance; diff --git a/src/Map/DefaultMap.php b/src/Map/DefaultMap.php index c734f629..e60eeee8 100644 --- a/src/Map/DefaultMap.php +++ b/src/Map/DefaultMap.php @@ -10,7 +10,7 @@ class DefaultMap extends AbstractMap { /** - * @var MapInterface + * @var MapInterface|null */ protected static $instance; diff --git a/src/Map/EmptyMap.php b/src/Map/EmptyMap.php index 91ad1230..f9b352cf 100644 --- a/src/Map/EmptyMap.php +++ b/src/Map/EmptyMap.php @@ -11,7 +11,7 @@ class EmptyMap extends AbstractMap { /** - * @var MapInterface + * @var MapInterface|null */ protected static $instance; } diff --git a/src/Map/MiniMap.php.test b/src/Map/MiniMap.php.test index 8a3a20ad..ccf56503 100644 --- a/src/Map/MiniMap.php.test +++ b/src/Map/MiniMap.php.test @@ -11,7 +11,7 @@ namespace FileEye\MimeMap\Map; class MiniMap extends AbstractMap { /** - * @var MapInterface + * @var MapInterface|null */ protected static $instance; diff --git a/src/TypeParser.php b/src/TypeParser.php index 06f7c734..b60c301e 100644 --- a/src/TypeParser.php +++ b/src/TypeParser.php @@ -27,7 +27,7 @@ public static function parse(string $type_string, Type $type): void if (!$media['delimiter_matched']) { throw new MalformedTypeException('Slash \'/\' to separate media type and subtype not found'); } - $type->setMedia(strtolower((string) $media['string'])); + $type->setMedia(strtolower($media['string'])); if ($media['comment'] !== null) { $type->setMediaComment($media['comment']); } @@ -37,7 +37,7 @@ public static function parse(string $type_string, Type $type): void if (!$sub['string']) { throw new MalformedTypeException('Media subtype not found'); } - $type->setSubType(strtolower((string) $sub['string'])); + $type->setSubType(strtolower($sub['string'])); if ($sub['comment'] !== null) { $type->setSubTypeComment($sub['comment']); } From 2b88a9fd5f786aefbea6ae93dcbaef479e157f6c Mon Sep 17 00:00:00 2001 From: mondrake Date: Sat, 14 May 2022 12:50:00 +0200 Subject: [PATCH 2/2] Updating README badges --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a74cd4a7..d33dc18a 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # MimeMap +[![PHP Version Require](http://poser.pugx.org/fileeye/mimemap/require/php)](https://packagist.org/packages/fileeye/mimemap) [![Tests](https://github.com/FileEye/MimeMap/actions/workflows/php-unit.yml/badge.svg)](https://github.com/FileEye/MimeMap/actions/workflows/php-unit.yml) [![PHPStan](https://img.shields.io/badge/PHPStan-level%20max-brightgreen.svg?style=flat)](https://github.com/FileEye/MimeMap/actions/workflows/code-quality.yml) [![Psalm coverage](https://shepherd.dev/github/FileEye/MimeMap/coverage.svg?)](https://shepherd.dev/github/FileEye/MimeMap) [![Psalm level](https://shepherd.dev/github/FileEye/MimeMap/level.svg?)](https://psalm.dev/) [![codecov](https://codecov.io/gh/FileEye/MimeMap/branch/master/graph/badge.svg?token=SUAMNKZLEW)](https://codecov.io/gh/FileEye/MimeMap) [![Latest Stable Version](https://poser.pugx.org/fileeye/mimemap/v/stable)](https://packagist.org/packages/fileeye/mimemap) +[![Latest Unstable Version](http://poser.pugx.org/fileeye/mimemap/v/unstable)](https://packagist.org/packages/fileeye/mimemap) [![Total Downloads](https://poser.pugx.org/fileeye/mimemap/downloads)](https://packagist.org/packages/fileeye/mimemap) [![License](https://poser.pugx.org/fileeye/mimemap/license)](https://packagist.org/packages/fileeye/mimemap)