From f18e52bee909a5a9705b937f5033690053b058ed Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 29 Jan 2021 14:30:18 +0100 Subject: [PATCH] Fix double casting, add property types --- public/main/admin/filler.php | 4 ++-- public/main/admin/statistics/index.php | 2 +- public/main/exercise/exercise.class.php | 1 + public/main/forum/forumfunction.inc.php | 2 +- public/main/gradebook/gradebook_flatview.php | 1 + src/CoreBundle/Entity/Message.php | 22 +++++--------------- src/CoreBundle/Entity/PortfolioCategory.php | 7 +------ src/CoreBundle/Entity/SessionCategory.php | 12 ++++------- 8 files changed, 16 insertions(+), 35 deletions(-) diff --git a/public/main/admin/filler.php b/public/main/admin/filler.php index f7d396425d..9ddc2217fe 100644 --- a/public/main/admin/filler.php +++ b/public/main/admin/filler.php @@ -29,11 +29,11 @@ $output = []; if (!empty($_GET['fill'])) { switch ($_GET['fill']) { case 'users': - require api_get_path(SYS_TEST_PATH).'datafiller/fill_users.php'; + require __DIR__.'/../../../tests/datafiller/fill_users.php'; $output = fill_users(); break; case 'courses': - require api_get_path(SYS_TEST_PATH).'datafiller/fill_courses.php'; + require __DIR__.'/../../../tests/datafiller/fill_courses.php'; $output = fill_courses(); break; default: diff --git a/public/main/admin/statistics/index.php b/public/main/admin/statistics/index.php index ab80238920..7b9c360c7c 100644 --- a/public/main/admin/statistics/index.php +++ b/public/main/admin/statistics/index.php @@ -1132,7 +1132,7 @@ switch ($report) { if ($validDate) { $date1 = new DateTime($row['value']); $interval = $now->diff($date1); - $years = (int) $interval->y; + $years = $interval->y; if ($years >= 16 && $years <= 17) { $all['16-17']++; diff --git a/public/main/exercise/exercise.class.php b/public/main/exercise/exercise.class.php index efe5aba206..0b25d791b5 100644 --- a/public/main/exercise/exercise.class.php +++ b/public/main/exercise/exercise.class.php @@ -6020,6 +6020,7 @@ class Exercise ); } elseif (ORAL_EXPRESSION == $answerType) { $answer = $choice; + /** @var OralExpression $objQuestionTmp */ Event::saveQuestionAttempt( $questionScore, $answer, diff --git a/public/main/forum/forumfunction.inc.php b/public/main/forum/forumfunction.inc.php index 9964332e4b..f1e8a6684f 100644 --- a/public/main/forum/forumfunction.inc.php +++ b/public/main/forum/forumfunction.inc.php @@ -6394,7 +6394,7 @@ function giveRevisionButton($postId, $threadInfo) [ 'forum' => $threadInfo['forum_id'], 'thread' => $threadInfo['thread_id'], - 'post' => $postId = (int) $postId, + 'post' => $postId, 'action' => 'replymessage', 'give_revision' => 1, ] diff --git a/public/main/gradebook/gradebook_flatview.php b/public/main/gradebook/gradebook_flatview.php index 46819bdaff..3ae409a72a 100644 --- a/public/main/gradebook/gradebook_flatview.php +++ b/public/main/gradebook/gradebook_flatview.php @@ -51,6 +51,7 @@ if ($showlink) { $alllinks = $cat[0]->get_links($userId, true); } +global $file_type; if (isset($export_flatview_form) && 'pdf' === !$file_type) { Display::addFlash( Display::return_message( diff --git a/src/CoreBundle/Entity/Message.php b/src/CoreBundle/Entity/Message.php index 36ee78abe4..89c8a4cb57 100644 --- a/src/CoreBundle/Entity/Message.php +++ b/src/CoreBundle/Entity/Message.php @@ -35,27 +35,21 @@ class Message protected $id; /** - * @var User - * * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="sentMessages") * @ORM\JoinColumn(name="user_sender_id", referencedColumnName="id", nullable=false) */ - protected $userSender; + protected User $userSender; /** - * @var User - * * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="receivedMessages") * @ORM\JoinColumn(name="user_receiver_id", referencedColumnName="id", nullable=true) */ - protected $userReceiver; + protected User $userReceiver; /** - * @var bool - * * @ORM\Column(name="msg_status", type="smallint", nullable=false) */ - protected $msgStatus; + protected int $msgStatus; /** * @var \DateTime @@ -176,12 +170,8 @@ class Message /** * Set msgStatus. - * - * @param bool $msgStatus - * - * @return Message */ - public function setMsgStatus($msgStatus) + public function setMsgStatus(int $msgStatus): self { $this->msgStatus = $msgStatus; @@ -190,10 +180,8 @@ class Message /** * Get msgStatus. - * - * @return bool */ - public function getMsgStatus() + public function getMsgStatus(): int { return $this->msgStatus; } diff --git a/src/CoreBundle/Entity/PortfolioCategory.php b/src/CoreBundle/Entity/PortfolioCategory.php index ef41ac7709..4ec5a6391b 100644 --- a/src/CoreBundle/Entity/PortfolioCategory.php +++ b/src/CoreBundle/Entity/PortfolioCategory.php @@ -210,12 +210,7 @@ class PortfolioCategory return $this->items->matching($criteria); } - /** - * Set items. - * - * @return PortfolioCategory - */ - public function setItems(Collection $items) + public function setItems(ArrayCollection $items): self { $this->items = $items; diff --git a/src/CoreBundle/Entity/SessionCategory.php b/src/CoreBundle/Entity/SessionCategory.php index 836117d72e..0800a6c34b 100644 --- a/src/CoreBundle/Entity/SessionCategory.php +++ b/src/CoreBundle/Entity/SessionCategory.php @@ -36,20 +36,19 @@ class SessionCategory * @ORM\ManyToOne(targetEntity="AccessUrl", inversedBy="sessionCategories", cascade={"persist"}) * @ORM\JoinColumn(name="access_url_id", referencedColumnName="id") */ - protected $url; + protected AccessUrl $url; /** * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Session", mappedBy="category") */ - protected $session; + protected Session $session; /** - * @var string * @Assert\NotBlank * @Groups({"session_category:read", "session_category:write"}) * @ORM\Column(name="name", type="string", length=100, nullable=true, unique=false) */ - protected $name; + protected string $name; /** * @var \DateTime @@ -65,10 +64,7 @@ class SessionCategory */ protected $dateEnd; - /** - * @return string - */ - public function __toString() + public function __toString(): string { return (string) $this->name; }