Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leepeuker committed Sep 11, 2024
1 parent 2a4c520 commit 2b3027a
Show file tree
Hide file tree
Showing 48 changed files with 262 additions and 130 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"squizlabs/php_codesniffer": "^3.9",
"phpstan/phpstan": "^1.12.3",
"phpstan/phpstan-phpunit": "^1.4",
"vimeo/psalm": "^5.25",
"vimeo/psalm": "^5.4",
"psalm/plugin-phpunit": "^0.19",
"webmozarts/strict-phpunit": "^7.11.19"
},
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

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

2 changes: 0 additions & 2 deletions settings/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ parameters:
ignoreErrors:
-
identifier: missingType.iterableValue
-
identifier: missingType.generics
-
message: '#Parameter \#2 \$level of class Monolog\\Handler\\StreamHandler#'
path: ../src/Factory.php
Expand Down
9 changes: 9 additions & 0 deletions settings/psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,27 @@
<DeprecatedFunction errorLevel="info"/>
<DeprecatedInterface errorLevel="info"/>
<DeprecatedTrait errorLevel="info"/>
<ParamNameMismatch errorLevel="info"/>

<RedundantConditionGivenDocblockType errorLevel="info"/>
<PropertyNotSetInConstructor errorLevel="info"/>
<MixedArrayAccess errorLevel="info"/>
<MixedAssignment errorLevel="info"/>
<ImplicitToStringCast errorLevel="suppress"/>
<PossiblyUndefinedArrayOffset errorLevel="info"/>
<RiskyTruthyFalsyComparison errorLevel="info"/>
<RiskyCast errorLevel="info"/>

<PossiblyInvalidCast>
<errorLevel type="suppress">
<file name="src/ValueObject/Http/Request.php"/>
</errorLevel>
</PossiblyInvalidCast>
<ArgumentTypeCoercion>
<errorLevel type="suppress">
<file name="src/ValueObject/DateTime.php"/>
</errorLevel>
</ArgumentTypeCoercion>

