mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\EventBundle\Entity;
|
||||
|
||||
use ArrayIterator;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
@@ -21,13 +20,14 @@ use DateTime;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* Class Event.
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chill\EventBundle\Repository\EventRepository")
|
||||
*
|
||||
* @ORM\Table(name="chill_event_event")
|
||||
*
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Event implements HasCenterInterface, HasScopeInterface
|
||||
@@ -48,10 +48,10 @@ class Event implements HasCenterInterface, HasScopeInterface
|
||||
private ?\DateTime $date;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private ?int $id = null;
|
||||
@@ -68,6 +68,7 @@ class Event implements HasCenterInterface, HasScopeInterface
|
||||
|
||||
/**
|
||||
* @var Collection<Participation>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\EventBundle\Entity\Participation",
|
||||
* mappedBy="event")
|
||||
@@ -118,7 +119,7 @@ class Event implements HasCenterInterface, HasScopeInterface
|
||||
/**
|
||||
* Get date.
|
||||
*
|
||||
* @return DateTime
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
@@ -151,17 +152,15 @@ class Event implements HasCenterInterface, HasScopeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<Participation>
|
||||
* @return Collection<int, Participation>
|
||||
*/
|
||||
public function getParticipations(): \ArrayIterator|\Doctrine\Common\Collections\Collection|\Traversable
|
||||
public function getParticipations(): Collection
|
||||
{
|
||||
return new ArrayCollection(iterator_to_array($this->getParticipationsOrdered()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort Collection of Participations.
|
||||
*
|
||||
* @return ArrayIterator|Traversable
|
||||
*/
|
||||
public function getParticipationsOrdered(): \ArrayIterator|\Traversable
|
||||
{
|
||||
@@ -169,7 +168,7 @@ class Event implements HasCenterInterface, HasScopeInterface
|
||||
|
||||
uasort($iterator, static fn ($first, $second) => strnatcasecmp((string) $first->getPerson()->getFirstName(), (string) $second->getPerson()->getFirstName()));
|
||||
|
||||
return new ArrayIterator($iterator);
|
||||
return new \ArrayIterator($iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +222,7 @@ class Event implements HasCenterInterface, HasScopeInterface
|
||||
*
|
||||
* @return Event
|
||||
*/
|
||||
public function setDate(DateTime $date)
|
||||
public function setDate(\DateTime $date)
|
||||
{
|
||||
$this->date = $date;
|
||||
|
||||
|
@@ -19,34 +19,37 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Class EventType.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_event_event_type")
|
||||
*
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class EventType
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
*/
|
||||
private bool $active = true;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var Collection<Role>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\EventBundle\Entity\Role",
|
||||
* mappedBy="type")
|
||||
@@ -55,6 +58,7 @@ class EventType
|
||||
|
||||
/**
|
||||
* @var Collection<Status>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\EventBundle\Entity\Status",
|
||||
* mappedBy="type")
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\EventBundle\Entity;
|
||||
|
||||
use ArrayAccess;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
@@ -19,20 +18,19 @@ use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Class Participation.
|
||||
*
|
||||
* @ORM\Entity(
|
||||
* repositoryClass="Chill\EventBundle\Repository\ParticipationRepository")
|
||||
*
|
||||
* @ORM\Table(name="chill_event_participation")
|
||||
*
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterface
|
||||
class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
@@ -42,10 +40,10 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
private ?\Chill\EventBundle\Entity\Event $event = null;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private ?int $id = null;
|
||||
@@ -75,9 +73,8 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
*/
|
||||
public function getCenter()
|
||||
{
|
||||
if ($this->getEvent() === null) {
|
||||
throw new RuntimeException('The event is not linked with this instance. '
|
||||
. 'You should initialize the event with a valid center before.');
|
||||
if (null === $this->getEvent()) {
|
||||
throw new \RuntimeException('The event is not linked with this instance. You should initialize the event with a valid center before.');
|
||||
}
|
||||
|
||||
return $this->getEvent()->getCenter();
|
||||
@@ -85,10 +82,8 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
|
||||
/**
|
||||
* Get event.
|
||||
*
|
||||
* @return Event
|
||||
*/
|
||||
public function getEvent()
|
||||
public function getEvent(): null|Event
|
||||
{
|
||||
return $this->event;
|
||||
}
|
||||
@@ -106,7 +101,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
/**
|
||||
* Get lastUpdate.
|
||||
*
|
||||
* @return DateTime
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getLastUpdate()
|
||||
{
|
||||
@@ -125,10 +120,8 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
|
||||
/**
|
||||
* Get role.
|
||||
*
|
||||
* @return Role
|
||||
*/
|
||||
public function getRole()
|
||||
public function getRole(): null|Role
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
@@ -138,9 +131,8 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
*/
|
||||
public function getScope()
|
||||
{
|
||||
if ($this->getEvent() === null) {
|
||||
throw new RuntimeException('The event is not linked with this instance. '
|
||||
. 'You should initialize the event with a valid center before.');
|
||||
if (null === $this->getEvent()) {
|
||||
throw new \RuntimeException('The event is not linked with this instance. You should initialize the event with a valid center before.');
|
||||
}
|
||||
|
||||
return $this->getEvent()->getCircle();
|
||||
@@ -148,10 +140,8 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
|
||||
/**
|
||||
* Get status.
|
||||
*
|
||||
* @return Status
|
||||
*/
|
||||
public function getStatus()
|
||||
public function getStatus(): null|Status
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
@@ -164,7 +154,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
*/
|
||||
public function isConsistent(ExecutionContextInterface $context)
|
||||
{
|
||||
if ($this->getEvent() === null || $this->getRole() === null || $this->getStatus() === null) {
|
||||
if (null === $this->getEvent() || null === $this->getRole() || null === $this->getStatus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -189,7 +179,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
|
||||
public function offsetExists(mixed $offset): bool
|
||||
{
|
||||
return in_array($offset, [
|
||||
return \in_array($offset, [
|
||||
'person', 'role', 'status', 'event',
|
||||
], true);
|
||||
}
|
||||
@@ -204,7 +194,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
'role' => $this->getRole(),
|
||||
'status' => $this->getStatus(),
|
||||
'event' => $this->getEvent(),
|
||||
default => throw new \LogicException("this offset does not exists : " . $offset),
|
||||
default => throw new \LogicException('this offset does not exists : '.$offset),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -241,11 +231,9 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
/**
|
||||
* Set event.
|
||||
*
|
||||
* @param Event $event
|
||||
*
|
||||
* @return Participation
|
||||
*/
|
||||
public function setEvent(?Event $event = null)
|
||||
public function setEvent(Event $event = null)
|
||||
{
|
||||
if ($this->event !== $event) {
|
||||
$this->update();
|
||||
@@ -259,11 +247,9 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
/**
|
||||
* Set person.
|
||||
*
|
||||
* @param Person $person
|
||||
*
|
||||
* @return Participation
|
||||
*/
|
||||
public function setPerson(?Person $person = null)
|
||||
public function setPerson(Person $person = null)
|
||||
{
|
||||
if ($person !== $this->person) {
|
||||
$this->update();
|
||||
@@ -277,11 +263,9 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
/**
|
||||
* Set role.
|
||||
*
|
||||
* @param Role $role
|
||||
*
|
||||
* @return Participation
|
||||
*/
|
||||
public function setRole(?Role $role = null)
|
||||
public function setRole(Role $role = null)
|
||||
{
|
||||
if ($role !== $this->role) {
|
||||
$this->update();
|
||||
@@ -294,11 +278,9 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
/**
|
||||
* Set status.
|
||||
*
|
||||
* @param Status $status
|
||||
*
|
||||
* @return Participation
|
||||
*/
|
||||
public function setStatus(?Status $status = null)
|
||||
public function setStatus(Status $status = null)
|
||||
{
|
||||
if ($this->status !== $status) {
|
||||
$this->update();
|
||||
@@ -316,7 +298,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
*/
|
||||
protected function update()
|
||||
{
|
||||
$this->lastUpdate = new DateTime('now');
|
||||
$this->lastUpdate = new \DateTime('now');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -17,28 +17,30 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Class Role.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_event_role")
|
||||
*
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Role
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
*/
|
||||
private bool $active = true;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private $name;
|
||||
@@ -121,11 +123,9 @@ class Role
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @param EventType $type
|
||||
*
|
||||
* @return Role
|
||||
*/
|
||||
public function setType(?EventType $type = null)
|
||||
public function setType(EventType $type = null)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
|
@@ -17,28 +17,30 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Class Status.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_event_status")
|
||||
*
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Status
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
*/
|
||||
private bool $active = true;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private $name;
|
||||
@@ -121,11 +123,9 @@ class Status
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @param EventType $type
|
||||
*
|
||||
* @return Status
|
||||
*/
|
||||
public function setType(?EventType $type = null)
|
||||
public function setType(EventType $type = null)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
|
Reference in New Issue
Block a user