diff --git a/.github/dependabot.yml b/.github/dependabot.yml index bd149a3..c724c18 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,9 +11,6 @@ updates: interval: "weekly" commit-message: prefix: "chore(deps/composer):" - labels: - - "t-dependencies" - - "pkg-composer" groups: mediawiki: patterns: @@ -33,7 +30,4 @@ updates: interval: "weekly" commit-message: prefix: "chore(deps/actions):" - labels: - - "t-dependencies" - - "pkg-gh-actions" open-pull-requests-limit: 4 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1512c42 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + +## Unreleased diff --git a/composer.json b/composer.json index b27aa64..71ac994 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ } }, "require": { - "neoncitylights/media-type": "^1.0", + "neoncitylights/media-type": "^3.0.0", "php": ">= 8.1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index a0e098f..d918fbc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,28 +4,33 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "18d31557766dee77a8393592798a0a16", + "content-hash": "dcec526db95ae5957268be93553fa2cc", "packages": [ { "name": "neoncitylights/media-type", - "version": "v1.0.0", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/neoncitylights/php-media-type.git", - "reference": "ee955fc1e9ec956e94089cabf2fb913b801f9641" + "reference": "94e102d5a996d4ac9f8f7cf84da5cd3b65040cda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/neoncitylights/php-media-type/zipball/ee955fc1e9ec956e94089cabf2fb913b801f9641", - "reference": "ee955fc1e9ec956e94089cabf2fb913b801f9641", + "url": "https://api.github.com/repos/neoncitylights/php-media-type/zipball/94e102d5a996d4ac9f8f7cf84da5cd3b65040cda", + "reference": "94e102d5a996d4ac9f8f7cf84da5cd3b65040cda", "shasum": "" }, + "require": { + "ext-intl": "*", + "php": ">=8.2", + "wikimedia/assert": "^0.5.1" + }, "require-dev": { - "mediawiki/mediawiki-codesniffer": "32.0.0", - "mediawiki/minus-x": "1.1.0", - "php-parallel-lint/php-console-highlighter": "0.5.0", - "php-parallel-lint/php-parallel-lint": "1.2.0", - "phpunit/phpunit": "^9.4" + "mediawiki/mediawiki-codesniffer": "43.0.0", + "mediawiki/minus-x": "1.1.1", + "php-parallel-lint/php-console-highlighter": "1.0.0", + "php-parallel-lint/php-parallel-lint": "1.4.0", + "phpunit/phpunit": "11.0.8" }, "type": "library", "autoload": { @@ -42,12 +47,76 @@ "name": "Samantha Nguyen" } ], - "description": "Allows working with INAN media types as entities in PHP", + "description": "Allows working with IANA media types as entities in PHP", "support": { "issues": "https://github.com/neoncitylights/php-media-type/issues", - "source": "https://github.com/neoncitylights/php-media-type/tree/v1.0.0" + "source": "https://github.com/neoncitylights/php-media-type/tree/v3.0.0" + }, + "funding": [ + { + "url": "https://github.com/sponsors/neoncitylights", + "type": "github" + } + ], + "time": "2024-04-04T01:23:27+00:00" + }, + { + "name": "wikimedia/assert", + "version": "v0.5.1", + "source": { + "type": "git", + "url": "https://github.com/wikimedia/Assert.git", + "reference": "27c983fddac1197dc37f6a7cec00fc02861529cd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wikimedia/Assert/zipball/27c983fddac1197dc37f6a7cec00fc02861529cd", + "reference": "27c983fddac1197dc37f6a7cec00fc02861529cd", + "shasum": "" + }, + "require": { + "php": ">=7.2.9" + }, + "require-dev": { + "mediawiki/mediawiki-codesniffer": "38.0.0", + "mediawiki/minus-x": "1.1.1", + "ockcyp/covers-validator": "1.3.3", + "php-parallel-lint/php-console-highlighter": "0.5.0", + "php-parallel-lint/php-parallel-lint": "1.3.1", + "phpunit/phpunit": "^8.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Wikimedia\\Assert\\": "src/" + } }, - "time": "2020-10-28T19:03:15+00:00" + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniel Kinzler" + }, + { + "name": "Thiemo Kreuz" + } + ], + "description": "Provides runtime assertions", + "homepage": "https://github.com/wikimedia/Assert", + "keywords": [ + "assert", + "assertions", + "php", + "postcondition", + "precondition", + "qa" + ], + "support": { + "source": "https://github.com/wikimedia/Assert/tree/v0.5.1" + }, + "time": "2021-12-21T11:46:59+00:00" } ], "packages-dev": [ @@ -465,16 +534,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.1", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", "shasum": "" }, "require": { @@ -482,11 +551,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", @@ -512,7 +582,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" }, "funding": [ { @@ -520,20 +590,20 @@ "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2024-11-08T17:47:46+00:00" }, { "name": "nikic/php-parser", - "version": "v5.0.2", + "version": "v5.3.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13" + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/139676794dc1e9231bf7bcd123cfc0c99182cb13", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", "shasum": "" }, "require": { @@ -544,7 +614,7 @@ }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, "bin": [ "bin/php-parse" @@ -576,9 +646,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" }, - "time": "2024-03-05T20:51:40+00:00" + "time": "2024-10-08T18:51:32+00:00" }, { "name": "ockcyp/covers-validator", @@ -1083,35 +1153,35 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.31", + "version": "9.2.32", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.18 || ^5.0", + "nikic/php-parser": "^4.19.1 || ^5.1.0", "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.6" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -1120,7 +1190,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-main": "9.2.x-dev" } }, "autoload": { @@ -1149,7 +1219,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/9.2.31" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" }, "funding": [ { @@ -1157,7 +1227,7 @@ "type": "github" } ], - "time": "2024-03-02T06:37:42+00:00" + "time": "2024-08-22T04:23:01+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2601,16 +2671,16 @@ }, { "name": "symfony/console", - "version": "v6.4.7", + "version": "v6.4.15", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "a170e64ae10d00ba89e2acbb590dc2e54da8ad8f" + "reference": "f1fc6f47283e27336e7cebb9e8946c8de7bff9bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/a170e64ae10d00ba89e2acbb590dc2e54da8ad8f", - "reference": "a170e64ae10d00ba89e2acbb590dc2e54da8ad8f", + "url": "https://api.github.com/repos/symfony/console/zipball/f1fc6f47283e27336e7cebb9e8946c8de7bff9bd", + "reference": "f1fc6f47283e27336e7cebb9e8946c8de7bff9bd", "shasum": "" }, "require": { @@ -2675,7 +2745,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.7" + "source": "https://github.com/symfony/console/tree/v6.4.15" }, "funding": [ { @@ -2691,20 +2761,20 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-11-06T14:19:14+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", "shasum": "" }, "require": { @@ -2742,7 +2812,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" }, "funding": [ { @@ -2758,24 +2828,24 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.29.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-ctype": "*" @@ -2786,8 +2856,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -2821,7 +2891,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" }, "funding": [ { @@ -2837,24 +2907,24 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.29.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "suggest": { "ext-intl": "For best performance" @@ -2862,8 +2932,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -2899,7 +2969,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0" }, "funding": [ { @@ -2915,24 +2985,24 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.29.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" + "reference": "3833d7255cc303546435cb650316bff708a1c75c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c", + "reference": "3833d7255cc303546435cb650316bff708a1c75c", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "suggest": { "ext-intl": "For best performance" @@ -2940,8 +3010,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -2980,7 +3050,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0" }, "funding": [ { @@ -2996,24 +3066,24 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.29.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-mbstring": "*" @@ -3024,8 +3094,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -3060,7 +3130,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" }, "funding": [ { @@ -3076,7 +3146,7 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-php80", @@ -3098,8 +3168,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -3160,16 +3230,16 @@ }, { "name": "symfony/service-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/e53260aabf78fb3d63f8d79d69ece59f80d5eda0", + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0", "shasum": "" }, "require": { @@ -3223,7 +3293,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.5.1" }, "funding": [ { @@ -3239,24 +3309,24 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/string", - "version": "v6.4.7", + "version": "v7.2.0", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "ffeb9591c61f65a68d47f77d12b83fa530227a69" + "reference": "446e0d146f991dde3e73f45f2c97a9faad773c82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/ffeb9591c61f65a68d47f77d12b83fa530227a69", - "reference": "ffeb9591c61f65a68d47f77d12b83fa530227a69", + "url": "https://api.github.com/repos/symfony/string/zipball/446e0d146f991dde3e73f45f2c97a9faad773c82", + "reference": "446e0d146f991dde3e73f45f2c97a9faad773c82", "shasum": "" }, "require": { - "php": ">=8.1", + "php": ">=8.2", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", @@ -3266,11 +3336,12 @@ "symfony/translation-contracts": "<2.5" }, "require-dev": { - "symfony/error-handler": "^5.4|^6.0|^7.0", - "symfony/http-client": "^5.4|^6.0|^7.0", - "symfony/intl": "^6.2|^7.0", + "symfony/emoji": "^7.1", + "symfony/error-handler": "^6.4|^7.0", + "symfony/http-client": "^6.4|^7.0", + "symfony/intl": "^6.4|^7.0", "symfony/translation-contracts": "^2.5|^3.0", - "symfony/var-exporter": "^5.4|^6.0|^7.0" + "symfony/var-exporter": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -3309,7 +3380,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.7" + "source": "https://github.com/symfony/string/tree/v7.2.0" }, "funding": [ { @@ -3325,7 +3396,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-11-13T13:31:26+00:00" }, { "name": "theseer/tokenizer", @@ -3380,12 +3451,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { "php": ">= 8.1" }, - "platform-dev": [], + "platform-dev": {}, "plugin-api-version": "2.6.0" } diff --git a/src/DataUrlParser.php b/src/DataUrlParser.php index 99422d5..dc5b1a2 100644 --- a/src/DataUrlParser.php +++ b/src/DataUrlParser.php @@ -3,6 +3,8 @@ namespace Neoncitylights\DataUrl; use Neoncitylights\MediaType\MediaType; +use Neoncitylights\MediaType\MediaTypeParser; +use Neoncitylights\MediaType\MediaTypeParserException; use function is_int; use function strlen; use function strrpos; @@ -21,12 +23,32 @@ * @license MIT */ class DataUrlParser { + private MediaTypeParser $mediaTypeParser; + + public function __construct( ?MediaTypeParser $mediaTypeParser ) { + $this->mediaTypeParser = $mediaTypeParser ?? new MediaTypeParser(); + } + + public function parseOrNull( string $dataUrl ): DataUrl|null { + try { + return $this->parseOrThrow( $dataUrl ); + } catch ( InvalidDataUrlSyntaxException | MediaTypeParserException $e ) { + return null; + } + } + /** - * @param string $dataUrl - * @return DataUrl - * @throws InvalidDataUrlSyntaxException + * @throws InvalidDataUrlSyntaxException|MediaTypeParserException + * @deprecated Call parseOrThrow() instead. */ public function parse( string $dataUrl ): DataUrl { + return $this->parseOrThrow( $dataUrl ); + } + + /** + * @throws InvalidDataUrlSyntaxException|MediaTypeParserException + */ + public function parseOrThrow( string $dataUrl ): DataUrl { $trimmedDataUrl = trim( $dataUrl ); if ( empty( $trimmedDataUrl ) ) { @@ -62,8 +84,7 @@ public function parse( string $dataUrl ): DataUrl { } /** - * @param string $content - * @return MediaType + * @throws MediaTypeParserException */ private function parseMediaTypeAndBase64( string $content ): MediaType { $base64ExtIndex = strrpos( $content, Token::Base64Ext->value ); @@ -76,14 +97,13 @@ private function parseMediaTypeAndBase64( string $content ): MediaType { } /** - * @param string $mediaTypeString - * @return MediaType + * @throws MediaTypeParserException */ private function getMediaType( string $mediaTypeString ): MediaType { if ( empty( $mediaTypeString ) ) { return new MediaType( 'text', 'plain', [ 'charset' => 'US-ASCII', ] ); } - return MediaType::newFromString( $mediaTypeString ); + return $this->mediaTypeParser->parse( $mediaTypeString ); } } diff --git a/tests/DataUrlParserTest.php b/tests/DataUrlParserTest.php deleted file mode 100644 index b35b854..0000000 --- a/tests/DataUrlParserTest.php +++ /dev/null @@ -1,85 +0,0 @@ -assertEqualsCanonicalizing( - $expectedDataUrlObject, - $parser->parse( $validDataUrl ) - ); - } - - /** - * @covers ::parse - * @covers \Neoncitylights\DataUrl\InvalidDataUrlSyntaxException - * @dataProvider provideInvalidDataUrls - */ - public function testParseInvalidDataUrls( $invalidDataUrl ) { - $this->expectException( InvalidDataUrlSyntaxException::class ); - - $parser = new DataUrlParser(); - $parser->parse( $invalidDataUrl ); - } - - public function provideValidTextBasedDataUrls() { - yield [ - new DataUrl( - new MediaType( 'text', 'plain', [ 'charset' => 'US-ASCII' ] ), - '' - ), - 'data:,', - ]; - yield [ - new DataUrl( - new MediaType( 'text', 'plain', [ 'charset' => 'US-ASCII' ] ), - '' - ), - " \n\r\t\0\x0Bdata:, \n\r\t\0\x0B", - ]; - yield [ - new DataUrl( - new MediaType( 'text', 'plain', [] ), - 'SGVsbG8sIFdvcmxkIQ==' - ), - "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==", - ]; - yield [ - new DataUrl( - new MediaType( - 'text', 'plain', - [ 'charset' => 'UTF-8' ] - ), - 'VGhlIGZpdmUgYm94aW5nIHdpemFyZHMganVtcCBxdWlja2x5Lg==' - ), - 'data:text/plain;charset=UTF-8;base64,VGhlIGZpdmUgYm94aW5nIHdpemFyZHMganVtcCBxdWlja2x5Lg==' - ]; - } - - public function provideInvalidDataUrls() { - yield [ '' ]; - yield [ ' \n\r\t\0\x0B' ]; - yield [ 'foo' ]; - yield [ 'data:test' ]; - } -} diff --git a/tests/DataUrlTest.php b/tests/DataUrlTest.php index 0036659..8fc4645 100644 --- a/tests/DataUrlTest.php +++ b/tests/DataUrlTest.php @@ -5,6 +5,7 @@ use Neoncitylights\DataUrl\DataUrl; use Neoncitylights\DataUrl\DataUrlParser; use Neoncitylights\MediaType\MediaType; +use Neoncitylights\MediaType\MediaTypeParser; use PHPUnit\Framework\TestCase; /** @@ -17,7 +18,9 @@ class DataUrlTest extends TestCase { private static $dataUrlParser; public static function setUpBeforeClass(): void { - self::$dataUrlParser = new DataUrlParser(); + self::$dataUrlParser = new DataUrlParser( + new MediaTypeParser() + ); } public static function tearDownAfterClass(): void {