Skip to content

Commit 2a84341

Browse files
authoredOct 3, 2023
chore: use psalm level 3 (#358)
* feat: add mockery psalm plugin * chore(psalm): disable PossiblyUndefinedMethod in test Since are false positive errors * chore(psalm): add symfony plugin * chore(psalm): upgrade to level 3
1 parent 9c90282 commit 2a84341

38 files changed

+326
-62
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<p align="center">
1212
<a href="https://github.com/CodelyTV"><img src="https://img.shields.io/badge/CodelyTV-OS-green.svg?style=flat-square" alt="codely.tv"/></a>
1313
<a href="http://pro.codely.tv"><img src="https://img.shields.io/badge/CodelyTV-PRO-black.svg?style=flat-square" alt="CodelyTV Courses"/></a>
14-
<a href="#"><img src="https://img.shields.io/badge/Symfony-5.0-purple.svg?style=flat-square&logo=symfony" alt="Symfony 5.0"/></a>
14+
<a href="#"><img src="https://img.shields.io/badge/Symfony-6-purple.svg?style=flat-square&logo=symfony" alt="Symfony 6"/></a>
1515
<a href="https://github.com/CodelyTV/php-ddd-example/actions"><img src="https://github.com/CodelyTV/php-ddd-example/workflows/CI/badge.svg?branch=master" alt="CI pipeline status" /></a>
1616
</p>
1717

‎apps/backoffice/backend/src/Controller/Courses/CoursesGetController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __invoke(Request $request): JsonResponse
3737

3838
return new JsonResponse(
3939
map(
40-
fn (BackofficeCourseResponse $course) => [
40+
fn (BackofficeCourseResponse $course): array => [
4141
'id' => $course->id(),
4242
'name' => $course->name(),
4343
'duration' => $course->duration(),

‎apps/mooc/backend/src/Command/DomainEvents/RabbitMq/ConsumeRabbitMqDomainEventsCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function configure(): void
3636

3737
protected function execute(InputInterface $input, OutputInterface $output): int
3838
{
39-
$queueName = (string) $input->getArgument('queue');
39+
$queueName = $input->getArgument('queue');
4040
$eventsToProcess = (int) $input->getArgument('quantity');
4141

4242
repeat($this->consumer($queueName), $eventsToProcess);

‎apps/mooc/backend/src/Command/DomainEvents/RabbitMq/GenerateSupervisorRabbitMqConsumerFilesCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function configure(): void
3535

3636
protected function execute(InputInterface $input, OutputInterface $output): int
3737
{
38-
$path = (string) $input->getArgument('command-path');
38+
$path = $input->getArgument('command-path');
3939

4040
each($this->configCreator($path), $this->locator->all());
4141

‎composer.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454

5555
"symplify/easy-coding-standard": "^12.0",
5656
"vimeo/psalm": "^5.15",
57-
"rector/rector": "^0.18.4"
57+
"rector/rector": "^0.18.4",
58+
"psalm/plugin-mockery": "^1.1",
59+
"psalm/plugin-symfony": "^5.0"
5860
},
5961
"autoload": {
6062
"psr-4": {

‎composer.lock

+196-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎psalm.xml

+44-11
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,56 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns="https://getpsalm.org/schema/config"
55
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
6-
errorLevel="4"
6+
errorLevel="3"
77
resolveFromConfigFile="true"
88
findUnusedBaselineEntry="false"
99
findUnusedCode="false"
1010
>
1111
<projectFiles>
12-
<directory name="apps" />
13-
<directory name="src" />
14-
<directory name="tests" />
12+
<directory name="apps"/>
13+
<directory name="src"/>
14+
<directory name="tests"/>
1515
<ignoreFiles>
16-
<directory name="apps/*/*/var" />
17-
<directory name="vendor" />
18-
<directory name="src/Shared/Infrastructure/Bus/Event/RabbitMq" />
19-
<directory name="src/Shared/Infrastructure/Symfony" />
20-
<directory name="tests/Shared/Infrastructure/Bus/Event/RabbitMq" />
21-
<directory name="tests/Shared/Infrastructure/Mink" />
22-
<directory name="tests/Shared/Infrastructure/PhpUnit/Constraint" />
16+
<directory name="apps/*/*/var"/>
17+
<directory name="vendor"/>
18+
<directory name="src/Shared/Infrastructure/Bus/Event/RabbitMq"/>
19+
<directory name="src/Shared/Infrastructure/Symfony"/>
20+
<directory name="tests/Shared/Infrastructure/Bus/Event/RabbitMq"/>
21+
<directory name="tests/Shared/Infrastructure/Mink"/>
22+
<directory name="tests/Shared/Infrastructure/PhpUnit/Constraint"/>
2323
</ignoreFiles>
2424
</projectFiles>
25+
26+
<issueHandlers>
27+
<PossiblyUndefinedMethod>
28+
<errorLevel type="suppress">
29+
<directory name="tests"/>
30+
</errorLevel>
31+
</PossiblyUndefinedMethod>
32+
<PossiblyInvalidArgument>
33+
<errorLevel type="suppress">
34+
<directory name="tests"/>
35+
</errorLevel>
36+
</PossiblyInvalidArgument>
37+
<PossiblyNullReference>
38+
<errorLevel type="suppress">
39+
<directory name="tests"/>
40+
</errorLevel>
41+
</PossiblyNullReference>
42+
<PossiblyNullArgument>
43+
<errorLevel type="suppress">
44+
<directory name="tests"/>
45+
</errorLevel>
46+
</PossiblyNullArgument>
47+
<MoreSpecificReturnType>
48+
<errorLevel type="suppress">
49+
<file name="apps/*/*/src/*Kernel.php"/>
50+
</errorLevel>
51+
</MoreSpecificReturnType>
52+
</issueHandlers>
53+
54+
<plugins>
55+
<pluginClass class="Psalm\MockeryPlugin\Plugin"/>
56+
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
57+
</plugins>
2558
</psalm>

‎rector.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Rector\Config\RectorConfig;
66
use Rector\Set\ValueObject\LevelSetList;
7+
use Rector\Set\ValueObject\SetList;
78

89
return static function (RectorConfig $rectorConfig): void {
910
$rectorConfig->paths([
@@ -13,6 +14,14 @@
1314
]);
1415

1516
$rectorConfig->sets([
16-
LevelSetList::UP_TO_PHP_82
17+
LevelSetList::UP_TO_PHP_82,
18+
SetList::TYPE_DECLARATION
19+
]);
20+
21+
$rectorConfig->skip([
22+
__DIR__ . '/apps/backoffice/backend/var',
23+
__DIR__ . '/apps/backoffice/frontend/var',
24+
__DIR__ . '/apps/mooc/backend/var',
25+
__DIR__ . '/apps/mooc/frontend/var',
1726
]);
1827
};

‎src/Backoffice/Auth/Application/Authenticate/UserAuthenticator.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@ public function authenticate(AuthUsername $username, AuthPassword $password): vo
1919
{
2020
$auth = $this->repository->search($username);
2121

22-
$this->ensureUserExist($auth, $username);
23-
$this->ensureCredentialsAreValid($auth, $password);
24-
}
25-
26-
private function ensureUserExist(?AuthUser $auth, AuthUsername $username): void
27-
{
2822
if ($auth === null) {
2923
throw new InvalidAuthUsername($username);
3024
}
25+
26+
$this->ensureCredentialsAreValid($auth, $password);
3127
}
3228

3329
private function ensureCredentialsAreValid(AuthUser $auth, AuthPassword $password): void

‎src/Backoffice/Courses/Application/SearchAll/AllBackofficeCoursesSearcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function searchAll(): BackofficeCoursesResponse
2222

2323
private function toResponse(): callable
2424
{
25-
return static fn (BackofficeCourse $course) => new BackofficeCourseResponse(
25+
return static fn (BackofficeCourse $course): BackofficeCourseResponse => new BackofficeCourseResponse(
2626
$course->id(),
2727
$course->name(),
2828
$course->duration()

‎src/Backoffice/Courses/Application/SearchByCriteria/BackofficeCoursesByCriteriaSearcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function search(Filters $filters, Order $order, ?int $limit, ?int $offset
2727

2828
private function toResponse(): callable
2929
{
30-
return static fn (BackofficeCourse $course) => new BackofficeCourseResponse(
30+
return static fn (BackofficeCourse $course): BackofficeCourseResponse => new BackofficeCourseResponse(
3131
$course->id(),
3232
$course->name(),
3333
$course->duration()

0 commit comments

Comments
 (0)
Please sign in to comment.