Skip to content

Commit

Permalink
Remove unecessary code to highlight issues with PHPStan-and-Psalm.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 2, 2021
1 parent 5773b8f commit 6f68b92
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 420 deletions.
2 changes: 0 additions & 2 deletions .github/settings.yml
Expand Up @@ -13,8 +13,6 @@ branches:
contexts:
- "Static Analysis (ubuntu-latest, 7.4)"
- "Static Analysis (ubuntu-latest, 8.0)"
- "Code Style (ubuntu-latest, 7.4)"
- "Code Style (ubuntu-latest, 8.0)"

restrictions: null
required_linear_history: true
Expand Down
6 changes: 0 additions & 6 deletions phpstan-doctrine-bug.neon
Expand Up @@ -4,9 +4,3 @@ parameters:
message: "#^Method loophp\\\\RepositoryMonadicHelper\\\\Doctrine\\\\MonadicStandardRepository\\:\\:getClassName\\(\\) should return class\\-string\\<R\\> but returns string\\.$#"
count: 1
path: src/Doctrine/MonadicStandardRepository.php

-
message: "#^Method loophp\\\\RepositoryMonadicHelper\\\\MonadicStandardRepositoryFactory\\:\\:getEntityClass\\(\\) should return class\\-string\\<R\\> but returns string\\.$#"
count: 1
path: src/MonadicStandardRepositoryFactory.php

60 changes: 0 additions & 60 deletions src/Doctrine/MonadicServiceEntityRepository.php

This file was deleted.

54 changes: 0 additions & 54 deletions src/Doctrine/MonadicServiceEntityRepositoryInterface.php

This file was deleted.

66 changes: 32 additions & 34 deletions src/Doctrine/MonadicStandardRepository.php
Expand Up @@ -11,8 +11,7 @@

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ObjectRepository;
use loophp\RepositoryMonadicHelper\Service\MonadicServiceRepositoryHelper;
use loophp\RepositoryMonadicHelper\Service\MonadicServiceRepositoryHelperInterface;
use loophp\RepositoryMonadicHelper\Exception\MonadicRepositoryException;
use Marcosh\LamPHPda\Either;

/**
Expand All @@ -23,11 +22,6 @@
*/
final class MonadicStandardRepository implements MonadicStandardRepositoryInterface
{
/**
* @var MonadicServiceRepositoryHelperInterface<L, R>
*/
private MonadicServiceRepositoryHelperInterface $monadicServiceRepositoryHelper;

/**
* @var ObjectRepository<R>
*/
Expand All @@ -41,26 +35,29 @@ public function __construct(
string $entityClass
) {
$this->objectRepository = $entityManager->getRepository($entityClass);
$this->monadicServiceRepositoryHelper = new MonadicServiceRepositoryHelper();
}

public function find($id): Either
{
return $this
->monadicServiceRepositoryHelper
->eitherFind(
$this->objectRepository,
$id
);
return (null === $entity = $this->objectRepository->find($id))
? Either::left(
MonadicRepositoryException::entityNotFoundWithSuchId(
$this->objectRepository->getClassName(),
(string) $id
)
)
: Either::right($entity);
}

public function findAll(): Either
{
return $this
->monadicServiceRepositoryHelper
->eitherFindAll(
$this->objectRepository,
);
return ([] === $entities = $this->objectRepository->findAll())
? Either::left(
MonadicRepositoryException::entityNotFound(
$this->objectRepository->getClassName()
)
)
: Either::right($entities);
}

public function findBy(
Expand All @@ -69,26 +66,27 @@ public function findBy(
?int $limit = null,
?int $offset = null
): Either {
return $this
->monadicServiceRepositoryHelper
->eitherFindBy(
$this->objectRepository,
$criteria,
$orderBy,
$limit,
$offset
);
return ([] === $entities = $this->objectRepository->findBy($criteria, $orderBy, $limit, $offset))
? Either::left(
MonadicRepositoryException::entityNotFoundWithSuchCriteria(
$this->objectRepository->getClassName(),
$criteria
)
)
: Either::right($entities);
}

public function findOneBy(
array $criteria
): Either {
return $this
->monadicServiceRepositoryHelper
->eitherFindOneBy(
$this->objectRepository,
$criteria
);
return (null === $entity = $this->objectRepository->findOneBy($criteria))
? Either::left(
MonadicRepositoryException::entityNotFoundWithSuchCriteria(
$this->objectRepository->getClassName(),
$criteria
)
)
: Either::right($entity);
}

public function getClassName(): string
Expand Down
40 changes: 0 additions & 40 deletions src/MonadicServiceEntityRepositoryTrait.php

This file was deleted.

49 changes: 0 additions & 49 deletions src/MonadicStandardRepositoryFactory.php

This file was deleted.

35 changes: 0 additions & 35 deletions src/MonadicStandardRepositoryFactoryInterface.php

This file was deleted.

0 comments on commit 6f68b92

Please sign in to comment.