Skip to content

Commit

Permalink
docs: fix minor phpDoc annotation issues within MediaType
Browse files Browse the repository at this point in the history
- Remove redundant `@return` annotations that are already specified by return typehint
- Add `@see` annotation for `isAudioOrVideo()` method for consistency with other methods
  • Loading branch information
neoncitylights committed Mar 27, 2024
1 parent 40a67da commit a6dfc94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

- `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"`.

### Documentation

- Fixes minor phpDoc annotation issues within `MediaType`. Specifically:
- Removes redundant `@return` annotations that are already specified from return typehints
- Adds missing `@see` annotation to `isAudioOrVideo()` method in reference to a WHATWG Standard link

## 2.0.0 (2023-12-11)

### Features
Expand Down
7 changes: 1 addition & 6 deletions src/MediaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public function __construct( string $type, string $subType, array $parameters )
* e.g, if given 'text/plain;charset=UTF-8', it will return 'text/plain'.
*
* @see https://mimesniff.spec.whatwg.org/#mime-type-essence
* @return string
*/
public function getEssence(): string {
return "{$this->type}/{$this->subType}";
Expand All @@ -66,7 +65,6 @@ public function getEssence(): string {
* given parameter is 'charset', it will return 'UTF-8'.
*
* @param string $parameterName
* @return string|null
*/
public function getParameterValue( string $parameterName ): ?string {
if ( !\array_key_exists( $parameterName, $this->parameters ) ) {
Expand All @@ -84,7 +82,7 @@ public function isImage(): bool {
}

/**
* https://mimesniff.spec.whatwg.org/#audio-or-video-mime-type
* @see https://mimesniff.spec.whatwg.org/#audio-or-video-mime-type
*/
public function isAudioOrVideo(): bool {
return $this->type === 'video'
Expand Down Expand Up @@ -136,8 +134,6 @@ public function isXml(): bool {

/**
* @see https://mimesniff.spec.whatwg.org/#html-mime-type
*
* @return bool
*/
public function isHtml(): bool {
return $this->getEssence() === 'text/html';
Expand Down Expand Up @@ -220,7 +216,6 @@ public function minimize( bool $isSupported ): string {

/**
* @see https://mimesniff.spec.whatwg.org/#serializing-a-mime-type
* @return string
*/
public function __toString(): string {
$essence = $this->getEssence();
Expand Down

0 comments on commit a6dfc94

Please sign in to comment.