Skip to content

Commit 1b5ad88

Browse files
committed
Fix Psalm errors
1 parent 07d19de commit 1b5ad88

File tree

6 files changed

+31
-12
lines changed

6 files changed

+31
-12
lines changed

src/CoreBundle/Controller/ChatController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function globalStart(): JsonResponse
229229
}
230230

231231
if (\is_string($ret)) {
232-
return JsonResponse::fromJsonString($ret);
232+
return JsonResponse::fromJsonString((string) $ret);
233233
}
234234

235235
return new JsonResponse($ret ?? []);

src/CoreBundle/Framework/Container.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
use Chamilo\CourseBundle\Repository\CCalendarEventRepository;
5959
use Chamilo\CourseBundle\Repository\CCourseDescriptionRepository;
6060
use Chamilo\CourseBundle\Repository\CDocumentRepository;
61+
use Chamilo\CourseBundle\Repository\CDropboxFileRepository;
6162
use Chamilo\CourseBundle\Repository\CForumAttachmentRepository;
6263
use Chamilo\CourseBundle\Repository\CForumCategoryRepository;
6364
use Chamilo\CourseBundle\Repository\CForumPostRepository;
@@ -480,9 +481,9 @@ public static function getNotebookRepository(): CNotebookRepository
480481
return self::$container->get(CNotebookRepository::class);
481482
}
482483

483-
public static function getDropboxFileRepository(): CDropboxFile
484+
public static function getDropboxFileRepository(): CDropboxFileRepository
484485
{
485-
return self::$container->get(CDropboxFile::class);
486+
return self::$container->get(CDropboxFileRepository::class);
486487
}
487488

488489
public static function getPersonalFileRepository(): PersonalFileRepository

src/CoreBundle/State/CBlogAssignAuthorProcessor.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
use Symfony\Bundle\SecurityBundle\Security;
1717

1818
/**
19-
* Assigns current authenticated user as author on POST if none provided.
19+
* Assigns the current authenticated user as author on POST if none provided.
20+
*
21+
* @implements ProcessorInterface<CBlogPost|CBlogComment|CBlogTask, CBlogPost|CBlogComment|CBlogTask>
2022
*/
2123
final readonly class CBlogAssignAuthorProcessor implements ProcessorInterface
2224
{

src/CoreBundle/State/LpCollectionStateProvider.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
use Doctrine\ORM\EntityManagerInterface;
1717
use Symfony\Bundle\SecurityBundle\Security;
1818

19-
final class LpCollectionStateProvider implements ProviderInterface
19+
/**
20+
* @template-implements ProviderInterface<CLp>
21+
*/
22+
final readonly class LpCollectionStateProvider implements ProviderInterface
2023
{
2124
public function __construct(
22-
private readonly EntityManagerInterface $em,
23-
private readonly CLpRepository $lpRepo,
24-
private readonly Security $security
25+
private EntityManagerInterface $em,
26+
private CLpRepository $lpRepo,
27+
private Security $security
2528
) {}
2629

2730
public function supports(Operation $op, array $uriVariables = [], array $ctx = []): bool

src/CoreBundle/State/UserSessionSubscriptionsStateProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(
3535
/**
3636
* @throws Exception
3737
*/
38-
public function provide(Operation $operation, array $uriVariables = [], array $context = []): iterable
38+
public function provide(Operation $operation, array $uriVariables = [], array $context = []): array
3939
{
4040
$user = $this->userRepository->find($uriVariables['id']);
4141

tests/CoreBundle/Security/Authorization/Voter/CourseVoterTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,34 @@
1111
use Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter;
1212
use Chamilo\Tests\ChamiloTestTrait;
1313
use Doctrine\ORM\EntityManagerInterface;
14+
use Doctrine\ORM\Exception\ORMException;
15+
use Doctrine\ORM\OptimisticLockException;
16+
use Generator;
1417
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
18+
use Symfony\Bundle\SecurityBundle\Security;
1519
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
16-
use Symfony\Component\Security\Core\Security;
1720

1821
class CourseVoterTest extends WebTestCase
1922
{
2023
use ChamiloTestTrait;
2124

2225
// @dataProvider provideVoteTests not working
26+
27+
/**
28+
* @throws OptimisticLockException
29+
* @throws ORMException
30+
*/
2331
public function testVote(): void
2432
{
2533
$client = static::createClient();
2634
$tests = $this->provideVoteTests();
2735
$entity_manager = $this->getContainer()->get(EntityManagerInterface::class);
36+
$translator = $this->getContainer()->get('translator');
2837
$request_stack = $this->getMockedRequestStack([
2938
'query' => ['sid' => 1],
3039
]);
3140
$security = $this->getContainer()->get(Security::class);
32-
$voter = new CourseVoter($security, $request_stack, $entity_manager);
41+
$voter = new CourseVoter($security, $translator, $request_stack, $entity_manager);
3342
foreach ($tests as $message => $test) {
3443
[$expected, $user, $course] = $test;
3544
$client->loginUser($user);
@@ -38,7 +47,11 @@ public function testVote(): void
3847
}
3948
}
4049

41-
public function provideVoteTests()
50+
/**
51+
* @throws ORMException
52+
* @throws OptimisticLockException
53+
*/
54+
public function provideVoteTests(): Generator
4255
{
4356
$em = $this->getEntityManager();
4457
$admin = $this->getAdmin();

0 commit comments

Comments
 (0)