Skip to content

Commit

Permalink
Minor: Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Apr 22, 2024
1 parent 37b2df6 commit 769d176
Show file tree
Hide file tree
Showing 19 changed files with 2,079 additions and 2,088 deletions.
3 changes: 2 additions & 1 deletion src/CoreBundle/Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Chamilo\CoreBundle\Repository\TrackELoginRecordRepository;
use Chamilo\CoreBundle\ServiceHelper\UserHelper;
use Chamilo\CoreBundle\Settings\SettingsManager;
use DateTime;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function loginJson(Request $request, EntityManager $entityManager, Settin
return $this->json(['error' => $message], 401);
}

if (null !== $user->getExpirationDate() && $user->getExpirationDate() <= new \DateTime()) {
if (null !== $user->getExpirationDate() && $user->getExpirationDate() <= new DateTime()) {
$message = $translator->trans('Your account has expired.');

$tokenStorage->setToken(null);
Expand Down
6 changes: 4 additions & 2 deletions src/CoreBundle/DataFixtures/ExtraFieldFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,8 @@ public function load(ObjectManager $manager): void
->setItemType($data['item_type'])
->setValueType($data['value_type'])
->setChangeable($data['changeable'] ?? false)
->setVisibleToSelf($data['visible_to_self'] ?? false);
->setVisibleToSelf($data['visible_to_self'] ?? false)
;

if (isset($data['default_value'])) {
$extraField->setDefaultValue((string) $data['default_value']);
Expand All @@ -857,7 +858,8 @@ public function load(ObjectManager $manager): void
$extraFieldOption = new ExtraFieldOptions();
$extraFieldOption->setField($extraField)
->setDisplayText($option)
->setOptionOrder(array_search($option, $options) + 1);
->setOptionOrder(array_search($option, $options) + 1)
;

$manager->persist($extraFieldOption);
}
Expand Down
4,081 changes: 2,041 additions & 2,040 deletions src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/CoreBundle/Entity/MailTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class MailTemplate
#[ORM\Column(name: 'type', type: 'string', nullable: false)]
protected string $type;

#[ORM\ManyToOne(targetEntity: "User")]
#[ORM\ManyToOne(targetEntity: 'User')]
#[ORM\JoinColumn(name: 'author_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
protected ?User $author = null;

#[ORM\ManyToOne(targetEntity: "AccessUrl")]
#[ORM\ManyToOne(targetEntity: 'AccessUrl')]
#[ORM\JoinColumn(name: 'url_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
protected ?AccessUrl $url = null;

Expand Down
2 changes: 2 additions & 0 deletions src/CoreBundle/Entity/NotificationEventRelUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function getEvent(): NotificationEvent
public function setEvent(NotificationEvent $event): self
{
$this->event = $event;

return $this;
}

Expand All @@ -49,6 +50,7 @@ public function getUser(): User
public function setUser(User $user): self
{
$this->user = $user;

return $this;
}
}
22 changes: 2 additions & 20 deletions src/CoreBundle/Entity/PortfolioCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public function __construct()

/**
* Get id.
*
* @return int|null
*/
public function getId(): ?int
{
Expand All @@ -66,8 +64,6 @@ public function getId(): ?int

/**
* Get title.
*
* @return string
*/
public function getTitle(): string
{
Expand All @@ -76,9 +72,6 @@ public function getTitle(): string

/**
* Set title.
*
* @param string $title
* @return PortfolioCategory
*/
public function setTitle(string $title): self
{
Expand All @@ -94,9 +87,6 @@ public function getDescription(): ?string

/**
* Set description.
*
* @param string|null $description
* @return PortfolioCategory
*/
public function setDescription(?string $description): self
{
Expand All @@ -112,9 +102,6 @@ public function isVisible(): bool

/**
* Set isVisible.
*
* @param bool $isVisible
* @return PortfolioCategory
*/
public function setIsVisible(bool $isVisible): self
{
Expand All @@ -125,11 +112,6 @@ public function setIsVisible(bool $isVisible): self

/**
* Get items.
*
* @param Course|null $course
* @param Session|null $session
* @param bool $onlyVisibles
* @return ArrayCollection
*/
public function getItems(?Course $course = null, ?Session $session = null, bool $onlyVisibles = false): ArrayCollection
{
Expand Down Expand Up @@ -179,7 +161,7 @@ public function getChildren(): Collection
return $this->children;
}

public function addChild(PortfolioCategory $child): self
public function addChild(self $child): self
{
if (!$this->children->contains($child)) {
$this->children[] = $child;
Expand All @@ -189,7 +171,7 @@ public function addChild(PortfolioCategory $child): self
return $this;
}

public function removeChild(PortfolioCategory $child): self
public function removeChild(self $child): self
{
if ($this->children->removeElement($child)) {
if ($child->getParent() === $this) {
Expand Down
2 changes: 1 addition & 1 deletion src/CoreBundle/Entity/PortfolioComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PortfolioComment
public const VISIBILITY_VISIBLE = 1;
public const VISIBILITY_PER_USER = 2;

#[ORM\Column(type: 'smallint', options: ["default" => self::VISIBILITY_VISIBLE])]
#[ORM\Column(type: 'smallint', options: ['default' => self::VISIBILITY_VISIBLE])]
protected int $visibility;

#[ORM\Id]
Expand Down
2 changes: 1 addition & 1 deletion src/CoreBundle/EventListener/CourseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Chamilo\CoreBundle\Security\Authorization\Voter\SessionVoter;
use Chamilo\CourseBundle\Controller\CourseControllerInterface;
use Chamilo\CourseBundle\Entity\CGroup;
use ChamiloSession;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -30,7 +31,6 @@
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;
use ChamiloSession;

/**
* Class CourseListener.
Expand Down
2 changes: 1 addition & 1 deletion src/CoreBundle/Framework/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
use Chamilo\CourseBundle\Repository\CCalendarEventRepository;
use Chamilo\CourseBundle\Repository\CCourseDescriptionRepository;
use Chamilo\CourseBundle\Repository\CDocumentRepository;
use Chamilo\CourseBundle\Repository\CQuizCategoryRepository;
use Chamilo\CourseBundle\Repository\CForumAttachmentRepository;
use Chamilo\CourseBundle\Repository\CForumCategoryRepository;
use Chamilo\CourseBundle\Repository\CForumPostRepository;
Expand All @@ -65,6 +64,7 @@
use Chamilo\CourseBundle\Repository\CLpItemRepository;
use Chamilo\CourseBundle\Repository\CLpRepository;
use Chamilo\CourseBundle\Repository\CNotebookRepository;
use Chamilo\CourseBundle\Repository\CQuizCategoryRepository;
use Chamilo\CourseBundle\Repository\CQuizQuestionCategoryRepository;
use Chamilo\CourseBundle\Repository\CQuizQuestionRepository;
use Chamilo\CourseBundle\Repository\CQuizRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace Chamilo\CoreBundle\Migrations\Schema\V200;

use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Chamilo\CoreBundle\DataFixtures\SettingsCurrentFixtures;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;

class Version20240414120300 extends AbstractMigrationChamilo
Expand Down Expand Up @@ -56,6 +56,7 @@ private function flattenConfigurationSettings(array $categorizedSettings): array
$flattenedSettings[] = $setting;
}
}

return $flattenedSettings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

namespace Chamilo\CoreBundle\Migrations\Schema\V200;

use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Chamilo\CoreBundle\DataFixtures\ExtraFieldFixtures;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use DateTime;
use Doctrine\DBAL\Schema\Schema;

class Version20240416110300 extends AbstractMigrationChamilo
Expand All @@ -23,14 +24,14 @@ public function up(Schema $schema): void

foreach ($extraFields as $field) {
$count = $this->connection->executeQuery(
"SELECT COUNT(*) FROM extra_field WHERE variable = :variable AND item_type = :item_type",
'SELECT COUNT(*) FROM extra_field WHERE variable = :variable AND item_type = :item_type',
[
'variable' => $field['variable'],
'item_type' => $field['item_type'],
]
)->fetchOne();

if ($count == 0) {
if (0 == $count) {
$this->connection->insert('extra_field', [
'item_type' => $field['item_type'],
'value_type' => $field['value_type'],
Expand All @@ -39,7 +40,7 @@ public function up(Schema $schema): void
'visible_to_self' => $field['visible_to_self'] ? 1 : 0,
'changeable' => $field['changeable'] ? 1 : 0,
'filter' => 1,
'created_at' => (new \DateTime())->format('Y-m-d H:i:s'),
'created_at' => (new DateTime())->format('Y-m-d H:i:s'),
]);
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/CoreBundle/Repository/TrackELoginRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use Chamilo\CoreBundle\Entity\User;
use DateTime;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
use Doctrine\Persistence\ManagerRegistry;

class TrackELoginRepository extends ServiceEntityRepository
Expand Down Expand Up @@ -41,7 +39,7 @@ public function updateLastLoginLogoutDate(int $userId, DateTime $logoutDate): vo
['loginDate' => 'DESC']
);

if ($lastLoginRecord !== null) {
if (null !== $lastLoginRecord) {
$lastLoginRecord->setLogoutDate($logoutDate);
$this->_em->flush();
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoreBundle/Settings/AbstractSettingsSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function updateFormFieldsFromSettingsInfo(FormBuilderInterface $builde

$existingHelp = $options['help'] ?? '';
if (!empty($existingHelp)) {
$combinedHelp = $helpFromDb . "<br>" . $existingHelp;
$combinedHelp = $helpFromDb.'<br>'.$existingHelp;
} else {
$combinedHelp = $helpFromDb;
}
Expand Down
13 changes: 8 additions & 5 deletions src/CoreBundle/Settings/SettingsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Exception\ValidatorException;

use const ARRAY_FILTER_USE_KEY;

/**
* Handles the platform settings.
*/
Expand Down Expand Up @@ -150,9 +152,9 @@ public function getSetting(string $name, bool $loadFromDb = false): mixed
$settings = $this->load($category, $name);
if ($settings->has($name)) {
return $settings->get($name);
} else {
return null;
}

return null;
}

$this->loadAll();
Expand All @@ -161,10 +163,10 @@ public function getSetting(string $name, bool $loadFromDb = false): mixed
$settings = $this->schemaList[$category];
if ($settings->has($name)) {
return $settings->get($name);
} else {
error_log("Attempted to access undefined setting '$name' in category '$category'.");
return null;
}
error_log("Attempted to access undefined setting '$name' in category '$category'.");

return null;
}

throw new InvalidArgumentException(sprintf('Category %s not found', $category));
Expand All @@ -179,6 +181,7 @@ public function loadAll(): void
$schemaList = $session->get('schemas');
if (!empty($schemaList)) {
$this->schemaList = $schemaList;

return;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/CoreBundle/State/CalendarEventStateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
namespace Chamilo\CoreBundle\State;

use ApiPlatform\Doctrine\Orm\State\CollectionProvider;
use ApiPlatform\Metadata\CollectionOperationInterface;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use Chamilo\CoreBundle\ApiResource\CalendarEvent;
use Chamilo\CoreBundle\Entity\AccessUrl;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\User;
Expand Down
2 changes: 1 addition & 1 deletion src/CoreBundle/State/UserRelUserStateProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function process($data, Operation $operation, array $uriVariables = [], a

$result = $this->persistProcessor->process($data, $operation, $uriVariables, $context);

assert($result instanceof UserRelUser);
\assert($result instanceof UserRelUser);

if ($operation instanceof Put) {
if (UserRelUser::USER_RELATION_TYPE_FRIEND === $data->getRelationType()) {
Expand Down
4 changes: 3 additions & 1 deletion src/CoreBundle/State/UserStateProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/* For licensing terms, see /license.txt */

namespace Chamilo\CoreBundle\State;
Expand Down Expand Up @@ -29,7 +31,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
if ($operation instanceof CollectionOperationInterface) {
$providedUsers = $this->collectionProvider->provide($operation, $uriVariables, $context);

assert($providedUsers instanceof Paginator);
\assert($providedUsers instanceof Paginator);

/** @var User $user */
foreach ($providedUsers as $user) {
Expand Down
2 changes: 1 addition & 1 deletion src/CoreBundle/Tool/Exercise.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace Chamilo\CoreBundle\Tool;

use Chamilo\CourseBundle\Entity\CQuizCategory;
use Chamilo\CourseBundle\Entity\CQuiz;
use Chamilo\CourseBundle\Entity\CQuizCategory;
use Chamilo\CourseBundle\Entity\CQuizQuestion;
use Chamilo\CourseBundle\Entity\CQuizQuestionCategory;

Expand Down
2 changes: 1 addition & 1 deletion tests/CourseBundle/Repository/CQuizRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace Chamilo\Tests\CourseBundle\Repository;

use Chamilo\CourseBundle\Entity\CQuizCategory;
use Chamilo\CourseBundle\Entity\CQuiz;
use Chamilo\CourseBundle\Entity\CQuizCategory;
use Chamilo\CourseBundle\Repository\CQuizRepository;
use Chamilo\Tests\AbstractApiTest;
use Chamilo\Tests\ChamiloTestTrait;
Expand Down

0 comments on commit 769d176

Please sign in to comment.