Skip to content

Commit

Permalink
Make strict typing
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Oct 21, 2022
1 parent aab2fd9 commit 9dbcb4f
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 65 deletions.
7 changes: 2 additions & 5 deletions src/Models/Channels/ChannelsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,14 @@ public function getResultSet(
}

/**
* @param class-string $type
* @param class-string<Entities\Channels\Channel> $type
*
* @return ORM\EntityRepository<Entities\Channels\Channel>
*/
private function getRepository(string $type = Entities\Channels\Channel::class): ORM\EntityRepository
{
if ($this->repository === null) {
/** @var ORM\EntityRepository<Entities\Channels\Channel> $repository */
$repository = $this->managerRegistry->getRepository($type);

$this->repository = $repository;
$this->repository = $this->managerRegistry->getRepository($type);
}

return $this->repository;
Expand Down
7 changes: 2 additions & 5 deletions src/Models/Channels/Controls/ControlsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,14 @@ public function getResultSet(
}

/**
* @param class-string $type
* @param class-string<Entities\Channels\Controls\Control> $type
*
* @return ORM\EntityRepository<Entities\Channels\Controls\Control>
*/
private function getRepository(string $type = Entities\Channels\Controls\Control::class): ORM\EntityRepository
{
if ($this->repository === null) {
/** @var ORM\EntityRepository<Entities\Channels\Controls\Control> $repository */
$repository = $this->managerRegistry->getRepository($type);

$this->repository = $repository;
$this->repository = $this->managerRegistry->getRepository($type);
}

return $this->repository;
Expand Down
13 changes: 5 additions & 8 deletions src/Models/Channels/Properties/PropertiesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(private readonly Persistence\ManagerRegistry $manage
}

/**
* @param class-string $type
* @phpstan-param class-string<Entities\Channels\Properties\Property> $type
*
* @throws DoctrineOrmQueryExceptions\InvalidStateException
* @throws DoctrineOrmQueryExceptions\QueryException
Expand All @@ -60,7 +60,7 @@ public function findOneBy(
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Channels\Properties\Property> $type
*
* @phpstan-return Array<Entities\Channels\Properties\Property>
*
Expand All @@ -86,7 +86,7 @@ public function findAllBy(
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Channels\Properties\Property> $type
*
* @phpstan-return DoctrineOrmQuery\ResultSet<Entities\Channels\Properties\Property>
*
Expand All @@ -104,17 +104,14 @@ public function getResultSet(
}

/**
* @param class-string $type
* @param class-string<Entities\Channels\Properties\Property> $type
*
* @return ORM\EntityRepository<Entities\Channels\Properties\Property>
*/
private function getRepository(string $type): ORM\EntityRepository
{
if (!isset($this->repository[$type])) {
/** @var ORM\EntityRepository<Entities\Channels\Properties\Property> $repository */
$repository = $this->managerRegistry->getRepository($type);

$this->repository[$type] = $repository;
$this->repository[$type] = $this->managerRegistry->getRepository($type);
}

return $this->repository[$type];
Expand Down
13 changes: 5 additions & 8 deletions src/Models/Connectors/ConnectorsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(private readonly Persistence\ManagerRegistry $manage
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Connectors\Connector> $type
*
* @throws DoctrineOrmQueryExceptions\InvalidStateException
* @throws DoctrineOrmQueryExceptions\QueryException
Expand All @@ -60,7 +60,7 @@ public function findOneBy(
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Connectors\Connector> $type
*
* @phpstan-return Array<Entities\Connectors\Connector>
*
Expand All @@ -86,7 +86,7 @@ public function findAllBy(
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Connectors\Connector> $type
*
* @phpstan-return DoctrineOrmQuery\ResultSet<Entities\Connectors\Connector>
*
Expand All @@ -104,17 +104,14 @@ public function getResultSet(
}

/**
* @param class-string $type
* @param class-string<Entities\Connectors\Connector> $type
*
* @return ORM\EntityRepository<Entities\Connectors\Connector>
*/
private function getRepository(string $type): ORM\EntityRepository
{
if (!isset($this->repository[$type])) {
/** @var ORM\EntityRepository<Entities\Connectors\Connector> $repository */
$repository = $this->managerRegistry->getRepository($type);

$this->repository[$type] = $repository;
$this->repository[$type] = $this->managerRegistry->getRepository($type);
}

return $this->repository[$type];
Expand Down
7 changes: 2 additions & 5 deletions src/Models/Connectors/Controls/ControlsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,14 @@ public function getResultSet(
}

/**
* @param class-string $type
* @param class-string<Entities\Connectors\Controls\Control> $type
*
* @return ORM\EntityRepository<Entities\Connectors\Controls\Control>
*/
private function getRepository(string $type = Entities\Connectors\Controls\Control::class): ORM\EntityRepository
{
if ($this->repository === null) {
/** @var ORM\EntityRepository<Entities\Connectors\Controls\Control> $repository */
$repository = $this->managerRegistry->getRepository($type);

$this->repository = $repository;
$this->repository = $this->managerRegistry->getRepository($type);
}

return $this->repository;
Expand Down
13 changes: 5 additions & 8 deletions src/Models/Connectors/Properties/PropertiesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(private readonly Persistence\ManagerRegistry $manage
}

/**
* @param class-string $type
* @phpstan-param class-string<Entities\Connectors\Properties\Property> $type
*
* @throws DoctrineOrmQueryExceptions\InvalidStateException
* @throws DoctrineOrmQueryExceptions\QueryException
Expand All @@ -60,7 +60,7 @@ public function findOneBy(
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Connectors\Properties\Property> $type
*
* @phpstan-return Array<Entities\Connectors\Properties\Property>
*
Expand All @@ -86,7 +86,7 @@ public function findAllBy(
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Connectors\Properties\Property> $type
*
* @phpstan-return DoctrineOrmQuery\ResultSet<Entities\Connectors\Properties\Property>
*
Expand All @@ -104,17 +104,14 @@ public function getResultSet(
}

/**
* @param class-string $type
* @param class-string<Entities\Connectors\Properties\Property> $type
*
* @return ORM\EntityRepository<Entities\Connectors\Properties\Property>
*/
private function getRepository(string $type): ORM\EntityRepository
{
if (!isset($this->repository[$type])) {
/** @var ORM\EntityRepository<Entities\Connectors\Properties\Property> $repository */
$repository = $this->managerRegistry->getRepository($type);

$this->repository[$type] = $repository;
$this->repository[$type] = $this->managerRegistry->getRepository($type);
}

return $this->repository[$type];
Expand Down
7 changes: 2 additions & 5 deletions src/Models/Devices/Attributes/AttributesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,14 @@ public function getResultSet(
}

/**
* @param class-string $type
* @param class-string<Entities\Devices\Attributes\Attribute> $type
*
* @return ORM\EntityRepository<Entities\Devices\Attributes\Attribute>
*/
private function getRepository(string $type = Entities\Devices\Attributes\Attribute::class): ORM\EntityRepository
{
if ($this->repository === null) {
/** @var ORM\EntityRepository<Entities\Devices\Attributes\Attribute> $repository */
$repository = $this->managerRegistry->getRepository($type);

$this->repository = $repository;
$this->repository = $this->managerRegistry->getRepository($type);
}

return $this->repository;
Expand Down
7 changes: 2 additions & 5 deletions src/Models/Devices/Controls/ControlsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,14 @@ public function getResultSet(
}

/**
* @param class-string $type
* @param class-string<Entities\Devices\Controls\Control> $type
*
* @return ORM\EntityRepository<Entities\Devices\Controls\Control>
*/
private function getRepository(string $type = Entities\Devices\Controls\Control::class): ORM\EntityRepository
{
if ($this->repository === null) {
/** @var ORM\EntityRepository<Entities\Devices\Controls\Control> $repository */
$repository = $this->managerRegistry->getRepository($type);

$this->repository = $repository;
$this->repository = $this->managerRegistry->getRepository($type);
}

return $this->repository;
Expand Down
13 changes: 5 additions & 8 deletions src/Models/Devices/DevicesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(private readonly Persistence\ManagerRegistry $manage
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Devices\Device> $type
*
* @throws DoctrineOrmQueryExceptions\InvalidStateException
* @throws DoctrineOrmQueryExceptions\QueryException
Expand All @@ -60,7 +60,7 @@ public function findOneBy(
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Devices\Device> $type
*
* @phpstan-return Array<Entities\Devices\Device>
*
Expand All @@ -86,7 +86,7 @@ public function findAllBy(
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Devices\Device> $type
*
* @phpstan-return DoctrineOrmQuery\ResultSet<Entities\Devices\Device>
*
Expand All @@ -104,17 +104,14 @@ public function getResultSet(
}

/**
* @param class-string $type
* @param class-string<Entities\Devices\Device> $type
*
* @return ORM\EntityRepository<Entities\Devices\Device>
*/
private function getRepository(string $type): ORM\EntityRepository
{
if (!isset($this->repository[$type])) {
/** @var ORM\EntityRepository<Entities\Devices\Device> $repository */
$repository = $this->managerRegistry->getRepository($type);

$this->repository[$type] = $repository;
$this->repository[$type] = $this->managerRegistry->getRepository($type);
}

return $this->repository[$type];
Expand Down
13 changes: 5 additions & 8 deletions src/Models/Devices/Properties/PropertiesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(private readonly Persistence\ManagerRegistry $manage
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Devices\Properties\Property> $type
*
* @throws DoctrineOrmQueryExceptions\InvalidStateException
* @throws DoctrineOrmQueryExceptions\QueryException
Expand All @@ -60,7 +60,7 @@ public function findOneBy(
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Devices\Properties\Property> $type
*
* @phpstan-return Array<Entities\Devices\Properties\Property>
*
Expand All @@ -86,7 +86,7 @@ public function findAllBy(
}

/**
* @phpstan-param class-string $type
* @phpstan-param class-string<Entities\Devices\Properties\Property> $type
*
* @phpstan-return DoctrineOrmQuery\ResultSet<Entities\Devices\Properties\Property>
*
Expand All @@ -104,17 +104,14 @@ public function getResultSet(
}

/**
* @param class-string $type
* @param class-string<Entities\Devices\Properties\Property> $type
*
* @return ORM\EntityRepository<Entities\Devices\Properties\Property>
*/
private function getRepository(string $type): ORM\EntityRepository
{
if (!isset($this->repository[$type])) {
/** @var ORM\EntityRepository<Entities\Devices\Properties\Property> $repository */
$repository = $this->managerRegistry->getRepository($type);

$this->repository[$type] = $repository;
$this->repository[$type] = $this->managerRegistry->getRepository($type);
}

return $this->repository[$type];
Expand Down

0 comments on commit 9dbcb4f

Please sign in to comment.