Fix argument types and return types

pull/5042/head
Angel Fernando Quiroz Campos 11 months ago
parent ec44f8e63b
commit cd318ea1ed
  1. 28
      psalm.xml
  2. 4
      src/CoreBundle/Component/Utils/NameConvention.php
  3. 2
      src/CoreBundle/Controller/Admin/IndexBlocksController.php
  4. 10
      src/CoreBundle/DataFixtures/SequenceFixtures.php
  5. 6
      src/CoreBundle/Entity/BranchSync.php
  6. 6
      src/CoreBundle/Entity/CourseCategory.php
  7. 42
      src/CoreBundle/Entity/ExtraField.php
  8. 4
      src/CoreBundle/Entity/PageCategory.php
  9. 5
      src/CoreBundle/Entity/PortfolioComment.php
  10. 11
      src/CoreBundle/Entity/SequenceCondition.php
  11. 8
      src/CoreBundle/Entity/SequenceMethod.php
  12. 44
      src/CoreBundle/Entity/SequenceValue.php
  13. 20
      src/CoreBundle/Entity/Skill.php
  14. 2
      src/CoreBundle/Entity/SkillRelUser.php
  15. 6
      src/CoreBundle/Entity/Tool.php
  16. 2
      src/CoreBundle/Entity/User.php
  17. 20
      src/CoreBundle/Entity/Usergroup.php
  18. 2
      src/CoreBundle/Form/ContactType.php
  19. 2
      src/CoreBundle/Form/ExtraFieldType.php
  20. 6
      src/CoreBundle/Framework/Container.php
  21. 8
      src/CoreBundle/Migrations/AbstractMigrationChamilo.php
  22. 6
      src/CourseBundle/Entity/CForum.php
  23. 4
      src/CourseBundle/Entity/CForumCategory.php
  24. 8
      src/CourseBundle/Entity/CForumThread.php
  25. 8
      src/CourseBundle/Entity/CGroup.php
  26. 8
      src/CourseBundle/Entity/CLpCategory.php
  27. 6
      src/CourseBundle/Entity/CQuiz.php
  28. 4
      src/CourseBundle/Entity/CQuizQuestionCategory.php
  29. 12
      src/CourseBundle/Entity/CSurveyQuestion.php
  30. 8
      src/CourseBundle/Entity/CThematic.php

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="7"
errorLevel="6"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
@ -151,38 +151,16 @@
<directory name="vendor"/>
<directory name="src/CoreBundle/Component/Editor"/>
<directory name="src/CoreBundle/Hook"/>
<directory name="src/CourseBundle/Component/CourseCopy"/>
<directory name="src/LtiBundle"/>
<directory name="public/main/inc/lib/javascript"/>
<directory name="public/main/inc/lib/kses-0.2.2"/>
<directory name="public/main/inc/lib/nusoap"/>
<directory name="public/main/inc/lib/pear"/>
<directory name="public/main/inc/lib/ppt2png"/>
<directory name="public/main/inc/lib/search"/>
<directory name="public/main/inc/lib/zombie"/>
<directory name="public/main/exercise/export/qti2"/>
<file name="public/main/admin/index.php"/>
<file name="public/main/admin/settings.php"/>
<file name="public/main/admin/periodic_export.php"/>
<file name="public/main/admin/user_move_stats.php"/>
<file name="public/main/admin/settings.lib.php"/>
<file name="public/main/admin/user_update_import.php"/>
<file name="public/main/admin/teachers_time_by_session_report.php"/>
<file name="public/main/admin/specific_fields.php"/>
<file name="public/main/admin/sub_language*"/>
<file name="public/main/admin/ldap_*"/>
<file name="public/main/admin/special_exports.php"/>
<file name="public/main/**/**"/>
<file name="public/main/lp/openoffice_presentation.class.php"/>
<file name="public/main/lp/openoffice_document.class.php"/>
<file name="public/main/lp/openoffice_text.class.php"/>
<file name="public/main/lp/openoffice_text_document.class.php"/>
<file name="public/main/lp/aicc.class.php"/>
<file name="public/main/exercise/admin.php"/>
<file name="public/main/survey/survey_list.php"/>
<file name="src/CoreBundle/Component/Utils/AssetDirectoryNamer.php"/>
<file name="src/CoreBundle/Controller/EditorController.php"/>

