Skip to content

Commit

Permalink
Enforce some more rector rules
Browse files Browse the repository at this point in the history
  • Loading branch information
usox committed Feb 13, 2024
1 parent cc43340 commit f1f7c12
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 53 deletions.
64 changes: 32 additions & 32 deletions composer.lock

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

11 changes: 10 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@
return RectorConfig::configure()
->withImportNames()
->withPhpSets(php82: true)
->withPreparedSets(deadCode: true, codeQuality: true, codingStyle: true)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
privatization: true,
instanceOf: true,
earlyReturn: true,
strictBooleans: true
)
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
Expand Down
7 changes: 4 additions & 3 deletions src/Api/Search/SearchApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Uxmp\Core\Api\Search;

use JsonSerializable;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Uxmp\Core\Api\AbstractApiApplication;
Expand Down Expand Up @@ -53,19 +54,19 @@ protected function run(
'items' => [
'albums' => array_values(
array_map(
fn (AlbumInterface $album) => $this->resultItemFactory->createAlbumListItem($album),
fn (AlbumInterface $album): JsonSerializable => $this->resultItemFactory->createAlbumListItem($album),
$this->albumRepository->search($searchTerm)
)
),
'artists' => array_values(
array_map(
fn (ArtistInterface $artist) => $this->resultItemFactory->createArtistListItem($artist),
fn (ArtistInterface $artist): JsonSerializable => $this->resultItemFactory->createArtistListItem($artist),
$this->artistRepository->search($searchTerm)
)
),
'songs' => array_values(
array_map(
fn (SongInterface $song) => $this->resultItemFactory->createSongListItem($song, $song->getAlbum()),
fn (SongInterface $song): JsonSerializable => $this->resultItemFactory->createSongListItem($song, $song->getAlbum()),
$this->songRepository->search($searchTerm)
)
),
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Io/Lib/PopenWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function run(string $command): mixed
return null;
}

register_shutdown_function(static fn () => fclose($handle));
register_shutdown_function(static fn (): bool => fclose($handle));

return $handle;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Component/Io/Transcoder/TranscodingHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public function __invoke(int $length): string
}

return $chunk;
} else {
// return only null (if the content length is greater than the actual size)
return str_repeat("\0", $length);
}

// return only null (if the content length is greater than the actual size)
return str_repeat("\0", $length);
}

private function read(int $length): string
Expand Down
22 changes: 11 additions & 11 deletions src/Component/Tag/Container/AudioFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function setTitle(string $title): AudioFileInterface

public function getTitleClean(): string
{
return $this->stringHelper->filterForSearch($this->getTitle());
return $this->stringHelper->filterForSearch($this->title);
}

public function getMbid(): string
Expand All @@ -110,7 +110,7 @@ public function setArtistTitle(string $artistTitle): AudioFileInterface

public function getArtistTitleClean(): string
{
return $this->stringHelper->filterForSearch($this->getArtistTitle());
return $this->stringHelper->filterForSearch($this->artistTitle);
}

public function getArtistMbid(): string
Expand Down Expand Up @@ -138,7 +138,7 @@ public function setAlbumTitle(string $albumTitle): AudioFileInterface
public function getAlbumTitleClean(): string
{
return $this->stringHelper->filterForSearch(
$this->getAlbumTitle()
$this->albumTitle
);
}

Expand Down Expand Up @@ -268,15 +268,15 @@ public function setLength(int $length): AudioFileInterface
public function apply(SongInterface $song): void
{
$song
->setTitle($this->getTitle())
->setTitle($this->title)
->setSearchTitle($this->getTitleClean())
->setTrackNumber($this->getTrackNumber())
->setFilename($this->getFilename())
->setMbid($this->getMbid())
->setLength($this->getLength())
->setYear($this->getYear())
->setMimeType($this->getMimeType())
->setFileSize($this->getFileSize())
->setTrackNumber($this->trackNumber)
->setFilename($this->filename)
->setMbid($this->mbid)
->setLength($this->length)
->setYear($this->year)
->setMimeType($this->mimeType)
->setFileSize($this->fileSize)
;
}
}
2 changes: 1 addition & 1 deletion tests/Api/Common/LogoutApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testRunPerformsLogout(): void
$response->shouldReceive('withHeader')
->with(
'Set-Cookie',
Mockery::on(static fn ($value) => str_starts_with(
Mockery::on(static fn ($value): bool => str_starts_with(
(string) $value,
sprintf(
'%s=; path=%s/play; Expires=',
Expand Down
2 changes: 1 addition & 1 deletion tests/Bootstrap/InitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testRunRuns(): void

$this->assertSame(
$foo,
Init::run(static fn () => $foo),
Init::run(static fn (): string => $foo),
);
}
}

0 comments on commit f1f7c12

Please sign in to comment.