Skip to content

Commit ff40d42

Browse files
authored
chore: use psalm level 2 (#359)
1 parent 2a84341 commit ff40d42

24 files changed

Lines changed: 132 additions & 57 deletions

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function __invoke(Request $request): JsonResponse
2828
$response = $this->queryBus->ask(
2929
new SearchBackofficeCoursesByCriteriaQuery(
3030
(array) $request->query->get('filters'),
31-
$orderBy === null ? null : (string) $orderBy,
32-
$order === null ? null : (string) $order,
31+
$orderBy === null ? null : $orderBy,
32+
$order === null ? null : $order,
3333
$limit === null ? null : (int) $limit,
3434
$offset === null ? null : (int) $offset
3535
)

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"vimeo/psalm": "^5.15",
5757
"rector/rector": "^0.18.4",
5858
"psalm/plugin-mockery": "^1.1",
59-
"psalm/plugin-symfony": "^5.0"
59+
"psalm/plugin-symfony": "^5.0",
60+
"psalm/plugin-phpunit": "^0.18.4"
6061
},
6162
"autoload": {
6263
"psr-4": {

composer.lock

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

psalm.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
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="3"
6+
errorLevel="2"
77
resolveFromConfigFile="true"
88
findUnusedBaselineEntry="false"
99
findUnusedCode="false"
10+
allowStringToStandInForClass="true"
1011
>
1112
<projectFiles>
1213
<directory name="apps"/>
@@ -44,15 +45,26 @@
4445
<directory name="tests"/>
4546
</errorLevel>
4647
</PossiblyNullArgument>
48+
<PropertyNotSetInConstructor>
49+
<errorLevel type="suppress">
50+
<directory name="tests"/>
51+
</errorLevel>
52+
</PropertyNotSetInConstructor>
4753
<MoreSpecificReturnType>
4854
<errorLevel type="suppress">
4955
<file name="apps/*/*/src/*Kernel.php"/>
5056
</errorLevel>
5157
</MoreSpecificReturnType>
58+
<UnresolvableInclude>
59+
<errorLevel type="suppress">
60+
<file name="apps/*/*/src/*Kernel.php"/>
61+
</errorLevel>
62+
</UnresolvableInclude>
5263
</issueHandlers>
5364

5465
<plugins>
5566
<pluginClass class="Psalm\MockeryPlugin\Plugin"/>
5667
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
68+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
5769
</plugins>
5870
</psalm>

src/Mooc/Shared/Infrastructure/Doctrine/DbalTypesSearcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private static function modulesInPath(string $path): array
3333
private static function possibleDbalPaths(string $path): array
3434
{
3535
return map(
36-
static function ($unused, string $module) use ($path) {
36+
static function (mixed $_unused, string $module) use ($path) {
3737
$mappingsPath = self::MAPPINGS_PATH;
3838

3939
return realpath("$path/$module/$mappingsPath");
@@ -51,7 +51,7 @@ private static function dbalClassesSearcher(string $contextName): callable
5151
{
5252
return static function (array $totalNamespaces, string $path) use ($contextName): array {
5353
$possibleFiles = scandir($path);
54-
$files = filter(static fn ($file): bool => Utils::endsWith('Type.php', $file), $possibleFiles);
54+
$files = filter(static fn (string $file): bool => Utils::endsWith('Type.php', $file), $possibleFiles);
5555

5656
$namespaces = map(
5757
static function (string $file) use ($path, $contextName): string {

src/Mooc/Shared/Infrastructure/Doctrine/DoctrinePrefixesSearcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private static function modulesInPath(string $path): array
3131
private static function possibleMappingPaths(string $path): array
3232
{
3333
return map(
34-
static function ($unused, string $module) use ($path) {
34+
static function (mixed $_unused, string $module) use ($path) {
3535
$mappingsPath = self::MAPPINGS_PATH;
3636

3737
return realpath("$path/$module/$mappingsPath");

src/Mooc/Videos/Application/Find/FindVideoQueryHandler.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@
88
use CodelyTv\Shared\Domain\Bus\Query\QueryHandler;
99

1010
use function Lambdish\Phunctional\apply;
11-
use function Lambdish\Phunctional\pipe;
1211

13-
final class FindVideoQueryHandler implements QueryHandler
12+
final readonly class FindVideoQueryHandler implements QueryHandler
1413
{
15-
private $finder;
14+
private VideoResponseConverter $responseConverter;
1615

17-
public function __construct(VideoFinder $finder)
16+
public function __construct(private VideoFinder $finder)
1817
{
19-
$this->finder = pipe($finder, new VideoResponseConverter());
18+
$this->responseConverter = new VideoResponseConverter();
2019
}
2120

2221
public function __invoke(FindVideoQuery $query): VideoResponse
2322
{
2423
$id = new VideoId($query->id());
2524

26-
return apply($this->finder, [$id]);
25+
$video = apply($this->finder, [$id]);
26+
27+
return apply($this->responseConverter, [$video]);
2728
}
2829
}

src/Shared/Domain/Assert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static function arrayOf(string $class, array $items): void
1515
}
1616
}
1717

18-
public static function instanceOf(string $class, $item): void
18+
public static function instanceOf(string $class, mixed $item): void
1919
{
2020
if (!$item instanceof $class) {
2121
throw new InvalidArgumentException(

src/Shared/Domain/ValueObject/Uuid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
abstract class Uuid implements Stringable
1212
{
13-
public function __construct(protected string $value)
13+
final public function __construct(protected string $value)
1414
{
1515
$this->ensureIsValidUuid($value);
1616
}

src/Shared/Infrastructure/Bus/CallableFirstParameterExtractor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function forPipedCallables(iterable $callables): array
2828

2929
private static function classExtractor(self $parameterExtractor): callable
3030
{
31-
return static fn (callable $handler): ?string => $parameterExtractor->extract($handler);
31+
return static fn (object $handler): ?string => $parameterExtractor->extract($handler);
3232
}
3333

3434
private static function pipedCallablesReducer(): callable
@@ -46,10 +46,10 @@ private static function pipedCallablesReducer(): callable
4646

4747
private static function unflatten(): callable
4848
{
49-
return static fn ($value): array => [$value];
49+
return static fn (mixed $value): array => [$value];
5050
}
5151

52-
public function extract($class): ?string
52+
public function extract(object $class): ?string
5353
{
5454
$reflector = new ReflectionClass($class);
5555
$method = $reflector->getMethod('__invoke');
@@ -63,7 +63,7 @@ public function extract($class): ?string
6363

6464
private function firstParameterClassFrom(ReflectionMethod $method): string
6565
{
66-
/** @var ReflectionNamedType $fistParameterType */
66+
/** @var ReflectionNamedType|null $fistParameterType */
6767
$fistParameterType = $method->getParameters()[0]->getType();
6868

6969
if ($fistParameterType === null) {

0 commit comments

Comments
 (0)