Skip to content

Commit eab817a

Browse files
author
Bl00D4NGEL
committed
chore: fix phpstan, add phpstan/phpstan-beberlei-assert
1 parent 63bfe49 commit eab817a

21 files changed

+210
-106
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"symfony/framework-bundle": "^6.0",
3131
"symfony/yaml": "^6.0 | ^7.0",
3232
"symfony/filesystem": "^6.0 | ^7.0",
33-
"symfony/maker-bundle": "^1.48"
33+
"symfony/maker-bundle": "^1.48",
34+
"phpstan/phpstan-beberlei-assert": "^1.1"
3435
},
3536
"autoload": {
3637
"psr-4": {

composer.lock

Lines changed: 51 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
includes:
22
- vendor/phpstan/phpstan-mockery/extension.neon
3+
- vendor/phpstan/phpstan-beberlei-assert/extension.neon
34

45
parameters:
56
level: max

src/GeekCellDddBundle.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace GeekCell\DddBundle;
66

7+
use Assert\Assert;
78
use GeekCell\DddBundle\DependencyInjection\GeekCellDddExtension;
89
use GeekCell\Facade\Facade;
910
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
@@ -31,6 +32,9 @@ public function getContainerExtension(): ?ExtensionInterface
3132
public function boot(): void
3233
{
3334
parent::boot();
34-
Facade::setContainer($this->container);
35+
36+
if ($this->container !== null) {
37+
Facade::setContainer($this->container);
38+
}
3539
}
3640
}

src/Infrastructure/Doctrine/Paginator.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,12 @@
1515
*/
1616
class Paginator implements PaginatorInterface
1717
{
18-
/**
19-
* @var int
20-
*/
2118
private readonly int $firstResult;
2219

23-
/**
24-
* @var int
25-
*/
2620
private readonly int $maxResults;
2721

2822
/**
29-
* Constructor.
30-
*
31-
* @param OrmPaginator $ormPaginator
23+
* @param OrmPaginator<T> $ormPaginator
3224
*/
3325
public function __construct(
3426
private readonly OrmPaginator $ormPaginator,

src/Infrastructure/Doctrine/Repository.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,10 @@
2222
*/
2323
abstract class Repository implements RepositoryInterface
2424
{
25-
/**
26-
* @var QueryBuilder
27-
*/
2825
private QueryBuilder $queryBuilder;
2926

3027
/**
31-
* Constructor.
32-
*
33-
* @param EntityManagerInterface $entityManager The entity manager
34-
* @param class-string $entityType The entity class
35-
* @param string $alias Entity alias
28+
* @param class-string $entityType
3629
*/
3730
public function __construct(
3831
protected EntityManagerInterface $entityManager,
@@ -56,10 +49,8 @@ public function __construct(
5649
*/
5750
public function collect(): Collection
5851
{
59-
/** @var array<object> $results */
52+
/** @var array<T> $results */
6053
$results = $this->queryBuilder->getQuery()->getResult() ?? [];
61-
62-
/** @var Collection */
6354
return new Collection($results);
6455
}
6556

@@ -80,9 +71,9 @@ function (QueryBuilder $queryBuilder) use (
8071
}
8172
);
8273

83-
return new DoctrinePaginator(
84-
new OrmPaginator($repository->queryBuilder->getQuery())
85-
);
74+
/** @var OrmPaginator<T> $paginator */
75+
$paginator = new OrmPaginator($repository->queryBuilder->getQuery());
76+
return new DoctrinePaginator($paginator);
8677
}
8778

8879
/**
@@ -116,9 +107,6 @@ public function filter(callable $filter): static
116107
return $clone;
117108
}
118109

119-
/**
120-
* @inheritDoc
121-
*/
122110
public function __clone(): void
123111
{
124112
$this->queryBuilder = clone $this->queryBuilder;

src/Infrastructure/Doctrine/Type/AbstractIdType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
abstract class AbstractIdType extends IntegerType
1313
{
14-
public function convertToDatabaseValue($value, AbstractPlatform $platform)
14+
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?int
1515
{
1616
if (is_int($value)) {
1717
return $value;
@@ -32,7 +32,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
3232
return intval($value->getValue());
3333
}
3434

35-
public function convertToPHPValue($value, AbstractPlatform $platform)
35+
public function convertToPHPValue($value, AbstractPlatform $platform): ?Id
3636
{
3737
if ($value === null) {
3838
return null;
@@ -54,7 +54,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
5454
}
5555

5656
/**
57-
* @return class-string<Id> $entityType
57+
* @return class-string<Id>
5858
*/
5959
abstract protected function getIdType(): string;
6060
}

src/Infrastructure/Doctrine/Type/AbstractUuidType.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ abstract class AbstractUuidType extends GuidType
1313
{
1414
/**
1515
* @inheritDoc
16-
* @return string
1716
*/
18-
public function convertToDatabaseValue($value, AbstractPlatform $platform)
17+
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
1918
{
2019
if (is_string($value)) {
2120
return $value;
@@ -38,9 +37,8 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
3837

3938
/**
4039
* @inheritDoc
41-
* @return Uuid
4240
*/
43-
public function convertToPHPValue($value, AbstractPlatform $platform)
41+
public function convertToPHPValue($value, AbstractPlatform $platform): ?Uuid
4442
{
4543
if ($value === null) {
4644
return null;
@@ -62,7 +60,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
6260
}
6361

6462
/**
65-
* @return class-string<Uuid> $entityType
63+
* @return class-string<Uuid>
6664
*/
6765
abstract protected function getIdType(): string;
6866
}

src/Infrastructure/Messenger/CommandBus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function dispatch(Command $command): mixed
2424
try {
2525
return $this->handle($command);
2626
} catch (HandlerFailedException $e) {
27-
$exceptions = $e->getNestedExceptions();
27+
$exceptions = $e->getWrappedExceptions();
2828
throw $exceptions[0];
2929
}
3030
}

src/Infrastructure/Messenger/QueryBus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function dispatch(Query $query): mixed
2424
try {
2525
return $this->handle($query);
2626
} catch (HandlerFailedException $e) {
27-
$exceptions = $e->getNestedExceptions();
27+
$exceptions = $e->getWrappedExceptions();
2828
throw $exceptions[0];
2929
}
3030
}

0 commit comments

Comments
 (0)