Skip to content

Commit

Permalink
chore: make classes readonly+final where applicable
Browse files Browse the repository at this point in the history
All classes are now final + readonly, except `MediaTypeParserException` which is only final since `Exception` is not readonly.
  • Loading branch information
neoncitylights committed Dec 11, 2023
1 parent 0314190 commit 4409a42
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/MediaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@
* @see https://mimesniff.spec.whatwg.org/
* @license MIT
*/
class MediaType implements Stringable {
final readonly class MediaType implements Stringable {
/**
* @see https://mimesniff.spec.whatwg.org/#type
* @var string
*/
private $type;
private string $type;

/**
* @see https://mimesniff.spec.whatwg.org/#subtype
* @var string
*/
private $subType;
private string $subType;

/**
* @see https://mimesniff.spec.whatwg.org/#parameters
* @var string[]
*/
private $parameters;
private array $parameters;

/**
* @param string $type
Expand Down
2 changes: 1 addition & 1 deletion src/MediaTypeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* @see https://mimesniff.spec.whatwg.org/#parsing-a-mime-type
*/
class MediaTypeParser {
final readonly class MediaTypeParser {
public function parseOrNull( string $s ): MediaType|null {
try {
return $this->parse( $s );
Expand Down
2 changes: 1 addition & 1 deletion src/MediaTypeParserException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
/**
* @license MIT
*/
class MediaTypeParserException extends Exception {
final class MediaTypeParserException extends Exception {
}
2 changes: 1 addition & 1 deletion src/Utf8Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @internal
* @license MIT
*/
class Utf8Utils {
final readonly class Utf8Utils {
public static function onlyContains( string $input, callable $predicateFn ): bool {
if ( $input === '' ) {
return true;
Expand Down

0 comments on commit 4409a42

Please sign in to comment.