Skip to content

Commit

Permalink
Upgrade to php83
Browse files Browse the repository at this point in the history
Also update rector- and phpcsfixer-configs
  • Loading branch information
usox committed Nov 16, 2024
1 parent 51fb2d0 commit 1231248
Show file tree
Hide file tree
Showing 72 changed files with 351 additions and 344 deletions.
41 changes: 28 additions & 13 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(['src', 'tests'])
;
$config = new PhpCsFixer\Config();
$config->setRules(
[
'@PSR12' => true,
'@PHP80Migration' => true,
'array_syntax' => ['syntax' => 'short'],
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline', 'keep_multiple_spaces_after_comma' => false],
]
)->setFinder($finder);
declare(strict_types=1);

return $config;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

return (new PhpCsFixer\Config())
->setRules(
[
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline', 'keep_multiple_spaces_after_comma' => false],
'no_unused_imports' => true,
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => ['const', 'class', 'function'],
],
'fully_qualified_strict_types' => [
'import_symbols' => true,
],
'trailing_comma_in_multiline' => [
'after_heredoc' => true,
'elements' => ['array_destructuring', 'arrays', 'parameters', 'arguments'],
],
],
)
->setParallelConfig(ParallelConfigFactory::detect())
->setFinder(
PhpCsFixer\Finder::create()
->in(['src', 'tests'])
);
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"sort-packages": true
},
"require": {
"php": "^8.2 || ^8.3",
"php": "^8.3",
"ext-mbstring": "*",
"aaronddm/xml-builder": "^2.0",
"psr/http-message": "^1||^2"
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 23 additions & 12 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\Config\RectorConfig;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withRules([
InlineConstructorDefaultToPropertyRector::class,
])
->withPhpSets(php81: true)
->withPreparedSets(deadCode: true, codeQuality: true, codingStyle: true)
->withSkip([
FlipTypeControlToUseExclusiveTypeRector::class,
]);
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withRules([
InlineConstructorDefaultToPropertyRector::class,
])
->withPhpSets(php83: true)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
privatization: true,
earlyReturn: true,
strictBooleans: true,
phpunitCodeQuality: true,
)
->withSkip([
FlipTypeControlToUseExclusiveTypeRector::class,
AddOverrideAttributeToOverriddenMethodsRector::class,
]);
4 changes: 2 additions & 2 deletions src/Authentication/AuthenticationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
/**
* Manages the authentication of subsonic api requests
*/
final class AuthenticationManager implements AuthenticationManagerInterface
final readonly class AuthenticationManager implements AuthenticationManagerInterface
{
public function __construct(
private readonly AuthenticationProviderInterface $authenticationProvider,
private AuthenticationProviderInterface $authenticationProvider,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ interface AlbumDataProviderInterface extends V1161DataProviderInterface
* }
*/
public function getAlbum(
string $albumId
string $albumId,
): ?array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public function getAlbums(
int $limit,
int $offset,
array $orderParameter,
?string $musicFolderId
?string $musicFolderId,
): Traversable;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ interface ArtistDataProviderInterface extends V1161DataProviderInterface
* }
*/
public function getArtist(
string $artistId
string $artistId,
): ?array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public function getIgnoredArticles(): array;
* }>
*/
public function getArtists(
?string $musicFolderId
?string $musicFolderId,
): iterable;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public function getRandomSongs(
?int $limit = 10,
?string $genreName = null,
?int $fromYear = null,
?int $toYear = null
?int $toYear = null,
): Traversable;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ interface GetStarred2DataProviderInterface extends V1161DataProviderInterface
* }
*/
public function getStarred(
?string $musicFolderId
?string $musicFolderId,
): array;
}
24 changes: 12 additions & 12 deletions src/FeatureSet/V1161/FeatureSetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,40 @@ public function getMethods(): array
{
return [
'ping.view' => static fn (): Method\V1161MethodInterface => new Method\PingMethod(
new ResponderFactory()
new ResponderFactory(),
),
'getLicense.view' => static fn (): Method\V1161MethodInterface => new Method\GetLicenseMethod(
new ResponderFactory()
new ResponderFactory(),
),
'getAlbum.view' => static fn (): Method\V1161MethodInterface => new Method\GetAlbumMethod(
new ResponderFactory()
new ResponderFactory(),
),
'getAlbumList2.view' => static fn (): Method\V1161MethodInterface => new Method\GetAlbumList2Method(
new ResponderFactory()
new ResponderFactory(),
),
'getArtists.view' => static fn (): Method\V1161MethodInterface => new Method\GetArtistsMethod(
new ResponderFactory()
new ResponderFactory(),
),
'getCoverArt.view' => static fn (): Method\V1161MethodInterface => new Method\GetCoverArtMethod(
new ResponderFactory()
new ResponderFactory(),
),
'getArtist.view' => static fn (): Method\V1161MethodInterface => new Method\GetArtistMethod(
new ResponderFactory()
new ResponderFactory(),
),
'getGenres.view' => static fn (): Method\V1161MethodInterface => new Method\GetGenresMethod(
new ResponderFactory()
new ResponderFactory(),
),
'getMusicFolders.view' => static fn (): Method\V1161MethodInterface => new Method\GetMusicFoldersMethod(
new ResponderFactory()
new ResponderFactory(),
),
'stream.view' => static fn (): Method\V1161MethodInterface => new Method\StreamMethod(
new ResponderFactory()
new ResponderFactory(),
),
'getStarred2.view' => static fn (): Method\V1161MethodInterface => new Method\GetStarred2Method(
new ResponderFactory()
new ResponderFactory(),
),
'getRandomSongs.view' => static fn (): Method\V1161MethodInterface => new Method\GetRandomSongsMethod(
new ResponderFactory()
new ResponderFactory(),
),
];
}
Expand Down
18 changes: 9 additions & 9 deletions src/FeatureSet/V1161/Method/GetAlbumList2Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
*
* @see http://www.subsonic.org/pages/api.jsp#getAlbumList2
*/
final class GetAlbumList2Method implements V1161MethodInterface
final readonly class GetAlbumList2Method implements V1161MethodInterface
{
/**
* List of allowed types for ordering
*
* @var string[]
*/
private const ORDER_TYPES = [
private const array ORDER_TYPES = [
'random',
'newest',
'frequent',
Expand All @@ -42,15 +42,15 @@ final class GetAlbumList2Method implements V1161MethodInterface
/**
* @var int
*/
private const DEFAULT_LIMIT = 10;
private const int DEFAULT_LIMIT = 10;

/**
* @var int
*/
private const MAX_LIMIT = 500;
private const int MAX_LIMIT = 500;

public function __construct(
private readonly ResponderFactoryInterface $responderFactory,
private ResponderFactoryInterface $responderFactory,
) {
}

Expand All @@ -76,7 +76,7 @@ public function __invoke(

if (!in_array($type, self::ORDER_TYPES, true)) {
throw new MethodCallFailedException(
ErrorCodeEnum::MISSING_PARAMETER
ErrorCodeEnum::MISSING_PARAMETER,
);
}

Expand All @@ -88,7 +88,7 @@ public function __invoke(

if ($fromYear === null || $toYear === null) {
throw new MethodCallFailedException(
ErrorCodeEnum::MISSING_PARAMETER
ErrorCodeEnum::MISSING_PARAMETER,
);
}

Expand All @@ -99,7 +99,7 @@ public function __invoke(
$genre = $queryParams['genre'] ?? null;
if ($genre === null) {
throw new MethodCallFailedException(
ErrorCodeEnum::MISSING_PARAMETER
ErrorCodeEnum::MISSING_PARAMETER,
);
}

Expand All @@ -115,7 +115,7 @@ public function __invoke(
);

return $this->responderFactory->createAlbumList2Responder(
$this->transformAlbums($albumList)
$this->transformAlbums($albumList),
);
}

Expand Down
12 changes: 6 additions & 6 deletions src/FeatureSet/V1161/Method/GetAlbumMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*
* This class covers the `getAlbum.view` method
*/
final class GetAlbumMethod implements V1161MethodInterface
final readonly class GetAlbumMethod implements V1161MethodInterface
{
public function __construct(
private readonly ResponderFactoryInterface $responderFactory,
private ResponderFactoryInterface $responderFactory,
) {
}

Expand All @@ -39,7 +39,7 @@ public function __invoke(

if ($album === null) {
throw new MethodCallFailedException(
ErrorCodeEnum::NOT_FOUND
ErrorCodeEnum::NOT_FOUND,
);
}

Expand Down Expand Up @@ -72,9 +72,9 @@ public function __invoke(
'artistId' => $song['artistId'],
'playCount' => $song['playCount'],
],
$album['songs']
)
)
$album['songs'],
),
),
);
}
}
10 changes: 5 additions & 5 deletions src/FeatureSet/V1161/Method/GetArtistMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*
* This class covers the `getArtist.view` method
*/
final class GetArtistMethod implements V1161MethodInterface
final readonly class GetArtistMethod implements V1161MethodInterface
{
public function __construct(
private readonly ResponderFactoryInterface $responderFactory,
private ResponderFactoryInterface $responderFactory,
) {
}

Expand All @@ -39,7 +39,7 @@ public function __invoke(

if ($artist === null) {
throw new MethodCallFailedException(
ErrorCodeEnum::NOT_FOUND
ErrorCodeEnum::NOT_FOUND,
);
}

Expand All @@ -65,8 +65,8 @@ public function __invoke(
'year' => $album['year'] ?? '',
'genre' => $album['genre'] ?? '',
],
$artist['albums']
)
$artist['albums'],
),
);
}
}
6 changes: 3 additions & 3 deletions src/FeatureSet/V1161/Method/GetArtistsMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*
* @see http://www.subsonic.org/pages/api.jsp#getArtists
*/
final class GetArtistsMethod implements V1161MethodInterface
final readonly class GetArtistsMethod implements V1161MethodInterface
{
public function __construct(
private readonly ResponderFactoryInterface $responderFactory,
private ResponderFactoryInterface $responderFactory,
) {
}

Expand Down Expand Up @@ -79,7 +79,7 @@ public function __invoke(
[
'ignoredArticles' => implode(' ', $artistListDataProvider->getIgnoredArticles()),
'index' => $data,
]
],
);
}
}
Loading

0 comments on commit 1231248

Please sign in to comment.