@ -22,9 +22,9 @@ class NameConvention
{
$format = $this->getFormat()['format'];
$personName = str_replace(
$personName = (string) str_replace(
['title ', 'first_name', 'last_name'],
['', $user->getFirstname(), $user->getLastname()],
['', (string) $user->getFirstname(), (string) $user->getLastname()],
$format
);

@ -673,7 +673,7 @@ class IndexBlocksController extends BaseController
private function getItemsChamilo(): array
{
$languageInterface = 'english';
$languageInterface = api_get_language_isocode();
$items = [];
$items[] = [

@ -32,8 +32,8 @@ class SequenceFixtures extends Fixture
$sequenceCondition1 = (new SequenceCondition())
->setDescription('<= 100%')
->setMathOperation('<=')
->setParam('100.0')
->setActTrue('2')
->setParam(100.0)
->setActTrue(2)
->setActFalse('0')
;
$manager->persist($sequenceCondition1);
@ -41,8 +41,8 @@ class SequenceFixtures extends Fixture
$sequenceCondition2 = (new SequenceCondition())
->setDescription('>= 70%')
->setMathOperation('>=')
->setParam('70.0')
->setActTrue('0')
->setParam(70.0)
->setActTrue(0)
->setActFalse('')
;
$manager->persist($sequenceCondition2);
@ -150,7 +150,7 @@ class SequenceFixtures extends Fixture
$sequenceMethod = (new SequenceMethod())
->setDescription($item['description'])
->setFormula($item['formula'])
->setAssign((string) $item['assign'])
->setAssign((int) $item['assign'])
->setMetType($item['met_type'])
->setActFalse($item['act_false'])
;

@ -171,8 +171,6 @@ class BranchSync
/**
* Get latitude.
*
* @return float
*/
public function getLatitude(): ?string
{
@ -188,10 +186,8 @@ class BranchSync
/**
* Get longitude.
*
* @return float
*/
public function getLongitude()
public function getLongitude(): ?string
{
return $this->longitude;
}

@ -65,7 +65,7 @@ class CourseCategory implements Stringable
protected ?int $id = null;
/**
* @var Collection|CourseCategory[]
* @var Collection<int, CourseCategory>
*/
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
protected Collection $children;
@ -152,9 +152,9 @@ class CourseCategory implements Stringable
}
/**
* @return Collection
* @return Collection<int, CourseCategory>
*/
public function getChildren()
public function getChildren(): Collection
{
return $this->children;
}

@ -96,7 +96,7 @@ class ExtraField
protected Collection $options;
/**
* @var Tag[]|Collection
* @var Collection<int, Tag>
*/
#[ORM\OneToMany(targetEntity: Tag::class, mappedBy: 'field')]
protected Collection $tags;
@ -114,12 +114,7 @@ class ExtraField
$this->filter = false;
}
/**
* Get id.
*
* @return int
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
@ -144,10 +139,7 @@ class ExtraField
return $this;
}
/**
* @return string
*/
public function getVariable()
public function getVariable(): string
{
return $this->variable;
}
@ -158,10 +150,7 @@ class ExtraField
return $this;
}
/**
* @return string
*/
public function getDisplayText()
public function getDisplayText(): ?string
{
return $this->displayText;
}
@ -172,10 +161,7 @@ class ExtraField
return $this;
}
/**
* @return string
*/
public function getDefaultValue()
public function getDefaultValue(): ?string
{
return $this->defaultValue;
}
@ -186,10 +172,7 @@ class ExtraField
return $this;
}
/**
* @return int
*/
public function getFieldOrder()
public function getFieldOrder(): ?int
{
return $this->fieldOrder;
}
@ -200,10 +183,7 @@ class ExtraField
return $this;
}
/**
* @return bool
*/
public function isChangeable()
public function isChangeable(): ?bool
{
return $this->changeable;
}
@ -269,9 +249,9 @@ class ExtraField
}
/**
* @return Tag[]|Collection
* @return Collection<int, Tag>
*/
public function getTags(): array|Collection
public function getTags(): Collection
{
return $this->tags;
}
@ -306,13 +286,13 @@ class ExtraField
return $this;
}
public function setTranslatableLocale($locale)
public function setTranslatableLocale($locale): static
{
$this->locale = $locale;
return $this;
}
public function getTranslatableLocale()
public function getTranslatableLocale(): ?string
{
return $this->locale;
}

