diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2453acd..4c4ddef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,8 +44,3 @@ jobs: - name: Run PHPStan run: composer run-script phpstan - - #- name: Analysis - # uses: php-actions/phpstan@v3 - # with: - # path: src/ dist/ bin/ diff --git a/.github/workflows/notify.yml b/.github/workflows/notify.yml deleted file mode 100644 index 361aa26..0000000 --- a/.github/workflows/notify.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Notify - -on: - workflow_dispatch: - release: - types: [published] - -jobs: - setup: - permissions: read-all - runs-on: ubuntu-latest - steps: - - uses: nearform-actions/github-action-notify-twitter@v1.1.5 - with: - message: | - ${{ github.repository }} (${{ github.event.repository.name }}) ${{ github.event.release.tag_name }} has been released. Release notes: ${{ github.event.release.html_url }} #opensource #opensourcesoftware - twitter-app-key: ${{ secrets.TWITTER_APP_KEY }} - twitter-app-secret: ${{ secrets.TWITTER_APP_SECRET }} - twitter-access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }} - twitter-access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 181041a..b417623 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ '8.1', '8.2', '8.3' ] + php: [ '8.1', '8.2', '8.3', '8.4' ] steps: - uses: actions/checkout@v4 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index eb55f28..20f1daa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,13 @@ -### 1.1.1 (2023-12-14) +### 1.1.1 (2023-12-20) * Added Scrutinizer to workflow * Updating codebase based on PHPStan level 9, strict w/bleeding edge. A work in progress * Updated docs throughout * First pass and attempt at adhering to PSR-12, PSR-5, and PSR-19 + * Updated tests to use the PHPUnit CoversClass and DataProvider attributes. + * Update composer.json and github workflows to allow PHP 8.4 into the mix. + * Updated unit tests to use `self::` instead of `$this->` when calling PHPUnit methods + * Pass through to add function, exception, and constant imports ### 1.1.0 (2023-11-27) diff --git a/bin/update.php b/bin/update.php index d498f15..c250787 100644 --- a/bin/update.php +++ b/bin/update.php @@ -4,7 +4,7 @@ declare(strict_types=1); $updateUrl = 'https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types'; -$destinationFile = dirname(__DIR__) . "/data/mime.types"; +$destinationFile = dirname(__DIR__) . '/data/mime.types'; file_put_contents($destinationFile, file_get_contents($updateUrl)); diff --git a/composer.json b/composer.json index 42f204b..d3f0e4d 100644 --- a/composer.json +++ b/composer.json @@ -20,13 +20,14 @@ } ], "require": { - "php": "^8.1", + "php": "^8.1 <8.5", "jetbrains/phpstorm-attributes": "^1.0" }, "require-dev": { - "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.4", + "phpstan/phpstan": "^1.11", "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^10.2" + "phpstan/phpstan-strict-rules": "^1.5" }, "suggest": { "ext-mbstring": "For non-English (user) input parsing" diff --git a/composer.lock b/composer.lock index c3fbe01..a4f73da 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": "6444e86c04661b6520aaf0d14435c8ba", + "content-hash": "cd6299f888000e1677267617df9c63eb", "packages": [ { "name": "jetbrains/phpstorm-attributes", @@ -292,12 +292,12 @@ "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "57cc76bb41632805985d726b721d9c53a92ddfbc" + "reference": "26c870cf58b59c4e68d66a92f100098ee213b9fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/57cc76bb41632805985d726b721d9c53a92ddfbc", - "reference": "57cc76bb41632805985d726b721d9c53a92ddfbc", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/26c870cf58b59c4e68d66a92f100098ee213b9fd", + "reference": "26c870cf58b59c4e68d66a92f100098ee213b9fd", "shasum": "" }, "require": { @@ -347,7 +347,7 @@ "type": "tidelift" } ], - "time": "2023-12-13T14:23:01+00:00" + "time": "2023-12-20T14:51:38+00:00" }, { "name": "phpstan/phpstan-phpunit", @@ -402,18 +402,68 @@ }, "time": "2023-11-20T08:52:11+00:00" }, + { + "name": "phpstan/phpstan-strict-rules", + "version": "1.6.x-dev", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-strict-rules.git", + "reference": "2090cfca49793b876887695f3293062070abc83c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/2090cfca49793b876887695f3293062070abc83c", + "reference": "2090cfca49793b876887695f3293062070abc83c", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.11" + }, + "require-dev": { + "nikic/php-parser": "^4.13.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-deprecation-rules": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "default-branch": true, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Extra strict and opinionated rules for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.6.x" + }, + "time": "2023-11-20T08:49:59+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "dev-main", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "599109c8ca6bae97b23482d557d2874c25a65e59" + "reference": "a48ea06e9c39d81fa7d9b73e58bc197c5a61cdc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/599109c8ca6bae97b23482d557d2874c25a65e59", - "reference": "599109c8ca6bae97b23482d557d2874c25a65e59", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/a48ea06e9c39d81fa7d9b73e58bc197c5a61cdc1", + "reference": "a48ea06e9c39d81fa7d9b73e58bc197c5a61cdc1", "shasum": "" }, "require": { @@ -471,7 +521,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.10" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/main" }, "funding": [ { @@ -479,7 +529,7 @@ "type": "github" } ], - "time": "2023-12-11T06:28:43+00:00" + "time": "2023-12-17T06:16:24+00:00" }, { "name": "phpunit/php-file-iterator", @@ -548,12 +598,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "a2fd9d53892abd0b30796cf6e64e6c1ce9d3d82f" + "reference": "947a522896f95fe2ee79878756b0151c5507b253" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/a2fd9d53892abd0b30796cf6e64e6c1ce9d3d82f", - "reference": "a2fd9d53892abd0b30796cf6e64e6c1ce9d3d82f", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/947a522896f95fe2ee79878756b0151c5507b253", + "reference": "947a522896f95fe2ee79878756b0151c5507b253", "shasum": "" }, "require": { @@ -605,7 +655,7 @@ "type": "github" } ], - "time": "2023-12-09T12:53:14+00:00" + "time": "2023-12-17T06:14:15+00:00" }, { "name": "phpunit/php-text-template", @@ -613,12 +663,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "36ce468c414d5fb1e0667d991b45bee6cac28c8b" + "reference": "3f8cf5f87e01953a65a61f75a10513caf93373e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/36ce468c414d5fb1e0667d991b45bee6cac28c8b", - "reference": "36ce468c414d5fb1e0667d991b45bee6cac28c8b", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/3f8cf5f87e01953a65a61f75a10513caf93373e3", + "reference": "3f8cf5f87e01953a65a61f75a10513caf93373e3", "shasum": "" }, "require": { @@ -666,7 +716,7 @@ "type": "github" } ], - "time": "2023-12-09T12:53:24+00:00" + "time": "2023-12-17T06:14:27+00:00" }, { "name": "phpunit/php-timer", @@ -674,12 +724,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "d118c2e2a37f6b0d5f4cd51d16c6203ada6eff48" + "reference": "551c6179a1ece754fed773bb496c30bb375ad894" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/d118c2e2a37f6b0d5f4cd51d16c6203ada6eff48", - "reference": "d118c2e2a37f6b0d5f4cd51d16c6203ada6eff48", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/551c6179a1ece754fed773bb496c30bb375ad894", + "reference": "551c6179a1ece754fed773bb496c30bb375ad894", "shasum": "" }, "require": { @@ -727,7 +777,7 @@ "type": "github" } ], - "time": "2023-12-09T12:53:34+00:00" + "time": "2023-12-17T06:14:38+00:00" }, { "name": "phpunit/phpunit", @@ -735,12 +785,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "d77a326390886d870b1b552a2967aa1b7978ed0d" + "reference": "203812604f83d9c6f983358bda3aeecacb6b61d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d77a326390886d870b1b552a2967aa1b7978ed0d", - "reference": "d77a326390886d870b1b552a2967aa1b7978ed0d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/203812604f83d9c6f983358bda3aeecacb6b61d0", + "reference": "203812604f83d9c6f983358bda3aeecacb6b61d0", "shasum": "" }, "require": { @@ -828,7 +878,7 @@ "type": "tidelift" } ], - "time": "2023-12-13T07:53:14+00:00" + "time": "2023-12-20T06:49:48+00:00" }, { "name": "sebastian/cli-parser", @@ -836,12 +886,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "333fb1f9faea50aea580da4c9150e4f862d95335" + "reference": "82cdfad235c93acb40dcf44c04eb6ef8401d7b77" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/333fb1f9faea50aea580da4c9150e4f862d95335", - "reference": "333fb1f9faea50aea580da4c9150e4f862d95335", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/82cdfad235c93acb40dcf44c04eb6ef8401d7b77", + "reference": "82cdfad235c93acb40dcf44c04eb6ef8401d7b77", "shasum": "" }, "require": { @@ -886,7 +936,7 @@ "type": "github" } ], - "time": "2023-12-09T12:50:59+00:00" + "time": "2023-12-17T06:11:49+00:00" }, { "name": "sebastian/code-unit", @@ -894,12 +944,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "fc85d823fe82d442f09c28148f01f2de1406bfd5" + "reference": "8a8805372c0cb956144eeb88166a154a0333a95a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/fc85d823fe82d442f09c28148f01f2de1406bfd5", - "reference": "fc85d823fe82d442f09c28148f01f2de1406bfd5", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/8a8805372c0cb956144eeb88166a154a0333a95a", + "reference": "8a8805372c0cb956144eeb88166a154a0333a95a", "shasum": "" }, "require": { @@ -944,7 +994,7 @@ "type": "github" } ], - "time": "2023-12-09T12:51:12+00:00" + "time": "2023-12-17T06:12:01+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -952,12 +1002,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "a5d4b197dabd362421d775b6bf18b8a6b3660739" + "reference": "fb446b105b0a3ca1b433578a4c1e34acf0e0bb3a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/a5d4b197dabd362421d775b6bf18b8a6b3660739", - "reference": "a5d4b197dabd362421d775b6bf18b8a6b3660739", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/fb446b105b0a3ca1b433578a4c1e34acf0e0bb3a", + "reference": "fb446b105b0a3ca1b433578a4c1e34acf0e0bb3a", "shasum": "" }, "require": { @@ -1001,7 +1051,7 @@ "type": "github" } ], - "time": "2023-12-09T12:51:22+00:00" + "time": "2023-12-17T06:12:12+00:00" }, { "name": "sebastian/comparator", @@ -1009,12 +1059,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "53353f1eef05cf26c4e29cb48d5bd4c830df3725" + "reference": "e468822281bdd3e55939b80a7c307638387458ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/53353f1eef05cf26c4e29cb48d5bd4c830df3725", - "reference": "53353f1eef05cf26c4e29cb48d5bd4c830df3725", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e468822281bdd3e55939b80a7c307638387458ca", + "reference": "e468822281bdd3e55939b80a7c307638387458ca", "shasum": "" }, "require": { @@ -1079,7 +1129,7 @@ "type": "github" } ], - "time": "2023-12-09T12:51:33+00:00" + "time": "2023-12-17T06:12:23+00:00" }, { "name": "sebastian/complexity", @@ -1087,12 +1137,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "318aa5a6acf7728c9af26d03cc6af25693b27cf5" + "reference": "84d7821a4ef203ef818611116bfc8043b65b9298" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/318aa5a6acf7728c9af26d03cc6af25693b27cf5", - "reference": "318aa5a6acf7728c9af26d03cc6af25693b27cf5", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/84d7821a4ef203ef818611116bfc8043b65b9298", + "reference": "84d7821a4ef203ef818611116bfc8043b65b9298", "shasum": "" }, "require": { @@ -1138,7 +1188,7 @@ "type": "github" } ], - "time": "2023-12-09T12:51:43+00:00" + "time": "2023-12-17T06:12:35+00:00" }, { "name": "sebastian/diff", @@ -1146,12 +1196,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "76dcc64d78011058dc262086ae96093098dbfbc6" + "reference": "654bd13ef56f1b721f2045100bb21b1abbb6d653" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/76dcc64d78011058dc262086ae96093098dbfbc6", - "reference": "76dcc64d78011058dc262086ae96093098dbfbc6", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/654bd13ef56f1b721f2045100bb21b1abbb6d653", + "reference": "654bd13ef56f1b721f2045100bb21b1abbb6d653", "shasum": "" }, "require": { @@ -1206,7 +1256,7 @@ "type": "github" } ], - "time": "2023-12-09T12:51:53+00:00" + "time": "2023-12-17T06:12:46+00:00" }, { "name": "sebastian/environment", @@ -1214,12 +1264,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "b720f6f2c69d57d89b52b966026ed4271d29462e" + "reference": "c0316eedd954cb6b65009d7ffca6cd43fee54ef9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/b720f6f2c69d57d89b52b966026ed4271d29462e", - "reference": "b720f6f2c69d57d89b52b966026ed4271d29462e", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/c0316eedd954cb6b65009d7ffca6cd43fee54ef9", + "reference": "c0316eedd954cb6b65009d7ffca6cd43fee54ef9", "shasum": "" }, "require": { @@ -1271,7 +1321,7 @@ "type": "github" } ], - "time": "2023-12-09T12:52:03+00:00" + "time": "2023-12-17T06:12:57+00:00" }, { "name": "sebastian/exporter", @@ -1279,12 +1329,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "032cf1796b94e920f6059f3f66ef3dec00d89166" + "reference": "dfc9aa2f005c78ebf8e16ad1f7508ef2a151cf4c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/032cf1796b94e920f6059f3f66ef3dec00d89166", - "reference": "032cf1796b94e920f6059f3f66ef3dec00d89166", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/dfc9aa2f005c78ebf8e16ad1f7508ef2a151cf4c", + "reference": "dfc9aa2f005c78ebf8e16ad1f7508ef2a151cf4c", "shasum": "" }, "require": { @@ -1350,7 +1400,7 @@ "type": "github" } ], - "time": "2023-12-09T12:52:13+00:00" + "time": "2023-12-17T06:13:08+00:00" }, { "name": "sebastian/global-state", @@ -1358,12 +1408,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "4a81eb9c42018f2dd746ac2181ec067f17b4cddb" + "reference": "35c66cadaf46c171f84a837172fc71d9ed9c0f7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/4a81eb9c42018f2dd746ac2181ec067f17b4cddb", - "reference": "4a81eb9c42018f2dd746ac2181ec067f17b4cddb", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/35c66cadaf46c171f84a837172fc71d9ed9c0f7e", + "reference": "35c66cadaf46c171f84a837172fc71d9ed9c0f7e", "shasum": "" }, "require": { @@ -1413,7 +1463,7 @@ "type": "github" } ], - "time": "2023-12-09T12:52:23+00:00" + "time": "2023-12-17T06:13:19+00:00" }, { "name": "sebastian/lines-of-code", @@ -1421,12 +1471,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c341778c2bda41ce598dc02f0912876da5d07cd3" + "reference": "be38a7a9262d1e41bacf9aa4c7328287ab13596e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c341778c2bda41ce598dc02f0912876da5d07cd3", - "reference": "c341778c2bda41ce598dc02f0912876da5d07cd3", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/be38a7a9262d1e41bacf9aa4c7328287ab13596e", + "reference": "be38a7a9262d1e41bacf9aa4c7328287ab13596e", "shasum": "" }, "require": { @@ -1472,7 +1522,7 @@ "type": "github" } ], - "time": "2023-12-09T12:52:34+00:00" + "time": "2023-12-17T06:13:32+00:00" }, { "name": "sebastian/object-enumerator", @@ -1480,12 +1530,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "0c9ec982ff95cc83cce2a7811be6c07398bcf353" + "reference": "27009d07cfd0d8923b045129cf9c769503473737" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/0c9ec982ff95cc83cce2a7811be6c07398bcf353", - "reference": "0c9ec982ff95cc83cce2a7811be6c07398bcf353", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/27009d07cfd0d8923b045129cf9c769503473737", + "reference": "27009d07cfd0d8923b045129cf9c769503473737", "shasum": "" }, "require": { @@ -1531,7 +1581,7 @@ "type": "github" } ], - "time": "2023-12-09T12:52:44+00:00" + "time": "2023-12-17T06:13:42+00:00" }, { "name": "sebastian/object-reflector", @@ -1539,12 +1589,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "fd1560a9909ac46ac6c9bf4ef34a8c2d61cd989d" + "reference": "38f6e494724fc72d8f74467cea1072a5d133912c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/fd1560a9909ac46ac6c9bf4ef34a8c2d61cd989d", - "reference": "fd1560a9909ac46ac6c9bf4ef34a8c2d61cd989d", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/38f6e494724fc72d8f74467cea1072a5d133912c", + "reference": "38f6e494724fc72d8f74467cea1072a5d133912c", "shasum": "" }, "require": { @@ -1588,7 +1638,7 @@ "type": "github" } ], - "time": "2023-12-09T12:52:54+00:00" + "time": "2023-12-17T06:13:53+00:00" }, { "name": "sebastian/recursion-context", @@ -1596,12 +1646,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "c667db4d144287807077438891c97eb4af356e2e" + "reference": "dd5e529f24c6d9decfe67d0c4097f06ae3227c64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/c667db4d144287807077438891c97eb4af356e2e", - "reference": "c667db4d144287807077438891c97eb4af356e2e", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/dd5e529f24c6d9decfe67d0c4097f06ae3227c64", + "reference": "dd5e529f24c6d9decfe67d0c4097f06ae3227c64", "shasum": "" }, "require": { @@ -1653,7 +1703,7 @@ "type": "github" } ], - "time": "2023-12-09T12:53:43+00:00" + "time": "2023-12-17T06:14:49+00:00" }, { "name": "sebastian/type", @@ -1661,12 +1711,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "81e33408e8812ba0abe464fbc071149ca24fe7e7" + "reference": "ea8c94f7ce18f17d3d554e57c0aed43ecbea1ed0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/81e33408e8812ba0abe464fbc071149ca24fe7e7", - "reference": "81e33408e8812ba0abe464fbc071149ca24fe7e7", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/ea8c94f7ce18f17d3d554e57c0aed43ecbea1ed0", + "reference": "ea8c94f7ce18f17d3d554e57c0aed43ecbea1ed0", "shasum": "" }, "require": { @@ -1711,7 +1761,7 @@ "type": "github" } ], - "time": "2023-12-09T12:53:55+00:00" + "time": "2023-12-17T06:15:01+00:00" }, { "name": "sebastian/version", @@ -1719,12 +1769,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "11642ad6e1c849da06f3f1f77e57e236e1cf6c4f" + "reference": "2515436e1f1f542074a81ccd0b8aadd4fbcccf47" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/11642ad6e1c849da06f3f1f77e57e236e1cf6c4f", - "reference": "11642ad6e1c849da06f3f1f77e57e236e1cf6c4f", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/2515436e1f1f542074a81ccd0b8aadd4fbcccf47", + "reference": "2515436e1f1f542074a81ccd0b8aadd4fbcccf47", "shasum": "" }, "require": { @@ -1766,7 +1816,7 @@ "type": "github" } ], - "time": "2023-12-09T12:54:05+00:00" + "time": "2023-12-17T06:15:12+00:00" }, { "name": "theseer/tokenizer", @@ -1825,7 +1875,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^8.1" + "php": "^8.1 <8.5" }, "platform-dev": [], "plugin-api-version": "2.6.0" diff --git a/dist/MimeType.php b/dist/MimeType.php index b8409f5..85e4870 100644 --- a/dist/MimeType.php +++ b/dist/MimeType.php @@ -1,5 +1,8 @@ diff --git a/src/MimeMappingBuilder.php b/src/MimeMappingBuilder.php index d9c5c39..7063098 100644 --- a/src/MimeMappingBuilder.php +++ b/src/MimeMappingBuilder.php @@ -12,10 +12,15 @@ */ namespace Esi\Mimey; +// Classes use JetBrains\PhpStorm\Pure; -use JsonException; -use RuntimeException; -use Throwable; + +// Exceptions +use JsonException, RuntimeException, Throwable; + +// Functions & constants +use function array_unshift, array_unique,json_encode, file_put_contents, dirname,file_get_contents, json_decode; +use const JSON_THROW_ON_ERROR, JSON_PRETTY_PRINT; /** * Mimey - PHP package for converting file extensions to MIME types and vice versa. @@ -92,23 +97,25 @@ private function __construct(array $mapping) */ public function add(string $mime, string $extension, bool $prependExtension = true, bool $prependMime = true): void { - $existingExtensions = empty($this->mapping['extensions'][$mime]) ? [] : $this->mapping['extensions'][$mime]; - $existingMimes = empty($this->mapping['mimes'][$extension]) ? [] : $this->mapping['mimes'][$extension]; + //$existingExtensions = empty($this->mapping['extensions'][$mime]) ? [] : $this->mapping['extensions'][$mime]; + //$existingMimes = empty($this->mapping['mimes'][$extension]) ? [] : $this->mapping['mimes'][$extension]; + $existingExtensions = $this->mapping['extensions'][$mime] ?? []; + $existingMimes = $this->mapping['mimes'][$extension] ?? []; if ($prependExtension) { - \array_unshift($existingExtensions, $extension); + array_unshift($existingExtensions, $extension); } else { $existingExtensions[] = $extension; } if ($prependMime) { - \array_unshift($existingMimes, $mime); + array_unshift($existingMimes, $mime); } else { $existingMimes[] = $mime; } - $this->mapping['extensions'][$mime] = \array_unique($existingExtensions); - $this->mapping['mimes'][$extension] = \array_unique($existingMimes); + $this->mapping['extensions'][$mime] = array_unique($existingExtensions); + $this->mapping['mimes'][$extension] = array_unique($existingMimes); } /** @@ -133,7 +140,7 @@ public function compile(bool $pretty = false): string { $mapping = $this->getMapping(); - return \json_encode($mapping, flags: \JSON_THROW_ON_ERROR | ($pretty ? \JSON_PRETTY_PRINT : 0)); + return json_encode($mapping, flags: JSON_THROW_ON_ERROR | ($pretty ? JSON_PRETTY_PRINT : 0)); } /** @@ -146,9 +153,9 @@ public function compile(bool $pretty = false): string * * @throws JsonException */ - public function save(string $file, int $flags = 0, mixed $context = null): false|int + public function save(string $file, int $flags = 0, mixed $context = null): false | int { - return \file_put_contents($file, $this->compile(), $flags, $context); + return file_put_contents($file, $this->compile(), $flags, $context); } /** @@ -158,7 +165,7 @@ public function save(string $file, int $flags = 0, mixed $context = null): false */ public static function create(): MimeMappingBuilder { - return self::load(\dirname(__DIR__) . '/dist/mime.types.min.json'); + return self::load(dirname(__DIR__) . '/dist/mime.types.min.json'); } /** @@ -173,9 +180,9 @@ public static function load(string $file): MimeMappingBuilder { try { /** @var string $json **/ - $json = \file_get_contents($file); + $json = file_get_contents($file); /** @var MimeTypeMap **/ - $json = \json_decode($json, true, flags: \JSON_THROW_ON_ERROR); + $json = json_decode($json, true, flags: JSON_THROW_ON_ERROR); return new self($json); } catch (Throwable $e) { diff --git a/src/MimeMappingGenerator.php b/src/MimeMappingGenerator.php index b92f6ad..a3fccf7 100644 --- a/src/MimeMappingGenerator.php +++ b/src/MimeMappingGenerator.php @@ -12,8 +12,15 @@ */ namespace Esi\Mimey; +// Exceptions use JsonException; +// Functions & constants +use function preg_replace, ucfirst, ucwords, str_replace, sprintf, file_get_contents, dirname; +use function json_encode, array_unique, trim, explode, count, array_values, array_filter; + +use const JSON_THROW_ON_ERROR, JSON_PRETTY_PRINT; + /** * Mimey - PHP package for converting file extensions to MIME types and vice versa. * @@ -99,27 +106,27 @@ public function generateMapping(): array return $this->mapCache; } - $lines = \explode("\n", $this->mimeTypesText); + $lines = explode("\n", $this->mimeTypesText); foreach ($lines as $line) { /** @var string $line **/ - $line = \preg_replace('~\\#.*~', '', $line); - $line = \trim($line); + $line = preg_replace('~\\#.*~', '', $line); + $line = trim($line); - $parts = $line ? \array_values(\array_filter(\explode("\t", $line))) : []; + $parts = $line !== '' ? array_values(array_filter(explode("\t", $line))) : []; - if (\count($parts) === 2) { - $mime = \trim($parts[0]); - $extensions = \explode(' ', $parts[1]); + if (count($parts) === 2) { + $mime = trim($parts[0]); + $extensions = explode(' ', $parts[1]); foreach ($extensions as $extension) { - $extension = \trim($extension); + $extension = trim($extension); - if ($mime && $extension) { + if ($mime !== '' && $extension !== '') { $this->mapCache['mimes'][$extension][] = $mime; $this->mapCache['extensions'][$mime][] = $extension; - $this->mapCache['mimes'][$extension] = \array_unique($this->mapCache['mimes'][$extension]); - $this->mapCache['extensions'][$mime] = \array_unique($this->mapCache['extensions'][$mime]); + $this->mapCache['mimes'][$extension] = array_unique($this->mapCache['mimes'][$extension]); + $this->mapCache['extensions'][$mime] = array_unique($this->mapCache['extensions'][$mime]); } } } @@ -137,7 +144,7 @@ public function generateMapping(): array */ public function generateJson(bool $minify = true): string { - return \json_encode($this->generateMapping(), \JSON_THROW_ON_ERROR | ($minify ? 0 : \JSON_PRETTY_PRINT)); + return json_encode($this->generateMapping(), flags: JSON_THROW_ON_ERROR | ($minify ? 0 : JSON_PRETTY_PRINT)); } /** @@ -152,14 +159,14 @@ public function generatePhpEnum(string $classname = 'MimeType', string $namespac $values = [ 'namespace' => $namespace, 'classname' => $classname, - 'interface_usage' => $namespace !== __NAMESPACE__ ? ("use " . MimeTypeInterface::class . ";\n") : '', + 'interface_usage' => $namespace !== __NAMESPACE__ ? ('use ' . MimeTypeInterface::class . ";\n") : '', 'cases' => '', 'type2ext' => '', - 'ext2type' => '', + 'ext2type' => '' ]; /** @var string $stub **/ - $stub = \file_get_contents(\dirname(__DIR__) . '/stubs/mimeType.php.stub'); + $stub = file_get_contents(dirname(__DIR__) . '/stubs/mimeType.php.stub'); $mapping = $this->generateMapping(); $nameMap = []; @@ -167,16 +174,16 @@ public function generatePhpEnum(string $classname = 'MimeType', string $namespac foreach ($mapping['extensions'] as $mime => $extensions) { /** @phpstan-ignore-line */ $nameMap[$mime] = $this->convertMimeTypeToCaseName($mime); - $values['cases'] .= \sprintf(" case %s = '%s';\n", $nameMap[$mime], $mime); - $values['type2ext'] .= \sprintf(" self::%s => '%s',\n", $nameMap[$mime], $extensions[0]); + $values['cases'] .= sprintf(" case %s = '%s';\n", $nameMap[$mime], $mime); + $values['type2ext'] .= sprintf(" self::%s => '%s',\n", $nameMap[$mime], $extensions[0]); } foreach ($mapping['mimes'] as $extension => $mimes) { /** @phpstan-ignore-line */ - $values['ext2type'] .= \sprintf(" '%s' => self::%s,\n", $extension, $nameMap[$mimes[0]]); + $values['ext2type'] .= sprintf(" '%s' => self::%s,\n", $extension, $nameMap[$mimes[0]]); } foreach ($values as $name => $value) { - $stub = \str_replace("%$name%", $value, $stub); + $stub = str_replace("%$name%", $value, $stub); } return $stub; } @@ -188,6 +195,6 @@ public function generatePhpEnum(string $classname = 'MimeType', string $namespac protected function convertMimeTypeToCaseName(string $mimeType): string { /** @phpstan-ignore-next-line */ - return \preg_replace('/([\/\-_+.]+)/', '', \ucfirst(\ucwords($mimeType, '/-_+.'))); + return preg_replace('/([\/\-_+.]+)/', '', ucfirst(ucwords($mimeType, '/-_+.'))); } } diff --git a/src/MimeTypes.php b/src/MimeTypes.php index 959bb44..0f80b80 100644 --- a/src/MimeTypes.php +++ b/src/MimeTypes.php @@ -12,9 +12,15 @@ */ namespace Esi\Mimey; +// Classes use JetBrains\PhpStorm\Pure; -use RuntimeException; -use Throwable; + +// Exceptions +use RuntimeException, Throwable; + +// Functions & constants +use function dirname, file_get_contents, json_decode, trim, function_exists, strtolower; +use const JSON_THROW_ON_ERROR; /** * Mimey - PHP package for converting file extensions to MIME types and vice versa. @@ -101,11 +107,7 @@ class MimeTypes implements MimeTypesInterface */ public function __construct(?array $mapping = null) { - if ($mapping === null) { - $this->mapping = self::getBuiltIn(); - } else { - $this->mapping = $mapping; - } + $this->mapping = $mapping ?? self::getBuiltIn(); } #[Pure] @@ -113,7 +115,7 @@ public function getMimeType(string $extension): ?string { $extension = $this->cleanInput($extension); - if (!empty($this->mapping['mimes'][$extension])) { + if (isset($this->mapping['mimes'][$extension])) { return $this->mapping['mimes'][$extension][0]; /** @phpstan-ignore-line */ } return null; @@ -124,7 +126,7 @@ public function getExtension(string $mimeType): ?string { $mimeType = $this->cleanInput($mimeType); - if (!empty($this->mapping['extensions'][$mimeType])) { + if (isset($this->mapping['extensions'][$mimeType])) { return $this->mapping['extensions'][$mimeType][0]; /** @phpstan-ignore-line */ } return null; @@ -154,14 +156,14 @@ public function getAllExtensions(string $mimeType): array protected static function getBuiltIn(): array { if (self::$builtIn === null) { - $builtInTypes = \dirname(__DIR__) . '/dist/mime.types.min.json'; + $builtInTypes = dirname(__DIR__) . '/dist/mime.types.min.json'; try { /** @var string $json **/ - $json = \file_get_contents($builtInTypes); + $json = file_get_contents($builtInTypes); /** @var MimeTypeMap $json **/ - $json = \json_decode($json, true, flags: \JSON_THROW_ON_ERROR); + $json = json_decode($json, true, flags: JSON_THROW_ON_ERROR); self::$builtIn = $json; } catch (Throwable $e) { @@ -180,13 +182,13 @@ protected static function getBuiltIn(): array */ private function cleanInput(string $input): string { - $input = \trim($input); + $input = trim($input); //@codeCoverageIgnoreStart - if (\function_exists('mb_strtolower')) { + if (function_exists('mb_strtolower')) { $input = \mb_strtolower($input); } else { - $input = \strtolower($input); + $input = strtolower($input); } //@codeCoverageIgnoreEnd return $input; diff --git a/stubs/mimeType.php.stub b/stubs/mimeType.php.stub index 6d8a554..0b808b0 100644 --- a/stubs/mimeType.php.stub +++ b/stubs/mimeType.php.stub @@ -1,5 +1,8 @@ getMapping()); - $this->assertEquals('bar', $mime->getExtension('foo/bar')); - $this->assertEquals(['bar', 'foobar'], $mime->getAllExtensions('foo/bar')); - $this->assertEquals('foobaz', $mime->getExtension('foo/baz')); - $this->assertEquals(['foobaz'], $mime->getAllExtensions('foo/baz')); - $this->assertEquals('foo/bar', $mime->getMimeType('foobar')); - $this->assertEquals(['foo/bar'], $mime->getAllMimeTypes('foobar')); - $this->assertEquals('foo/bar', $mime->getMimeType('bar')); - $this->assertEquals(['foo/bar'], $mime->getAllMimeTypes('bar')); - $this->assertEquals('foo/baz', $mime->getMimeType('foobaz')); - $this->assertEquals(['foo/baz'], $mime->getAllMimeTypes('foobaz')); + self::assertEquals('bar', $mime->getExtension('foo/bar')); + self::assertEquals(['bar', 'foobar'], $mime->getAllExtensions('foo/bar')); + self::assertEquals('foobaz', $mime->getExtension('foo/baz')); + self::assertEquals(['foobaz'], $mime->getAllExtensions('foo/baz')); + self::assertEquals('foo/bar', $mime->getMimeType('foobar')); + self::assertEquals(['foo/bar'], $mime->getAllMimeTypes('foobar')); + self::assertEquals('foo/bar', $mime->getMimeType('bar')); + self::assertEquals(['foo/bar'], $mime->getAllMimeTypes('bar')); + self::assertEquals('foo/baz', $mime->getMimeType('foobaz')); + self::assertEquals(['foo/baz'], $mime->getAllMimeTypes('foobaz')); } /** @@ -88,20 +99,20 @@ public function testFromBuiltIn(): void $builder = MimeMappingBuilder::create(); $mime1 = new MimeTypes($builder->getMapping()); - $this->assertEquals('json', $mime1->getExtension('application/json')); - $this->assertEquals('application/json', $mime1->getMimeType('json')); + self::assertEquals('json', $mime1->getExtension('application/json')); + self::assertEquals('application/json', $mime1->getMimeType('json')); $builder->add('application/json', 'mycustomjson'); $mime2 = new MimeTypes($builder->getMapping()); - $this->assertEquals('mycustomjson', $mime2->getExtension('application/json')); - $this->assertEquals('application/json', $mime2->getMimeType('json')); + self::assertEquals('mycustomjson', $mime2->getExtension('application/json')); + self::assertEquals('application/json', $mime2->getMimeType('json')); $builder->add('application/mycustomjson', 'json'); $mime3 = new MimeTypes($builder->getMapping()); - $this->assertEquals('mycustomjson', $mime3->getExtension('application/json')); - $this->assertEquals('application/mycustomjson', $mime3->getMimeType('json')); + self::assertEquals('mycustomjson', $mime3->getExtension('application/json')); + self::assertEquals('application/mycustomjson', $mime3->getMimeType('json')); } /** @@ -114,7 +125,7 @@ public function testAppendExtension(): void $builder->add('foo/bar', 'bar', false); $mime = new MimeTypes($builder->getMapping()); - $this->assertEquals('foobar', $mime->getExtension('foo/bar')); + self::assertEquals('foobar', $mime->getExtension('foo/bar')); } /** @@ -127,18 +138,18 @@ public function testAppendMime(): void $builder->add('foo/bar2', 'foobar', true, false); $mime = new MimeTypes($builder->getMapping()); - $this->assertEquals('foo/bar', $mime->getMimeType('foobar')); + self::assertEquals('foo/bar', $mime->getMimeType('foobar')); } /** * Test saving the mapping to a file. * - * @throws \JsonException + * @throws JsonException */ public function testSave(): void { /** @var string $file **/ - $file = \tempnam(\sys_get_temp_dir(), 'mapping_test'); + $file = tempnam(sys_get_temp_dir(), 'mapping_test'); $builder = MimeMappingBuilder::blank(); $builder->add('foo/one', 'one'); @@ -148,30 +159,30 @@ public function testSave(): void $builder->save($file); /** @var string $json **/ - $json = \file_get_contents($file); + $json = file_get_contents($file); - $mappingIncluded = \json_decode($json, true, flags: \JSON_THROW_ON_ERROR); - $this->assertEquals($builder->getMapping(), $mappingIncluded); + $mappingIncluded = json_decode($json, true, flags: JSON_THROW_ON_ERROR); + self::assertEquals($builder->getMapping(), $mappingIncluded); $builder2 = MimeMappingBuilder::load($file); - \unlink($file); + unlink($file); - $this->assertEquals($builder->getMapping(), $builder2->getMapping()); + self::assertEquals($builder->getMapping(), $builder2->getMapping()); } /** * Test loading a mapping file that contains invalid JSON. * - * @throws \JsonException + * @throws JsonException */ public function testLoadInvalid(): void { /** @var string $file **/ - $file = \tempnam(\sys_get_temp_dir(), 'mapping_test'); - \file_put_contents($file, 'invalid json'); + $file = tempnam(sys_get_temp_dir(), 'mapping_test'); + file_put_contents($file, 'invalid json'); - $this->expectException(RuntimeException::class); + self::expectException(RuntimeException::class); MimeMappingBuilder::load($file); } } diff --git a/tests/src/MimeMappingGeneratorTest.php b/tests/src/MimeMappingGeneratorTest.php index 86b20b9..5956baf 100644 --- a/tests/src/MimeMappingGeneratorTest.php +++ b/tests/src/MimeMappingGeneratorTest.php @@ -12,8 +12,12 @@ */ namespace Esi\Mimey\Tests; +// Core classes use Esi\Mimey\MimeMappingGenerator; + +// PHPUnit use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** * Mimey - PHP package for converting file extensions to MIME types and vice versa. @@ -52,6 +56,7 @@ * Elephox\Mimey is a fork of ralouphie/mimey (https://github.com/ralouphie/mimey) which is: * Copyright (c) 2016 Ralph Khattar */ +#[CoversClass(MimeMappingGenerator::class)] class MimeMappingGeneratorTest extends TestCase { /** @@ -84,7 +89,7 @@ public function testGenerateMapping(): void 'qux' => ['bar'], ], ]; - $this->assertEquals($expected, $mapping); + self::assertEquals($expected, $mapping); } /** @@ -149,6 +154,9 @@ public function testGeneratePhpEnum(): void self::assertEquals(<<assertEquals($expectedMimeType, $this->mime->getMimeType($extension)); + self::assertEquals($expectedMimeType, $this->mime->getMimeType($extension)); } /** @@ -129,11 +143,13 @@ public static function getExtensionProvider(): array /** * Tests retrieving an extension based on mime type. * - * @dataProvider getExtensionProvider + * @param string $expectedExtension + * @param string $mimeType */ + #[DataProvider('getExtensionProvider')] public function testGetExtension(string $expectedExtension, string $mimeType): void { - $this->assertEquals($expectedExtension, $this->mime->getExtension($mimeType)); + self::assertEquals($expectedExtension, $this->mime->getExtension($mimeType)); } /** @@ -165,14 +181,13 @@ public static function getAllMimeTypesProvider(): array /** * Tests retrieving all mime types for a given extension. * - * @dataProvider getAllMimeTypesProvider - * * @param array|string>> $expectedMimeTypes - * + * @param string $extension */ + #[DataProvider('getAllMimeTypesProvider')] public function testGetAllMimeTypes(array $expectedMimeTypes, string $extension): void { - $this->assertEquals($expectedMimeTypes, $this->mime->getAllMimeTypes($extension)); + self::assertEquals($expectedMimeTypes, $this->mime->getAllMimeTypes($extension)); } /** @@ -201,13 +216,13 @@ public static function getAllExtensionsProvider(): array /** * Tests retrieving all extensions for a given mime type. * - * @dataProvider getAllExtensionsProvider - * * @param array|string>> $expectedExtensions + * @param string $mimeType */ + #[DataProvider('getAllExtensionsProvider')] public function testGetAllExtensions(array $expectedExtensions, string $mimeType): void { - $this->assertEquals($expectedExtensions, $this->mime->getAllExtensions($mimeType)); + self::assertEquals($expectedExtensions, $this->mime->getAllExtensions($mimeType)); } /** @@ -215,7 +230,7 @@ public function testGetAllExtensions(array $expectedExtensions, string $mimeType */ public function testGetMimeTypeUndefined(): void { - $this->assertNull($this->mime->getMimeType('undefined')); + self::assertNull($this->mime->getMimeType('undefined')); } /** @@ -223,7 +238,7 @@ public function testGetMimeTypeUndefined(): void */ public function testGetExtensionUndefined(): void { - $this->assertNull($this->mime->getExtension('undefined')); + self::assertNull($this->mime->getExtension('undefined')); } /** @@ -231,7 +246,7 @@ public function testGetExtensionUndefined(): void */ public function testGetAllMimeTypesUndefined(): void { - $this->assertEquals([], $this->mime->getAllMimeTypes('undefined')); + self::assertEquals([], $this->mime->getAllMimeTypes('undefined')); } /** @@ -239,7 +254,7 @@ public function testGetAllMimeTypesUndefined(): void */ public function testGetAllExtensionsUndefined(): void { - $this->assertEquals([], $this->mime->getAllExtensions('undefined')); + self::assertEquals([], $this->mime->getAllExtensions('undefined')); } /** @@ -248,30 +263,30 @@ public function testGetAllExtensionsUndefined(): void public function testBuiltInMapping(): void { $mime = new MimeTypes(); - $this->assertEquals('json', $mime->getExtension('application/json')); - $this->assertEquals('application/json', $mime->getMimeType('json')); + self::assertEquals('json', $mime->getExtension('application/json')); + self::assertEquals('application/json', $mime->getMimeType('json')); } /** - * Test behavior basedon invalid built in mapping. + * Test behavior based on invalid built in mapping. */ public function testInvalidBuiltInMapping(): void { - $original = \dirname(__DIR__, 2) . '/dist/mime.types.min.json'; - $backup = \dirname(__DIR__, 2) . '/dist/mime.types.min.json.backup'; + $original = dirname(__DIR__, 2) . '/dist/mime.types.min.json'; + $backup = dirname(__DIR__, 2) . '/dist/mime.types.min.json.backup'; - \rename($original, $backup); - \file_put_contents($original, 'invalid json'); + rename($original, $backup); + file_put_contents($original, 'invalid json'); $class = new ReflectionClass(MimeTypes::class); $class->setStaticPropertyValue('builtIn', null); try { - $this->expectException(RuntimeException::class); + self::expectException(RuntimeException::class); new MimeTypes(); } finally { - \unlink($original); - \rename($backup, $original); + unlink($original); + rename($backup, $original); } } }