Fix psalm errors

pull/3282/head
Julio Montoya 5 years ago
parent ddfd23a186
commit 1a5e2c679b
  1. 1
      composer.json
  2. 2
      config/services.yaml
  3. 4
      psalm.xml
  4. 3
      public/main/session/session_course_user.php
  5. 49
      src/CoreBundle/Entity/User.php
  6. 16
      src/CoreBundle/Repository/UserRepository.php

@ -124,6 +124,7 @@
"sabre/vobject": "~4.2",
"sensio/framework-extra-bundle": "~5.0",
"sensiolabs/security-checker": "~6.0",
"sonata-project/exporter": "^2.2",
"sunra/php-simple-html-dom-parser": "~1.5",
"symfony/apache-pack": "^1.0",
"symfony/asset": "^5.0",

@ -99,8 +99,6 @@ services:
tags:
- {name: security.voter}
sylius_settings:
driver: doctrine/orm

@ -14,10 +14,14 @@
<!-- <directory name="public/main/exercise"/> -->
<ignoreFiles>
<directory name="vendor/*" />
<directory name="src/CoreBundle/Admin" />
<directory name="src/CoreBundle/Block" />
<directory name="src/CoreBundle/Menu" />
<directory name="src/CoreBundle/Migrations" />
<directory name="src/CoreBundle/Component/Editor" />
<!-- <directory name="src/CourseBundle" />-->
<directory name="src/CourseBundle/Component/CourseCopy" />
<directory name="src/CourseBundle/Admin" />
<directory name="src/GraphQlBundle" />
<directory name="src/LtiBundle" />
<file name="public/main/admin/db.php" />

@ -18,8 +18,7 @@ SessionManager::protectSession($id_session);
$id_user = intval($_GET['id_user']);
$em = Database::getManager();
/** @var Session $session */
$session = api_get_session_entity( $id_session);
$session = api_get_session_entity($id_session);
$user = api_get_user_entity($id_user);
if (!api_is_platform_admin() && $session->getSessionAdmin()->getId() != api_get_user_id()) {

@ -53,6 +53,9 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
*/
class User implements UserInterface, EquatableInterface
{
public const ROLE_DEFAULT = 'ROLE_USER';
public const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
public const COURSE_MANAGER = 1;
public const TEACHER = 1;
public const SESSION_ADMIN = 3;
@ -202,6 +205,13 @@ class User implements UserInterface, EquatableInterface
*/
protected $credentialsExpireAt;
/**
* @var \DateTime
*
* @ORM\Column(name="date_of_birth", type="datetime", nullable=true)
*/
protected $dateOfBirth;
/**
* @var \DateTime
* @Groups({"user:read", "user:write"})
@ -1682,6 +1692,25 @@ class User implements UserInterface, EquatableInterface
return $this;
}
/**
* @param string $role
*
* @return $this
*/
public function addRole($role)
{
$role = strtoupper($role);
if ($role === static::ROLE_DEFAULT) {
return $this;
}
if (!in_array($role, $this->roles, true)) {
$this->roles[] = $role;
}
return $this;
}
/**
* Returns the user roles.
*
@ -2169,6 +2198,26 @@ class User implements UserInterface, EquatableInterface
return $this;
}
/**
* @param \DateTime $dateOfBirth
*
* @return User
*/
public function setDateOfBirth($dateOfBirth)
{
$this->dateOfBirth = $dateOfBirth;
return $this;
}
/**
* @return \DateTime
*/
public function getDateOfBirth()
{
return $this->dateOfBirth;
}
public function getCourseGroupsAsTutorFromCourse(Course $course): ArrayCollection
{
$criteria = Criteria::create();

@ -666,22 +666,22 @@ class UserRepository extends ResourceRepository implements UserLoaderInterface,
// Dummy content
$user->setDateOfBirth(null);
//$user->setBiography($noDataLabel);
$user->setFacebookData($noDataLabel);
/*$user->setFacebookData($noDataLabel);
$user->setFacebookName($noDataLabel);
$user->setFacebookUid($noDataLabel);
$user->setFacebookUid($noDataLabel);*/
//$user->setImageName($noDataLabel);
//$user->setTwoStepVerificationCode($noDataLabel);
$user->setGender($noDataLabel);
$user->setGplusData($noDataLabel);
//$user->setGender($noDataLabel);
/*$user->setGplusData($noDataLabel);
$user->setGplusName($noDataLabel);
$user->setGplusUid($noDataLabel);
$user->setGplusUid($noDataLabel);*/
$user->setLocale($noDataLabel);
$user->setTimezone($noDataLabel);
$user->setTwitterData($noDataLabel);
/*$user->setTwitterData($noDataLabel);
$user->setTwitterName($noDataLabel);
$user->setTwitterUid($noDataLabel);
$user->setTwitterUid($noDataLabel);*/
$user->setWebsite($noDataLabel);
$user->setToken($noDataLabel);
//$user->setToken($noDataLabel);
$courses = $user->getCourses();
$list = [];

Loading…
Cancel
Save