@ -102,9 +102,9 @@ class PageCategory
}
/**
* @return ArrayCollection<int, Page>
* @return Collection<int, Page>
*/
public function getPages(): ArrayCollection
public function getPages(): Collection
{
return $this->pages;
}

@ -8,6 +8,7 @@ namespace Chamilo\CoreBundle\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
@ -71,7 +72,7 @@ class PortfolioComment
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')]
#[ORM\OrderBy(['lft' => 'DESC'])]
private ArrayCollection $children;
private Collection $children;
#[ORM\Column(type: 'float', nullable: true)]
private ?float $score;
@ -151,7 +152,7 @@ class PortfolioComment
return $this;
}
public function getChildren(): ArrayCollection
public function getChildren(): Collection
{
return $this->children;
}

@ -72,9 +72,6 @@ class SequenceCondition
return $this;
}
/**
* @return string
*/
public function getParam(): float
{
return $this->param;
@ -87,9 +84,6 @@ class SequenceCondition
return $this;
}
/**
* @return string
*/
public function getActTrue(): int
{
return $this->actTrue;
@ -102,10 +96,7 @@ class SequenceCondition
return $this;
}
/**
* @return string
*/
public function getActFalse()
public function getActFalse(): string
{
return $this->actFalse;
}

@ -72,9 +72,6 @@ class SequenceMethod
return $this;
}
/**
* @return string
*/
public function getAssign(): int
{
return $this->assign;
@ -87,10 +84,7 @@ class SequenceMethod
return $this;
}
/**
* @return string
*/
public function getMetType()
public function getMetType(): string
{
return $this->metType;
}

@ -53,12 +53,7 @@ class SequenceValue
#[ORM\Column(name: 'available_end_date', type: 'datetime', nullable: true)]
protected ?DateTime $availableEndDate = null;
/**
* Get id.
*
* @return int
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
@ -75,17 +70,11 @@ class SequenceValue
return $this;
}
/**
* @return int
*/
public function getAdvance(): float
{
return $this->advance;
}
/**
* @return SequenceValue
*/
public function setAdvance(float $advance): static
{
$this->advance = $advance;
@ -93,10 +82,7 @@ class SequenceValue
return $this;
}
/**
* @return int
*/
public function getCompleteItems()
public function getCompleteItems(): int
{
return $this->completeItems;
}
@ -108,10 +94,7 @@ class SequenceValue
return $this;
}
/**
* @return int
*/
public function getTotalItems()
public function getTotalItems(): int
{
return $this->totalItems;
}
@ -123,9 +106,6 @@ class SequenceValue
return $this;
}
/**
* @return int
*/
public function getSuccess(): bool
{
return $this->success;
@ -138,10 +118,7 @@ class SequenceValue
return $this;
}
/**
* @return DateTime
*/
public function getSuccessDate()
public function getSuccessDate(): ?DateTime
{
return $this->successDate;
}
@ -153,9 +130,6 @@ class SequenceValue
return $this;
}
/**
* @return int
*/
public function getAvailable(): bool
{
return $this->available;
@ -168,10 +142,7 @@ class SequenceValue
return $this;
}
/**
* @return DateTime
*/
public function getAvailableStartDate()
public function getAvailableStartDate(): ?DateTime
{
return $this->availableStartDate;
}
@ -183,10 +154,7 @@ class SequenceValue
return $this;
}
/**
* @return DateTime
*/
public function getAvailableEndDate()
public function getAvailableEndDate(): ?DateTime
{
return $this->availableEndDate;
}

