MediaTypeParser::parseOrNull()
,MediaTypeParse::parse()
now also accepts passingnull
values as an argument. The new argument type for both methods is nowstring|null
.
- Fixes minor bug in
MediaType::isFont()
method; it will now correctly returntrue
for media types that have an essence ofapplication/vnd.ms-opentype
.
MediaTypeParser::parse()
is deprecated and renamed toMediaTypeParser::parseOrThrow()
, to be more explicit that it can throw exceptions. CallMediaTypeParser::parseOrThrow()
instead.
- The developer dependency
mediawiki/mediawiki-codesniffer
was bumped from v43.0.0 to v45.0.0. - The developer dependency
mediawiki/minus-x
was bumped from v1.1.1 to v1.1.3. - The developer dependency
phpunit/phpunit
was bumped from v11.0.8 to v11.5.1.
- The library now requires PHP 8.2+ (originally 8.1+). This breaking change comes from bumping the developer dependency PHPUnit from v9 to v11.
- The
README.md
file now includes usage examples for serialization and matching. (#49)
- Simplify number of jobs in main CI workflow (#48)
- Refactors
MediaType
class internally by factoring out subtype matching (#45) - Bumps
mediawiki/mediawiki-codesniffer
developer dependency fromv42.0.0
tov43.0.0
. (#38) - Bumps
php-parallel-lint/php-parallel-lint
developer dependency from1.3.2
tov1.4.0
. (#47) - Bumps
phpunit/phpunit
developer dependency fromv9.6.15
tov11.0.8
. (#46)
MediaType
now has a new method,minimize( $isSupported )
. This method allows returning a consistent essence as a string, depending on what category the media type is and whether the user agent supports the media type. For example, if the media type is a JavaScript type, then it will consistently return"text/javascript"
.
- Fixes minor phpDoc annotation issues within
MediaType
. Specifically:- Removes redundant
@return
annotations that are already specified from return typehints - Removes redundant
@param
annotation fromgetParameterValue()
- Adds missing
@see
annotation toisAudioOrVideo()
method in reference to a WHATWG Standard link
- Removes redundant
MediaTypeParser
is a new parser that is more compliant to WHATWG Mime Sniffing Standard. The following differences include:- validates for Unicode ranges of HTTP codepoints and HTTP quoted-string codepoints
- normalizes the type and subtype to ASCII lowercase
- is more forgiving with surrounding HTTP whitespace codepoints
- accounts for HTTP-quoted strings in parameter values, and normalizes such values
- will error out when the type or subtype is empty
MediaType
now implements the nativeStringable
interface (introduced by PHP 8.1).MediaType
now includes built-in predicate methods for checking what group the media type belongs to:isImage()
isAudioOrVideo()
isFont()
isZipBased()
isArchive()
isXml()
isHtml()
isScriptable()
isJavaScript()
isJson()
MediaType::__toString()
now correctly serializes HTTP parameter values that contain HTTP-quoted strings.
- The package now requires PHP 8.1 or higher, and the native
intl
extension. - The following classes are now marked as
final
:MediaType
MediaTypeParser
MediaTypeParseException
- The
MediaType
class now has public and readonly properties. Access these instead:$mediaType->type
replacesMediaType->getType()
(removed)$mediaType->subType
replacesMediaType->getSubType()
(removed)$mediaType->parameters
replacesMediaType->getParameters()
(removed)
MediaType::newFromString()
is removed. Instead, create a newMediaTypeParser
instance and callparseOrNull()
.
- The
Utf8Utils
class andToken
enum are internal, and therefore not part of the public API. They may be changed or removed at any time.
- First release