Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(psalm): add some level 1 improvements #360

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@
<directory name="tests"/>
</errorLevel>
</PropertyNotSetInConstructor>
<MixedMethodCall>
<errorLevel type="suppress">
<directory name="tests"/>
</errorLevel>
</MixedMethodCall>
<MixedAssignment>
<errorLevel type="suppress">
<file name="tests/Shared/Infrastructure/PhpUnit/Comparator/*SimilarComparator.php"/>
</errorLevel>
</MixedAssignment>
<MixedArgument>
<errorLevel type="suppress">
<file name="tests/Shared/Infrastructure/PhpUnit/Comparator/*SimilarComparator.php"/>
</errorLevel>
</MixedArgument>
<MixedClone>
<errorLevel type="suppress">
<file name="tests/Shared/Infrastructure/PhpUnit/Comparator/*SimilarComparator.php"/>
</errorLevel>
</MixedClone>
<MoreSpecificReturnType>
<errorLevel type="suppress">
<file name="apps/*/*/src/*Kernel.php"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/Shared/Domain/Criteria/OrderMother.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function none(): Order
return Order::none();
}

private static function randomOrderType(): Order
private static function randomOrderType(): OrderType
{
return RandomElementPicker::from(OrderType::ASC, OrderType::DESC, OrderType::NONE);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Shared/Domain/DuplicatorMother.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

final class DuplicatorMother
{
public static function with(mixed $object, array $newParams): mixed
public static function with(object $object, array $newParams): object
{
$duplicated = clone $object;
$reflection = new ReflectionObject($duplicated);
Expand Down
12 changes: 11 additions & 1 deletion tests/Shared/Domain/RandomElementPicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@

final class RandomElementPicker
{
/**
* @template T
*
* @psalm-param T ...$elements
*
* @psalm-return T
*/
public static function from(mixed ...$elements): mixed
{
return MotherCreator::random()->randomElement($elements);
/** @var T $randomElement */
$randomElement = MotherCreator::random()->randomElement($elements);

return $randomElement;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function __invoke(EntityManagerInterface $entityManager): void

private function truncateDatabaseSql(array $tables): string
{
/** @var array<int, string> $truncateTables */
$truncateTables = map($this->truncateTableSql(), $tables);

return sprintf('SET FOREIGN_KEY_CHECKS = 0; %s SET FOREIGN_KEY_CHECKS = 1;', implode(' ', $truncateTables));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function __invoke(ElasticsearchClient $client): void

each(
static function (array $index) use ($client): void {
/** @var string $indexName */
$indexName = $index['index'];

$client->client()->indices()->delete(['index' => $indexName]);
Expand Down
1 change: 1 addition & 0 deletions tests/Shared/Infrastructure/PhpUnit/UnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ protected function dispatch(Command $command, callable $commandHandler): void

protected function assertAskResponse(Response $expected, Query $query, callable $queryHandler): void
{
/** @var Response $actual */
$actual = $queryHandler($query);

$this->assertEquals($expected, $actual);
Expand Down
Loading