fix syntax php7

This commit is contained in:
2021-03-27 13:37:37 +01:00
parent 0a17011cc3
commit ea4e3c715e
2 changed files with 26 additions and 40 deletions

View File

@@ -169,15 +169,15 @@ class AccompanyingPeriod
*/
public function isOpen(): bool
{
if ($this->getOpeningDate() > new \DateTime('now')) {
if ($this->getOpeningDate() > new \DateTimeImmutable('now')) {
return false;
}
if ($this->getClosingDate() === null) {
return true;
} else {
return false;
}
return false;
}
/**
@@ -210,7 +210,7 @@ class AccompanyingPeriod
/**
* Set persons
*/
public function setPersons($persons) : AccompanyingPeriod
public function setPersons($persons): AccompanyingPeriod
{
$this->persons = $persons;
@@ -220,7 +220,7 @@ class AccompanyingPeriod
/**
* Get Persons
*/
public function getPersons() : Collection
public function getPersons(): Collection
{
return $this->persons;
}
@@ -228,7 +228,7 @@ class AccompanyingPeriod
/**
* Return true if a given Person is associated
*/
public function containsPerson(Person $person) : bool
public function containsPerson(Person $person): bool
{
foreach ($this->persons as $p) {
if ($p === $person) { return true; }
@@ -242,7 +242,7 @@ class AccompanyingPeriod
* For consistency, you should use Person::addAccompanyingPeriod instead.
* @see Person::addAccompanyingPeriod
*/
public function addPerson(Person $person = null) : AccompanyingPeriod
public function addPerson(Person $person = null): AccompanyingPeriod
{
$this->persons[] = $person;
@@ -252,7 +252,7 @@ class AccompanyingPeriod
/**
* Remove person.
*/
public function removePerson(Person $person) : void
public function removePerson(Person $person): void
{
$this->persons->removeElement($person);
}
@@ -281,25 +281,25 @@ class AccompanyingPeriod
* This function test if the period is closed and if the period is the last
* for the given person
*/
public function canBeReOpened(Person $person) : bool
public function canBeReOpened(Person $person): bool
{
if ($this->isOpen() === true) {
return false;
}
dump('parcours fermé: '. $this->getId());
foreach ($this->getPersons() as $p) {
if ($p === $person) {
$periods = $p->getAccompanyingPeriodsOrdered();
return end($periods) === $this; // retourne TRUE si cette période est la dernière
return end($periods) === $this;
}
}
return false;
}
/**
*/
public function reOpen()
public function reOpen(): void
{
$this->setClosingDate(null);
$this->setClosingMotive(null);