@ -34,31 +34,31 @@ class Skill implements Stringable
protected ?Profile $profile = null;
/**
* @var SkillRelUser[]|Collection
* @var Collection<int, SkillRelUser>
*/
#[ORM\OneToMany(targetEntity: SkillRelUser::class, mappedBy: 'skill', cascade: ['persist'])]
protected Collection $issuedSkills;
/**
* @var Collection|SkillRelItem[]
* @var Collection<int, SkillRelItem>
*/
#[ORM\OneToMany(targetEntity: SkillRelItem::class, mappedBy: 'skill', cascade: ['persist'])]
protected Collection $items;
/**
* @var Collection|SkillRelSkill[]
* @var Collection<int, SkillRelSkill>
*/
#[ORM\OneToMany(targetEntity: SkillRelSkill::class, mappedBy: 'skill', cascade: ['persist'])]
protected Collection $skills;
/**
* @var Collection|SkillRelCourse[]
* @var Collection<int, SkillRelCourse>
*/
#[ORM\OneToMany(targetEntity: SkillRelCourse::class, mappedBy: 'skill', cascade: ['persist'])]
protected Collection $courses;
/**
* @var Collection|SkillRelGradebook[]
* @var Collection<int, SkillRelGradebook>
*/
#[ORM\OneToMany(targetEntity: SkillRelGradebook::class, mappedBy: 'skill', cascade: ['persist'])]
protected Collection $gradeBookCategories;
@ -253,19 +253,17 @@ class Skill implements Stringable
}
/**
* Get issuedSkills.
*
* @return Collection
* @return Collection<int, SkillRelUser>
*/
public function getIssuedSkills()
public function getIssuedSkills(): Collection
{
return $this->issuedSkills;
}
/**
* @return Collection
* @return Collection<int, SkillRelItem>
*/
public function getItems()
public function getItems(): Collection
{
return $this->items;
}

@ -46,7 +46,7 @@ class SkillRelUser
protected ?Session $session = null;
/**
* @var Collection|SkillRelUserComment[]
* @var Collection<int, SkillRelUserComment>
*/
#[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\SkillRelUserComment::class, mappedBy: 'skillRelUser', cascade: ['persist', 'remove'], orphanRemoval: true)]
protected Collection $comments;

@ -32,7 +32,7 @@ class Tool implements Stringable
protected string $name;
/**
* @var ResourceType[]|Collection
* @var Collection<int, ResourceType>
*/
#[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\ResourceType::class, mappedBy: 'tool', cascade: ['persist', 'remove'])]
protected Collection $resourceTypes;
@ -99,9 +99,9 @@ class Tool implements Stringable
}
/**
* @return Collection
* @return Collection<int, ResourceType>
*/
public function getResourceTypes()
public function getResourceTypes(): Collection
{
return $this->resourceTypes;
}

@ -2072,7 +2072,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
return $this->templates;
}
public function getDropBoxReceivedFiles(): ArrayCollection|Collection
public function getDropBoxReceivedFiles(): Collection
{
return $this->dropBoxReceivedFiles;
}

