Releases: php-lights/media-type
Releases · php-lights/media-type
v3.1.0
Features
MediaTypeParser::parseOrNull(),MediaTypeParse::parse()now also accepts passingnullvalues as an argument. The new argument type for both methods is nowstring|null.
Bug fixes
- Fixes minor bug in
MediaType::isFont()method; it will now correctly returntruefor media types that have an essence ofapplication/vnd.ms-opentype.
Deprecated
MediaTypeParser::parse()is deprecated and renamed toMediaTypeParser::parseOrThrow(), to be more explicit that it can throw exceptions. CallMediaTypeParser::parseOrThrow()instead.
Internal changes
- The developer dependency
mediawiki/mediawiki-codesnifferwas bumped from v43.0.0 to v45.0.0. - The developer dependency
mediawiki/minus-xwas bumped from v1.1.1 to v1.1.3. - The developer dependency
phpunit/phpunitwas bumped from v11.0.8 to v11.5.1.
v3.0.0
Breaking changes
- The library now requires PHP 8.2+ (originally 8.1+). This breaking change comes from bumping the developer dependency PHPUnit from v9 to v11.
Documentation
- The
README.mdfile now includes usage examples for serialization and matching. (#49)
Internal changes
- Simplify number of jobs in main CI workflow (#48)
- Refactors
MediaTypeclass internally by factoring out subtype matching (#45) - Bumps
mediawiki/mediawiki-codesnifferdeveloper dependency fromv42.0.0tov43.0.0. (#38) - Bumps
php-parallel-lint/php-parallel-lintdeveloper dependency from1.3.2tov1.4.0. (#47) - Bumps
phpunit/phpunitdeveloper dependency fromv9.6.15tov11.0.8. (#46)
v2.1.0
Features
MediaTypenow 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".
Documentation
- Fixes minor phpDoc annotation issues within
MediaType. Specifically:- Removes redundant
@returnannotations that are already specified from return typehints - Removes redundant
@paramannotation fromgetParameterValue() - Adds missing
@seeannotation toisAudioOrVideo()method in reference to a WHATWG Standard link
- Removes redundant
v2.0.0
Features
MediaTypeParseris 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
MediaTypenow implements the nativeStringableinterface (introduced by PHP 8.1).MediaTypenow includes built-in predicate methods for checking what group the media type belongs to:isImage()isAudioOrVideo()isFont()isZipBased()isArchive()isXml()isHtml()isScriptable()isJavaScript()isJson()
Bug fixes
MediaType::__toString()now correctly serializes HTTP parameter values that contain HTTP-quoted strings.
Breaking changes
- The package now requires PHP 8.1 or higher, and the native
intlextension. - The following classes are now marked as
final:MediaTypeMediaTypeParserMediaTypeParseException
- The
MediaTypeclass now has public and readonly properties. Access these instead:$mediaType->typereplacesMediaType->getType()(removed)$mediaType->subTypereplacesMediaType->getSubType()(removed)$mediaType->parametersreplacesMediaType->getParameters()(removed)
MediaType::newFromString()is removed. Instead, create a newMediaTypeParserinstance and callparseOrNull().
Notes
- The
Utf8Utilsclass andTokenenum are internal, and therefore not part of the public API. They may be changed or removed at any time.
v1.0.0
Initial source code commit