Skip to content

Commit 3034258

Browse files
committed
Minor: Format code
1 parent fc640ea commit 3034258

22 files changed

+113
-103
lines changed

src/CoreBundle/Controller/Admin/AdminController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public function listResourcesInfo(Request $request, ResourceNodeRepository $reso
9797
->where('rn.resourceType = :type')
9898
->setParameter('type', $resourceTypeId)
9999
->getQuery()
100-
->getResult();
100+
->getResult()
101+
;
101102

102103
$seen = [];
103104
foreach ($resourceLinks as $link) {
@@ -136,7 +137,7 @@ public function listResourcesInfo(Request $request, ResourceNodeRepository $reso
136137
}
137138

138139
$courses = array_values($seen);
139-
usort($courses, fn($a, $b) => strnatcasecmp($a['title'], $b['title']));
140+
usort($courses, fn ($a, $b) => strnatcasecmp($a['title'], $b['title']));
140141
}
141142

142143
return $this->render('@ChamiloCore/Admin/resources_info.html.twig', [

src/CoreBundle/Controller/Api/BaseResourceFileAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function handleCreateFileRequest(
192192
Request $request,
193193
EntityManager $em,
194194
string $fileExistsOption = '',
195-
TranslatorInterface $translator = null
195+
?TranslatorInterface $translator = null
196196
): array {
197197
$contentData = $request->getContent();
198198

@@ -270,7 +270,7 @@ public function handleCreateFileRequest(
270270
$existingDocument->setUploadFile($uploadedFile);
271271
}
272272

273-
$resourceNode->setUpdatedAt(new \DateTime());
273+
$resourceNode->setUpdatedAt(new DateTime());
274274
$existingDocument->setResourceNode($resourceNode);
275275

276276
$em->persist($existingDocument);

src/CoreBundle/Controller/Api/CreateSessionWithUsersAndCoursesAction.php

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
use Chamilo\CoreBundle\Entity\Session;
1212
use Chamilo\CoreBundle\Entity\SessionCategory;
1313
use Chamilo\CoreBundle\Entity\SessionRelCourse;
14-
use Chamilo\CoreBundle\Entity\SessionRelUser;
1514
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
15+
use Chamilo\CoreBundle\Entity\SessionRelUser;
1616
use Chamilo\CoreBundle\Repository\Node\CourseRepository;
1717
use Chamilo\CoreBundle\Repository\Node\UserRepository;
18+
use DateTime;
1819
use Doctrine\ORM\EntityManagerInterface;
20+
use RuntimeException;
1921
use Symfony\Component\HttpKernel\Attribute\AsController;
2022

2123
#[AsController]
@@ -37,22 +39,23 @@ public function __invoke(CreateSessionWithUsersAndCoursesInput $data): Session
3739
->setTitle($data->getTitle())
3840
->setDescription($data->getDescription() ?? '')
3941
->setVisibility($data->getVisibility() ?? 1)
40-
->setNbrCourses(count($data->getCourseIds()))
41-
->setNbrUsers(count($data->getStudentIds()) + count($data->getTutorIds()))
42+
->setNbrCourses(\count($data->getCourseIds()))
43+
->setNbrUsers(\count($data->getStudentIds()) + \count($data->getTutorIds()))
4244
->setShowDescription($data->getShowDescription() ?? false)
4345
->setDuration($data->getDuration() ?? 0)
44-
->setDisplayStartDate($data->getDisplayStartDate() ?? new \DateTime())
45-
->setDisplayEndDate($data->getDisplayEndDate() ?? new \DateTime())
46-
->setAccessStartDate($data->getAccessStartDate() ?? new \DateTime())
47-
->setAccessEndDate($data->getAccessEndDate() ?? new \DateTime())
48-
->setCoachAccessStartDate($data->getCoachAccessStartDate() ?? new \DateTime())
49-
->setCoachAccessEndDate($data->getCoachAccessEndDate() ?? new \DateTime())
50-
->setValidityInDays($data->getValidityInDays() ?? 0);
46+
->setDisplayStartDate($data->getDisplayStartDate() ?? new DateTime())
47+
->setDisplayEndDate($data->getDisplayEndDate() ?? new DateTime())
48+
->setAccessStartDate($data->getAccessStartDate() ?? new DateTime())
49+
->setAccessEndDate($data->getAccessEndDate() ?? new DateTime())
50+
->setCoachAccessStartDate($data->getCoachAccessStartDate() ?? new DateTime())
51+
->setCoachAccessEndDate($data->getCoachAccessEndDate() ?? new DateTime())
52+
->setValidityInDays($data->getValidityInDays() ?? 0)
53+
;
5154

5255
if ($data->getCategory()) {
5356
$category = $this->em->getRepository(SessionCategory::class)->find($data->getCategory());
5457
if (!$category) {
55-
throw new \RuntimeException("Invalid category ID: " . $data->getCategory());
58+
throw new RuntimeException('Invalid category ID: '.$data->getCategory());
5659
}
5760
$session->setCategory($category);
5861
}
@@ -88,7 +91,8 @@ public function __invoke(CreateSessionWithUsersAndCoursesInput $data): Session
8891
$rel
8992
->setSession($session)
9093
->setUser($user)
91-
->setRelationType(Session::STUDENT);
94+
->setRelationType(Session::STUDENT)
95+
;
9296

9397
$this->em->persist($rel);
9498

@@ -101,7 +105,8 @@ public function __invoke(CreateSessionWithUsersAndCoursesInput $data): Session
101105
->setStatus(Session::STUDENT)
102106
->setVisibility(1)
103107
->setProgress(0)
104-
->setLegalAgreement(0);
108+
->setLegalAgreement(0)
109+
;
105110

106111
$this->em->persist($relCourseUser);
107112

@@ -123,7 +128,8 @@ public function __invoke(CreateSessionWithUsersAndCoursesInput $data): Session
123128
$rel
124129
->setSession($session)
125130
->setUser($user)
126-
->setRelationType(Session::SESSION_ADMIN);
131+
->setRelationType(Session::SESSION_ADMIN)
132+
;
127133

128134
$this->em->persist($rel);
129135
}

src/CoreBundle/Controller/CatalogueController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function listSessions(): JsonResponse
100100
$session = $rel->getSession();
101101
$usergroup = $rel->getUsergroup();
102102

103-
if (null === $usergroup || in_array($usergroup->getId(), $userGroupIds)) {
103+
if (null === $usergroup || \in_array($usergroup->getId(), $userGroupIds)) {
104104
$visibleSessions[$session->getId()] = $session;
105105
}
106106
}
@@ -143,7 +143,8 @@ public function listSessions(): JsonResponse
143143
->andWhere('v.course IS NULL')
144144
->setParameter('session', $session->getId())
145145
->getQuery()
146-
->getSingleScalarResult();
146+
->getSingleScalarResult()
147+
;
147148

148149
return [
149150
'id' => $session->getId(),

src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public static function getExistingSettings(): array
246246
[
247247
'name' => 'access_url_specific_files',
248248
'title' => 'Enable URL-specific files',
249-
'comment' => 'When this feature is enabled on a multi-URL configuration, you can go to the main URL and provide URL-specific versions of any file (in the documents tool). The original file will be replaced by the alternative whenever seeing it from a different URL. This allows you to customize each URL even further, while enjoying the advantage of re-using the same courses many times.'
249+
'comment' => 'When this feature is enabled on a multi-URL configuration, you can go to the main URL and provide URL-specific versions of any file (in the documents tool). The original file will be replaced by the alternative whenever seeing it from a different URL. This allows you to customize each URL even further, while enjoying the advantage of re-using the same courses many times.',
250250
],
251251
[
252252
'name' => 'allow_course_theme',
@@ -1054,12 +1054,12 @@ public static function getExistingSettings(): array
10541054
[
10551055
'name' => 'donotlistcampus',
10561056
'title' => 'Do not list this campus on chamilo.org',
1057-
'comment' => 'By default, Chamilo portals are automatically registered in a public list at chamilo.org, just using the title you gave to this portal (not the URL nor any private data). Check this box to avoid having the title of your portal appear.'
1057+
'comment' => 'By default, Chamilo portals are automatically registered in a public list at chamilo.org, just using the title you gave to this portal (not the URL nor any private data). Check this box to avoid having the title of your portal appear.',
10581058
],
10591059
[
10601060
'name' => 'timezone',
10611061
'title' => 'Default timezone',
1062-
'comment' => 'Select the default timezone for this portal. This will help set the timezone (if the feature is enabled) for each new user or for any user that has not set a specific timezone yet. Timezones help show all time-related information on screen in the specific timezone of each user.'
1062+
'comment' => 'Select the default timezone for this portal. This will help set the timezone (if the feature is enabled) for each new user or for any user that has not set a specific timezone yet. Timezones help show all time-related information on screen in the specific timezone of each user.',
10631063
],
10641064
[
10651065
'name' => 'chamilo_database_version',

src/CoreBundle/DataTransformer/CalendarEventTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private function mapCCalendarToDto(CCalendarEvent $object): CalendarEvent
4545

4646
$eventType = $object->determineType();
4747
$color = trim((string) $object->getColor());
48-
$color = $color !== '' ? $color : $this->determineEventColor($eventType);
48+
$color = '' !== $color ? $color : $this->determineEventColor($eventType);
4949

5050
$calendarEvent = new CalendarEvent(
5151
'calendar_event_'.$object->getIid(),

src/CoreBundle/Dto/CreateSessionWithUsersAndCoursesInput.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Chamilo\CoreBundle\Dto;
88

99
use ApiPlatform\Metadata\ApiResource;
10+
use DateTime;
1011
use Symfony\Component\Serializer\Annotation\Groups;
1112
use Symfony\Component\Validator\Constraints as Assert;
1213

@@ -30,22 +31,22 @@ class CreateSessionWithUsersAndCoursesInput
3031
private ?int $duration = 0;
3132

3233
#[Groups(['write'])]
33-
private ?\DateTime $displayStartDate = null;
34+
private ?DateTime $displayStartDate = null;
3435

3536
#[Groups(['write'])]
36-
private ?\DateTime $displayEndDate = null;
37+
private ?DateTime $displayEndDate = null;
3738

3839
#[Groups(['write'])]
39-
private ?\DateTime $accessStartDate = null;
40+
private ?DateTime $accessStartDate = null;
4041

4142
#[Groups(['write'])]
42-
private ?\DateTime $accessEndDate = null;
43+
private ?DateTime $accessEndDate = null;
4344

4445
#[Groups(['write'])]
45-
private ?\DateTime $coachAccessStartDate = null;
46+
private ?DateTime $coachAccessStartDate = null;
4647

4748
#[Groups(['write'])]
48-
private ?\DateTime $coachAccessEndDate = null;
49+
private ?DateTime $coachAccessEndDate = null;
4950

5051
#[Groups(['write'])]
5152
private ?int $category = null;
@@ -105,62 +106,62 @@ public function setDuration(?int $duration): void
105106
$this->duration = $duration;
106107
}
107108

108-
public function getDisplayStartDate(): ?\DateTime
109+
public function getDisplayStartDate(): ?DateTime
109110
{
110111
return $this->displayStartDate;
111112
}
112113

113-
public function setDisplayStartDate(?\DateTime $displayStartDate): void
114+
public function setDisplayStartDate(?DateTime $displayStartDate): void
114115
{
115116
$this->displayStartDate = $displayStartDate;
116117
}
117118

118-
public function getDisplayEndDate(): ?\DateTime
119+
public function getDisplayEndDate(): ?DateTime
119120
{
120121
return $this->displayEndDate;
121122
}
122123

123-
public function setDisplayEndDate(?\DateTime $displayEndDate): void
124+
public function setDisplayEndDate(?DateTime $displayEndDate): void
124125
{
125126
$this->displayEndDate = $displayEndDate;
126127
}
127128

128-
public function getAccessStartDate(): ?\DateTime
129+
public function getAccessStartDate(): ?DateTime
129130
{
130131
return $this->accessStartDate;
131132
}
132133

133-
public function setAccessStartDate(?\DateTime $accessStartDate): void
134+
public function setAccessStartDate(?DateTime $accessStartDate): void
134135
{
135136
$this->accessStartDate = $accessStartDate;
136137
}
137138

138-
public function getAccessEndDate(): ?\DateTime
139+
public function getAccessEndDate(): ?DateTime
139140
{
140141
return $this->accessEndDate;
141142
}
142143

143-
public function setAccessEndDate(?\DateTime $accessEndDate): void
144+
public function setAccessEndDate(?DateTime $accessEndDate): void
144145
{
145146
$this->accessEndDate = $accessEndDate;
146147
}
147148

148-
public function getCoachAccessStartDate(): ?\DateTime
149+
public function getCoachAccessStartDate(): ?DateTime
149150
{
150151
return $this->coachAccessStartDate;
151152
}
152153

153-
public function setCoachAccessStartDate(?\DateTime $coachAccessStartDate): void
154+
public function setCoachAccessStartDate(?DateTime $coachAccessStartDate): void
154155
{
155156
$this->coachAccessStartDate = $coachAccessStartDate;
156157
}
157158

158-
public function getCoachAccessEndDate(): ?\DateTime
159+
public function getCoachAccessEndDate(): ?DateTime
159160
{
160161
return $this->coachAccessEndDate;
161162
}
162163

163-
public function setCoachAccessEndDate(?\DateTime $coachAccessEndDate): void
164+
public function setCoachAccessEndDate(?DateTime $coachAccessEndDate): void
164165
{
165166
$this->coachAccessEndDate = $coachAccessEndDate;
166167
}

src/CoreBundle/Entity/User.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,8 +1609,7 @@ public function eraseCredentials(): void
16091609
}
16101610

16111611
/**
1612-
* Returns whether a user can be admin of all multi-URL portals in the case of a multi-URL install
1613-
* @return bool
1612+
* Returns whether a user can be admin of all multi-URL portals in the case of a multi-URL install.
16141613
*/
16151614
public function isSuperAdmin(): bool
16161615
{

src/CoreBundle/EventListener/UserRelCourseVoteListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
use Chamilo\CoreBundle\Entity\UserRelCourseVote;
1010
use Doctrine\ORM\EntityManagerInterface;
11-
use Doctrine\ORM\Event\LifecycleEventArgs;
1211
use Doctrine\ORM\Event\PostPersistEventArgs;
1312
use Doctrine\ORM\Event\PostUpdateEventArgs;
1413
use Doctrine\ORM\NonUniqueResultException;
@@ -44,7 +43,8 @@ private function updateCoursePopularity(UserRelCourseVote $vote, EntityManagerIn
4443
->where('v.course = :course')
4544
->setParameter('course', $course->getId())
4645
->getQuery()
47-
->getSingleScalarResult();
46+
->getSingleScalarResult()
47+
;
4848

4949
$course->setPopularity($uniqueUsers);
5050
$entityManager->persist($course);

src/CoreBundle/Filter/SidFilter.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ public function getDescription(string $resourceClass): array
4848
}
4949

5050
/**
51+
* @param mixed $value
52+
*
5153
* @throws ReflectionException
5254
*/
5355
protected function filterProperty(
5456
string $property,
55-
$value,
57+
$value,
5658
QueryBuilder $queryBuilder,
5759
QueryNameGeneratorInterface $queryNameGenerator,
5860
string $resourceClass,
@@ -75,11 +77,11 @@ protected function filterProperty(
7577

7678
$joins = $queryBuilder->getDQLPart('join');
7779

78-
if (empty($joins[$alias]) || !array_filter($joins[$alias], fn($j) => $j->getAlias() === 'resourceNode')) {
79-
$queryBuilder->leftJoin($alias . '.resourceNode', 'resourceNode');
80+
if (empty($joins[$alias]) || !array_filter($joins[$alias], fn ($j) => 'resourceNode' === $j->getAlias())) {
81+
$queryBuilder->leftJoin($alias.'.resourceNode', 'resourceNode');
8082
}
8183

82-
if (empty($joins['resourceNode']) || !array_filter($joins['resourceNode'], fn($j) => $j->getAlias() === 'resourceLink')) {
84+
if (empty($joins['resourceNode']) || !array_filter($joins['resourceNode'], fn ($j) => 'resourceLink' === $j->getAlias())) {
8385
$queryBuilder->leftJoin('resourceNode.resourceLinks', 'resourceLink');
8486
}
8587

@@ -100,7 +102,8 @@ protected function filterProperty(
100102
} else {
101103
$queryBuilder
102104
->andWhere('resourceLink.session = :session')
103-
->setParameter('session', $session->getId());
105+
->setParameter('session', $session->getId())
106+
;
104107
}
105108
}
106109
}

0 commit comments

Comments
 (0)