@ -98,12 +98,16 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
}
/**
* @return ArrayCollection<int, UsergroupRelUser>
* @return Collection<int, UsergroupRelUser>
*/
public function getUsers(): ArrayCollection
public function getUsers(): Collection
{
return $this->users;
}
/**
* @return Collection<int, AccessUrlRelUserGroup>
*/
public function getUrls(): Collection
{
return $this->urls;
@ -227,9 +231,9 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
}
/**
* @return ArrayCollection<int, UsergroupRelCourse>
* @return Collection<int, UsergroupRelCourse>
*/
public function getCourses(): ArrayCollection
public function getCourses(): Collection
{
return $this->courses;
}
@ -241,9 +245,9 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
}
/**
* @return ArrayCollection<int, UsergroupRelSession>
* @return Collection<int, UsergroupRelSession>
*/
public function getSessions(): ArrayCollection
public function getSessions(): Collection
{
return $this->sessions;
}
@ -255,9 +259,9 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
}
/**
* @return ArrayCollection<int, UsergroupRelQuestion>
* @return Collection<int, UsergroupRelQuestion>
*/
public function getQuestions(): ArrayCollection
public function getQuestions(): Collection
{
return $this->questions;
}

@ -20,7 +20,7 @@ use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @template-extends AbstractType<object>
* @template-extends AbstractType<array>
*/
class ContactType extends AbstractType
{

@ -31,7 +31,7 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\Security\Core\Security;
/**
* @template-extends AbstractType<ExtraField>
* @template-extends AbstractType<array>
*/
class ExtraFieldType extends AbstractType
{

@ -93,6 +93,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
use Symfony\Component\Translation\Translator;
use Twig\Environment;
use UnitEnum;
/**
* Symfony services for the legacy Chamilo code.
@ -112,10 +113,7 @@ class Container
self::$container = $container;
}
/**
* @return array|bool|float|int|string|null
*/
public static function getParameter(string $parameter)
public static function getParameter(string $parameter): UnitEnum|float|array|bool|int|string|null
{
if (self::$container->hasParameter($parameter)) {
return self::$container->getParameter($parameter);

@ -7,6 +7,7 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\AccessUrl;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\ResourceLink;
use Chamilo\CoreBundle\Entity\SettingsCurrent;
@ -121,6 +122,9 @@ abstract class AbstractMigrationChamilo extends AbstractMigration implements Con
$options = []
): void {
$em = $this->getEntityManager();
$accessUrl = $em->find(AccessUrl::class, $accessUrl);
$setting = new SettingsCurrent();
$setting
->setVariable($variable)
@ -133,8 +137,8 @@ abstract class AbstractMigrationChamilo extends AbstractMigration implements Con
->setScope($scope)
->setSubkeytext($subKeyText)
->setUrl($accessUrl)
->setAccessUrlChangeable($accessUrlChangeable)
->setAccessUrlLocked($accessUrlLocked)
->setAccessUrlChangeable((int) $accessUrlChangeable)
->setAccessUrlLocked((int) $accessUrlLocked)
;
$em->persist($setting);

@ -366,7 +366,7 @@ class CForum extends AbstractResource implements ResourceInterface, Stringable
return $this->iid;
}
public function getThreads(): ArrayCollection
public function getThreads(): Collection
{
return $this->threads;
}
@ -396,9 +396,9 @@ class CForum extends AbstractResource implements ResourceInterface, Stringable
}
/**
* @return ArrayCollection<int, CForumPost>
* @return Collection<int, CForumPost>
*/
public function getPosts(): ArrayCollection
public function getPosts(): Collection
{
return $this->posts;
}

@ -111,9 +111,9 @@ class CForumCategory extends AbstractResource implements ResourceInterface, Stri
}
/**
* @return ArrayCollection<int, CForum>
* @return Collection<int, CForum>
*/
public function getForums(): ArrayCollection
public function getForums(): Collection
{
return $this->forums;
}

@ -281,9 +281,9 @@ class CForumThread extends AbstractResource implements ResourceInterface, String
}
/**
* @return ArrayCollection<int, CForumPost>
* @return Collection<int, CForumPost>
*/
public function getPosts(): ArrayCollection
public function getPosts(): Collection
{
return $this->posts;
}
@ -301,9 +301,9 @@ class CForumThread extends AbstractResource implements ResourceInterface, String
}
/**
* @return ArrayCollection<int, CForumThreadQualify>
* @return Collection<int, CForumThreadQualify>
*/
public function getQualifications(): ArrayCollection
public function getQualifications(): Collection
{
return $this->qualifications;
}