<InternalMethod>
<errorLevel type="suppress">
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Jellyfin/Dto/JellyfinMovieDtoList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method JellyfinMovieDto[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<JellyfinMovieDto>
*/
class JellyfinMovieDtoList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Tmdb/Dto/TmdbCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method TmdbCastMember[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<TmdbCastMember>
*/
class TmdbCast extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Tmdb/Dto/TmdbCrew.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method TmdbCrewMember[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<TmdbCrewMember>
*/
class TmdbCrew extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Tmdb/Dto/TmdbGenreList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method TmdbGenre[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<TmdbGenre>
*/
class TmdbGenreList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Tmdb/Dto/TmdbProductionCompanyList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method TmdbProductionCompany[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<TmdbProductionCompany>
*/
class TmdbProductionCompanyList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Tmdb/Dto/TmdbWatchProviderList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method TmdbWatchProviderDto[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<TmdbWatchProviderDto>
*/
class TmdbWatchProviderList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Trakt/ValueObject/User/Movie/History/DtoList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method Dto[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<Dto>
*/
class DtoList extends AbstractList
{
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Trakt/ValueObject/User/Movie/Rating/DtoList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<Dto>
*/
class DtoList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Trakt/ValueObject/User/Movie/Watched/DtoList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
use Movary\ValueObject\DateTime;

/**
* @method Dto[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<Dto>
*/
class DtoList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Domain/Company/CompanyEntityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method CompanyEntity[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<CompanyEntity>
*/
class CompanyEntityList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Domain/Genre/GenreEntityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method GenreEntity[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<GenreEntity>
*/
class GenreEntityList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Domain/Movie/Cast/CastEntityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method CastEntity[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<CastEntity>
*/
class CastEntityList extends AbstractList
{
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Movie/Crew/CrewApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class CrewApi
{
private const RELEVANT_JOBS = [
private const array RELEVANT_JOBS = [
'Screenplay',
'Director',
'Producer',
Expand Down
3 changes: 1 addition & 2 deletions src/Domain/Movie/Crew/CrewEntityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method CrewEntity[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<CrewEntity>
*/
class CrewEntityList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Domain/Movie/Genre/MovieGenreEntityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method MovieGenreEntity[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<MovieGenreEntity>
*/
class MovieGenreEntityList extends AbstractList
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method MovieHistoryLocationEntity[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<MovieHistoryLocationEntity>
*/
class MovieHistoryLocationEntityList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Domain/Movie/History/MovieHistoryEntityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method MovieHistoryEntity[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<MovieHistoryEntity>
*/
class MovieHistoryEntityList extends AbstractList
{
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Movie/MovieApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ public function updateCrew(int $movieId, TmdbCrew $tmdbCrew) : void
$crewMember->getPerson()->getPosterPath(),
);

$this->crewApi->create($movieId, $person->getId(), $crewMember->getJob(), $crewMember->getDepartment(), $position);
$this->crewApi->create($movieId, $person->getId(), $crewMember->getJob(), $crewMember->getDepartment(), (int)$position);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/Domain/Movie/MovieEntityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method MovieEntity[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<MovieEntity>
*/
class MovieEntityList extends AbstractList
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method ProductionCompanyEntity[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<ProductionCompanyEntity>
*/
class ProductionCompanyEntityList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/Domain/Person/PersonEntityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method PersonEntity[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<PersonEntity>
*/
class PersonEntityList extends AbstractList
{
Expand Down
20 changes: 10 additions & 10 deletions src/Domain/User/Service/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public function getCurrentUser() : UserEntity
public function getCurrentUserId() : int
{
$userId = $this->sessionWrapper->find('userId');
$token = filter_input(INPUT_COOKIE, self::AUTHENTICATION_COOKIE_NAME);
$token = (string)filter_input(INPUT_COOKIE, self::AUTHENTICATION_COOKIE_NAME);

if ($userId === null && $token !== null) {
$userId = $this->repository->findUserIdByAuthToken((string)$token);
if ($userId === null && $token !== '') {
$userId = $this->repository->findUserIdByAuthToken($token);
$this->sessionWrapper->set('userId', $userId);
}

Expand All @@ -100,8 +100,8 @@ public function getCurrentUserId() : int

public function getToken(Request $request) : ?string
{
$tokenInCookie = filter_input(INPUT_COOKIE, self::AUTHENTICATION_COOKIE_NAME);
if ($tokenInCookie !== false && $tokenInCookie !== null) {
$tokenInCookie = (string)filter_input(INPUT_COOKIE, self::AUTHENTICATION_COOKIE_NAME);
if ($tokenInCookie !== '') {
return $tokenInCookie;
}

Expand All @@ -124,9 +124,9 @@ public function getUserIdByApiToken(Request $request) : ?int

public function isUserAuthenticatedWithCookie() : bool
{
$token = filter_input(INPUT_COOKIE, self::AUTHENTICATION_COOKIE_NAME);
$token = (string)filter_input(INPUT_COOKIE, self::AUTHENTICATION_COOKIE_NAME);

if (empty($token) === false && $this->isValidAuthToken((string)$token) === true) {
if ($token !== '' && $this->isValidAuthToken($token) === true) {
return true;
}

Expand Down Expand Up @@ -203,10 +203,10 @@ public function login(

public function logout() : void
{
$token = filter_input(INPUT_COOKIE, 'id');
$token = (string)filter_input(INPUT_COOKIE, 'id');

if ($token !== null) {
$this->deleteToken((string)$token);
if ($token !== '') {
$this->deleteToken($token);
unset($_COOKIE[self::AUTHENTICATION_COOKIE_NAME]);
setcookie(self::AUTHENTICATION_COOKIE_NAME, '', -1);
}
Expand Down
3 changes: 1 addition & 2 deletions src/HttpController/Api/Dto/HistoryEntryDtoList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method MovieDto[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<HistoryEntryDto>
*/
class HistoryEntryDtoList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/HttpController/Api/Dto/MovieSearchResultDtoList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method MovieSearchResultDto[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<MovieSearchResultDto>
*/
class MovieSearchResultDtoList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/HttpController/Api/Dto/PlayedEntryDtoList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method MovieDto[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<PlayedEntryDto>
*/
class PlayedEntryDtoList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/HttpController/Api/Dto/WatchDateDtoList.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
use RuntimeException;

/**
* @method WatchDateDto[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<WatchDateDto>
*/
class WatchDateDtoList extends AbstractList
{
Expand Down
3 changes: 1 addition & 2 deletions src/HttpController/Api/Dto/WatchlistEntryDtoList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Movary\ValueObject\AbstractList;

/**
* @method MovieDto[] getIterator()
* @psalm-suppress ImplementedReturnTypeMismatch
* @extends AbstractList<WatchlistEntryDto>
*/
class WatchlistEntryDtoList extends AbstractList
{
Expand Down
Loading

0 comments on commit 2b3027a

Please sign in to comment.