Rector: apply rules for doctrine code quality

This commit is contained in:
Julien Fastré 2023-08-31 10:35:52 +02:00
parent bc9b7b1776
commit e4e52234ad
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
32 changed files with 74 additions and 92 deletions

View File

@ -26,6 +26,7 @@ return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_82,
\Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_44,
\Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_CODE_QUALITY,
]);
// some routes are added twice if it remains activated

View File

@ -36,7 +36,7 @@ class ActivityReasonCategory implements \Stringable
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @var string

View File

@ -55,7 +55,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
* @ORM\Column(type="integer")
* @Groups({"read"})
*/
private $id;
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Location::class)

View File

@ -41,7 +41,7 @@ class CancelReason
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
private ?int $id = null;
/**
* @ORM\Column(type="json")

View File

@ -45,7 +45,7 @@ class CustomField
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @var array
@ -64,7 +64,7 @@ class CustomField
*
* @ORM\Column(type="float")
*/
private $ordering;
private ?float $ordering = null;
/**
* @ORM\Column(type="boolean")
@ -76,14 +76,14 @@ class CustomField
*
* @ORM\Column(type="string", length=255)
*/
private $slug;
private ?string $slug = null;
/**
* @var string
*
* @ORM\Column(type="string", length=255)
*/
private $type;
private ?string $type = null;
/**
* Get customFieldGroup.

View File

@ -42,7 +42,7 @@ class Option
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @ORM\Column(type="string", length=50, name="internal_key")

View File

@ -34,14 +34,14 @@ class CustomFieldsDefaultGroup
*
* sf4 check: option inversedBy="customFields" return inconsistent error mapping !!
*/
private $customFieldsGroup;
private ?\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup $customFieldsGroup = null;
/**
* @var string
*
* @ORM\Column(type="string", length=255)
*/
private $entity;
private ?string $entity = null;
/**
* @var int
@ -50,7 +50,7 @@ class CustomFieldsDefaultGroup
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* Get customFieldsGroup.

View File

@ -46,7 +46,7 @@ class CustomFieldsGroup
*
* @ORM\Column(type="string", length=255)
*/
private $entity;
private ?string $entity = null;
/**
* @var int
@ -55,7 +55,7 @@ class CustomFieldsGroup
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @var array

View File

@ -54,7 +54,7 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
private ?int $id = null;
/**
* @ORM\ManyToOne(
@ -83,10 +83,8 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*
* @var \Chill\PersonBundle\Entity\user The user who encoded the exif_read_data
*/
private $user;
private ?\Chill\MainBundle\Entity\User $user = null;
public function getCategory(): ?DocumentCategory
{

View File

@ -24,7 +24,7 @@ class DocumentCategory
*
* @var string The class of the document (ie Chill\DocStoreBundle\PersonDocument)
*/
private $documentClass;
private ?string $documentClass = null;
/**
* @ORM\Column(type="json")

View File

@ -33,7 +33,7 @@ class PersonDocument extends Document implements HasCenterInterface, HasScopeInt
*
* @var \Chill\MainBundle\Entity\Scope The document's center
*/
private $scope;
private ?\Chill\MainBundle\Entity\Scope $scope = null;
public function getCenter()
{

View File

@ -516,7 +516,7 @@ class EventController extends AbstractController
'A5' => 'Circle',
'B5' => $event->getCircle()->getName()[$trans],
'A6' => 'Moderator',
'B6' => $event->getModerator() ? $event->getModerator()->getUsernameCanonical() : null,
'B6' => null !== $event->getModerator() ? $event->getModerator()->getUsernameCanonical() : null,
];
foreach ($headerValues as $k => $value) {

View File

@ -45,7 +45,7 @@ class Event implements HasCenterInterface, HasScopeInterface
/**
* @ORM\Column(type="datetime")
*/
private ?\DateTime $date = null;
private ?\DateTime $date;
/**
* @var int
@ -54,19 +54,17 @@ class Event implements HasCenterInterface, HasScopeInterface
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @var User
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*/
private $moderator;
private ?\Chill\MainBundle\Entity\User $moderator = null;
/**
* @var string
* @ORM\Column(type="string", length=150)
*/
private $name;
private ?string $name = null;
/**
* @var Collection<Participation>
@ -137,10 +135,7 @@ class Event implements HasCenterInterface, HasScopeInterface
return $this->id;
}
/**
* @return int
*/
public function getModerator()
public function getModerator(): User|null
{
return $this->moderator;
}
@ -235,12 +230,7 @@ class Event implements HasCenterInterface, HasScopeInterface
return $this;
}
/**
* @param int $moderator
*
* @return Event
*/
public function setModerator($moderator)
public function setModerator(User $moderator): self
{
$this->moderator = $moderator;

View File

@ -26,9 +26,9 @@ class EventType
{
/**
* @var bool
* @ORM\Column(type="boolean")
* @ORM\Column(type="boolean", nullable=false)
*/
private $active;
private bool $active = true;
/**
* @var int
@ -37,7 +37,7 @@ class EventType
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @var array

View File

@ -48,7 +48,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @ORM\Column(type="datetime")

View File

@ -24,9 +24,9 @@ class Role
{
/**
* @var bool
* @ORM\Column(type="boolean")
* @ORM\Column(type="boolean", nullable=false)
*/
private $active;
private bool $active = true;
/**
* @var int
@ -35,7 +35,7 @@ class Role
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @var array

View File

@ -24,9 +24,9 @@ class Status
{
/**
* @var bool
* @ORM\Column(type="boolean")
* @ORM\Column(type="boolean", nullable=false)
*/
private $active;
private bool $active = true;
/**
* @var int
@ -35,7 +35,7 @@ class Status
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @var array

View File

@ -35,7 +35,7 @@ class CommentEmbeddable
* @var int
* @ORM\Column(type="integer", nullable=true)
*/
private $userId;
private ?int $userId = null;
public function getComment(): ?string
{

View File

@ -47,14 +47,14 @@ class PermissionsGroup
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @var string
*
* @ORM\Column(type="string", length=255)
* @ORM\Column(type="string", length=255, nullable=false, options={"default": ""})
*/
private $name;
private string $name = '';
/**
* @var Collection<RoleScope>

View File

@ -65,7 +65,7 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface
* @ORM\Column(type="string", length=100)
* @groups({"write", "read"})
*/
private $code;
private ?string $code = null;
/**
*
@ -87,7 +87,7 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface
* @ORM\GeneratedValue(strategy="AUTO")
* @groups({"write", "read"})
*/
private $id;
private ?int $id = null;
/**
* @var string
@ -95,7 +95,7 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface
* @ORM\Column(type="string", length=255, name="label")
* @groups({"write", "read"})
*/
private $name;
private ?string $name = null;
/**
*

View File

@ -249,8 +249,6 @@ class AccompanyingPeriod implements
private Collection $locationHistories;
/**
* @var DateTime
*
* @ORM\Column(type="date")
* @Groups({"read", "write", "docgen:read"})
* @Assert\LessThan(value="tomorrow", groups={AccompanyingPeriod::STEP_CONFIRMED})

View File

@ -51,21 +51,21 @@ class PersonHouseholdAddress
* @ORM\ManyToOne(targetEntity=Address::class)
* @ORM\JoinColumn(nullable=false)
*/
private $address;
private ?\Chill\MainBundle\Entity\Address $address = null;
/**
* @ORM\Id
* @ORM\ManyToOne(targetEntity=Household::class)
* @ORM\JoinColumn(nullable=false)
*/
private $household;
private ?\Chill\PersonBundle\Entity\Household\Household $household = null;
/**
* @ORM\Id
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=false)
*/
private $person;
private ?\Chill\PersonBundle\Entity\Person $person = null;
/**
* @ORM\Column(type="date_immutable")

View File

@ -158,12 +158,10 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The person's birthdate.
*
* @var DateTime
*
* @ORM\Column(type="date", nullable=true)
* @Birthdate
*/
private $birthdate;
private ?\DateTime $birthdate = null;
/**
* @var Collection<Charge>
@ -184,7 +182,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
private Collection $budgetResources;
/**
* @var Collection<Calendar>
* @var Collection<int, Calendar>
* @ORM\ManyToMany(
* targetEntity="Chill\CalendarBundle\Entity\Calendar",
* mappedBy="persons"
@ -397,8 +395,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The date of the last marital status change of the person.
*
* @var DateTime
*
* @ORM\Column(type="date", nullable=true)
* @Assert\Date
*/
@ -527,6 +523,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/
public function __construct()
{
$this->calendars = new \Doctrine\Common\Collections\ArrayCollection();
$this->accompanyingPeriodParticipations = new ArrayCollection();
$this->spokenLanguages = new ArrayCollection();
$this->addresses = new ArrayCollection();
@ -929,6 +926,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->budgetResources;
}
/**
* @return Collection<int, Calendar>
*/
public function getCalendars(): Collection
{
return $this->calendars;
}
public function getCenter(): ?Center
{
if (null !== $this->centerCurrent) {

View File

@ -65,7 +65,7 @@ class ResidentialAddress
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)

View File

@ -29,7 +29,7 @@ class PersonAltName
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @var string
@ -37,7 +37,7 @@ class PersonAltName
* @ORM\Column(name="key", type="string", length=255)
* @Groups({"write"})
*/
private $key;
private ?string $key = null;
/**
* @var string
@ -45,7 +45,7 @@ class PersonAltName
* @ORM\Column(name="label", type="text")
* @Groups({"write"})
*/
private $label;
private ?string $label = null;
/**
* @ORM\ManyToOne(

View File

@ -37,7 +37,7 @@ class PersonNotDuplicate
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")

View File

@ -43,7 +43,7 @@ class SocialIssue
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
private ?int $id = null;
/**
* @ORM\Column(type="float", name="ordering", options={"default": 0.0})

View File

@ -42,10 +42,9 @@ class Report implements HasCenterInterface, HasScopeInterface
private ?\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup $cFGroup = null;
/**
* @var DateTime
* @ORM\Column(type="datetime")
*/
private $date;
private ?\DateTime $date = null;
/**
* @var int
@ -54,7 +53,7 @@ class Report implements HasCenterInterface, HasScopeInterface
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
@ -101,10 +100,8 @@ class Report implements HasCenterInterface, HasScopeInterface
/**
* Get date.
*
* @return DateTime
*/
public function getDate()
public function getDate(): ?DateTime
{
return $this->date;
}

View File

@ -25,11 +25,9 @@ use Doctrine\ORM\Mapping as ORM;
class RecurringTask extends AbstractTask
{
/**
* @var DateTime
*
* @ORM\Column(name="first_occurence_end_date", type="date")
*/
private $firstOccurenceEndDate;
private ?\DateTime $firstOccurenceEndDate = null;
/**
* @var int
@ -38,21 +36,19 @@ class RecurringTask extends AbstractTask
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @var DateTime
*
* @ORM\Column(name="last_occurence_end_date", type="date")
*/
private $lastOccurenceEndDate;
private ?\DateTime $lastOccurenceEndDate = null;
/**
* @var string
*
* @ORM\Column(name="occurence_frequency", type="string", length=255)
*/
private $occurenceFrequency;
private ?string $occurenceFrequency = null;
/**
*

View File

@ -46,13 +46,11 @@ use Symfony\Component\Validator\Constraints as Assert;
class SingleTask extends AbstractTask
{
/**
* @var DateTime
*
* @ORM\Column(name="end_date", type="date", nullable=true)
* @Assert\Date
* @Serializer\Groups({"read"})
*/
private $endDate;
private ?\DateTime $endDate = null;
/**
* @var int
@ -62,7 +60,7 @@ class SingleTask extends AbstractTask
* @ORM\GeneratedValue(strategy="AUTO")
* @Serializer\Groups({"read"})
*/
private $id;
private ?int $id = null;
/**
* @ORM\ManyToOne(
@ -73,7 +71,6 @@ class SingleTask extends AbstractTask
private ?\Chill\TaskBundle\Entity\RecurringTask $recurringTask = null;
/**
* @var DateTime
*
* @ORM\Column(name="start_date", type="date", nullable=true)
* @Serializer\Groups({"read"})
@ -89,7 +86,7 @@ class SingleTask extends AbstractTask
* message="The start date must be before warning date"
* )
*/
private $startDate;
private ?\DateTime $startDate = null;
/**
* @var Collection<SingleTaskPlaceEvent>

View File

@ -48,7 +48,7 @@ class AbstractTaskPlaceEvent
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @ORM\Column(name="transition", type="string", length=255)

View File

@ -38,7 +38,7 @@ class SingleTaskPlaceEvent extends AbstractTaskPlaceEvent
* inversedBy="taskPlaceEvents"
* )
*/
protected $task;
protected ?\Chill\TaskBundle\Entity\SingleTask $task = null;
public function getTask(): SingleTask
{