@ -260,9 +260,9 @@ class CGroup extends AbstractResource implements ResourceInterface, Stringable
}
/**
* @return ArrayCollection<int, CGroupRelUser>
* @return Collection<int, CGroupRelUser>
*/
public function getMembers(): ArrayCollection
public function getMembers(): Collection
{
return $this->members;
}
@ -297,9 +297,9 @@ class CGroup extends AbstractResource implements ResourceInterface, Stringable
}
/**
* @return ArrayCollection<int, CGroupRelTutor>
* @return Collection<int, CGroupRelTutor>
*/
public function getTutors(): ArrayCollection
public function getTutors(): Collection
{
return $this->tutors;
}

@ -93,17 +93,17 @@ class CLpCategory extends AbstractResource implements ResourceInterface, Stringa
}
/**
* @return ArrayCollection<int, CLp>
* @return Collection<int, CLp>
*/
public function getLps(): ArrayCollection
public function getLps(): Collection
{
return $this->lps;
}
/**
* @return ArrayCollection<int, CLpCategoryRelUser>
* @return Collection<int, CLpCategoryRelUser>
*/
public function getUsers(): ArrayCollection
public function getUsers(): Collection
{
return $this->users;
}

@ -185,7 +185,7 @@ class CQuiz extends AbstractResource implements ResourceInterface, ResourceShowC
/**
* @return ArrayCollection<int, CQuizRelQuestion>
*/
public function getQuestions(): ArrayCollection
public function getQuestions(): Collection
{
return $this->questions instanceof ArrayCollection ?
$this->questions :
@ -616,9 +616,9 @@ class CQuiz extends AbstractResource implements ResourceInterface, ResourceShowC
}
/**
* @return ArrayCollection<int, CQuizRelQuestionCategory>
* @return Collection<int, CQuizRelQuestionCategory>
*/
public function getQuestionsCategories(): ArrayCollection
public function getQuestionsCategories(): Collection
{
return $this->questionsCategories instanceof ArrayCollection ?
$this->questionsCategories :

@ -101,9 +101,9 @@ class CQuizQuestionCategory extends AbstractResource implements ResourceInterfac
}
/**
* @return ArrayCollection<int, CQuizQuestion>
* @return Collection<int, CQuizQuestion>
*/
public function getQuestions(): ArrayCollection
public function getQuestions(): Collection
{
return $this->questions;
}

@ -287,9 +287,9 @@ class CSurveyQuestion
}
/**
* @return ArrayCollection<int, CSurveyQuestion>
* @return Collection<int, CSurveyQuestion>
*/
public function getChildren(): ArrayCollection
public function getChildren(): Collection
{
return $this->children;
}
@ -326,17 +326,17 @@ class CSurveyQuestion
}
/**
* @return ArrayCollection<int, CSurveyAnswer>
* @return Collection<int, CSurveyAnswer>
*/
public function getAnswers(): ArrayCollection
public function getAnswers(): Collection
{
return $this->answers;
}
/**
* @return ArrayCollection<int, CSurveyQuestionOption>
* @return Collection<int, CSurveyQuestionOption>
*/
public function getOptions(): ArrayCollection
public function getOptions(): Collection
{
return $this->options;
}

@ -127,17 +127,17 @@ class CThematic extends AbstractResource implements ResourceInterface, Stringabl
}
/**
* @return ArrayCollection<int, CThematicPlan>
* @return Collection<int, CThematicPlan>
*/
public function getPlans(): ArrayCollection
public function getPlans(): Collection
{
return $this->plans;
}
/**
* @return ArrayCollection<int, CThematicAdvance>
* @return Collection<int, CThematicAdvance>
*/
public function getAdvances(): ArrayCollection
public function getAdvances(): Collection
{
return $this->advances;
}

Loading…
Cancel
Save