fix syntax php7

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

View File

@ -33,6 +33,7 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\ConstraintViolationListInterface;
/** /**
* Class AccompanyingPeriodController * Class AccompanyingPeriodController
@ -56,12 +57,8 @@ class AccompanyingPeriodController extends AbstractController
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
} }
/** public function listAction(int $person_id): Response
* @return Response
*/
public function listAction(int $person_id)
{ {
$person = $this->_getPerson($person_id); $person = $this->_getPerson($person_id);
$event = new PrivacyEvent($person, [ $event = new PrivacyEvent($person, [
@ -76,12 +73,8 @@ class AccompanyingPeriodController extends AbstractController
]); ]);
} }
/** public function createAction(int $person_id, Request $request): Response
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
*/
public function createAction(int $person_id, Request $request)
{ {
$person = $this->_getPerson($person_id); $person = $this->_getPerson($person_id);
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person, $this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person,
@ -138,9 +131,10 @@ class AccompanyingPeriodController extends AbstractController
} }
/** /**
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response|\Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws Exception
*/ */
public function updateAction(int $person_id, int $period_id, Request $request){ public function updateAction(int $person_id, int $period_id, Request $request): Response
{
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
/** @var AccompanyingPeriod $accompanyingPeriod */ /** @var AccompanyingPeriod $accompanyingPeriod */
@ -203,10 +197,9 @@ class AccompanyingPeriodController extends AbstractController
} }
/** /**
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
* @throws \Exception * @throws \Exception
*/ */
public function closeAction(int $person_id, Request $request) public function closeAction(int $person_id, Request $request): Response
{ {
$person = $this->_getPerson($person_id); $person = $this->_getPerson($person_id);
@ -287,10 +280,8 @@ class AccompanyingPeriodController extends AbstractController
]); ]);
} }
/** private function _validatePerson(Person $person): ConstraintViolationListInterface
* @return \Symfony\Component\Validator\ConstraintViolationListInterface {
*/
private function _validatePerson(Person $person) {
$errors = $this->get('validator')->validate($person, null, $errors = $this->get('validator')->validate($person, null,
['Default']); ['Default']);
$errors_accompanying_period = $this->get('validator')->validate($person, null, $errors_accompanying_period = $this->get('validator')->validate($person, null,
@ -303,10 +294,8 @@ class AccompanyingPeriodController extends AbstractController
return $errors; return $errors;
} }
/** public function openAction(int $person_id, Request $request): Response
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response {
*/
public function openAction($person_id, Request $request) {
$person = $this->_getPerson($person_id); $person = $this->_getPerson($person_id);
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person, $this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person,
@ -382,10 +371,7 @@ class AccompanyingPeriodController extends AbstractController
]); ]);
} }
/** public function reOpenAction(int $person_id, int $period_id, Request $request): Response
* @return object|\Symfony\Component\HttpFoundation\RedirectResponse|Response
*/
public function reOpenAction(int $person_id, int $period_id, Request $request)
{ {
/** @var Person $person */ /** @var Person $person */
$person = $this->_getPerson($person_id); $person = $this->_getPerson($person_id);
@ -432,7 +418,7 @@ class AccompanyingPeriodController extends AbstractController
} }
/** /**
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the person is not found * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/ */
private function _getPerson(int $id) : Person private function _getPerson(int $id) : Person
{ {

View File

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