apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -17,16 +17,11 @@ use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Chill\ReportBundle\Entity\Report;
use Chill\ReportBundle\Form\ReportType;
use DateTime;
use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Role\Role;
use function count;
/**
* Class ReportController.
@@ -64,11 +59,11 @@ class ReportController extends AbstractController
/**
* Create a new report for a given person and of a given type.
*
* @param int $person_id The id of the person.
* @param int $cf_group_id The id of the report type.
* @param Request $request The request containing the form data (from the newAction)
* @param int $person_id the id of the person
* @param int $cf_group_id the id of the report type
* @param Request $request The request containing the form data (from the newAction)
*
* @return Response The web page.
* @return Response the web page
*/
public function createAction($person_id, $cf_group_id, Request $request)
{
@@ -127,10 +122,10 @@ class ReportController extends AbstractController
/**
* Display a form to edit an existing Report entity.
*
* @param int|string $person_id The id of the person.
* @param int|string $report_id The id of the report.
* @param int|string $person_id the id of the person
* @param int|string $report_id the id of the report
*
* @return Response The web page.
* @return Response the web page
*/
public function editAction(int|string $person_id, int|string $report_id)
{
@@ -140,16 +135,11 @@ class ReportController extends AbstractController
$report = $em->getRepository('ChillReportBundle:Report')->find($report_id);
if (!$report) {
throw $this->createNotFoundException(
$this->get('translator')->trans('Unable to find this report.')
);
throw $this->createNotFoundException($this->get('translator')->trans('Unable to find this report.'));
}
if ((int) $person_id !== (int) $report->getPerson()->getId()) {
throw new RuntimeException(
$this->get('translator')->trans('This is not the report of the person.'),
1
);
throw new \RuntimeException($this->get('translator')->trans('This is not the report of the person.'), 1);
}
$this->denyAccessUnlessGranted('CHILL_REPORT_UPDATE', $report);
@@ -174,8 +164,8 @@ class ReportController extends AbstractController
/**
* Return a csv file with all the reports of a given type.
*
* @param int $cf_group_id The id of the report type to export
* @param Request $request The request
* @param int $cf_group_id The id of the report type to export
* @param Request $request The request
*
* @return A csv file with all the reports of the selected type
*/
@@ -200,10 +190,10 @@ class ReportController extends AbstractController
/**
* List all the report entities for a given person.
*
* @param int $person_id The id of the person.
* @param Request $request The request
* @param int $person_id the id of the person
* @param Request $request The request
*
* @return Response The web page.
* @return Response the web page
*/
public function listAction($person_id, Request $request)
{
@@ -222,7 +212,7 @@ class ReportController extends AbstractController
$total = $em
->createQuery('SELECT COUNT(r.id) FROM ChillReportBundle:Report r '
. 'WHERE r.person = :person AND r.scope IN (:scopes) ')
.'WHERE r.person = :person AND r.scope IN (:scopes) ')
->setParameter('person', $person)
->setParameter('scopes', $reachableScopes)
->getSingleScalarResult();
@@ -256,11 +246,11 @@ class ReportController extends AbstractController
/**
* Display a form for creating a new report for a given person and of a given type.
*
* @param int $person_id The id of the person.
* @param int $cf_group_id The id of the report type.
* @param Request $request The request
* @param int $person_id the id of the person
* @param int $cf_group_id the id of the report type
* @param Request $request The request
*
* @return Response The web page.
* @return Response the web page
*/
public function newAction($person_id, $cf_group_id, Request $request)
{
@@ -289,7 +279,7 @@ class ReportController extends AbstractController
$entity = new Report();
$entity->setUser($this->get('security.token_storage')->getToken()->getUser());
$entity->setDate(new DateTime('now'));
$entity->setDate(new \DateTime('now'));
$entity->setCFGroup($cFGroup);
@@ -305,10 +295,10 @@ class ReportController extends AbstractController
/**
* Display a form for selecting which type of report to add for a given person.
*
* @param int $person_id The id of the person.
* @param Request $request The request
* @param int $person_id the id of the person
* @param Request $request The request
*
* @return Response The web page.
* @return Response the web page
*/
public function selectReportTypeAction($person_id, Request $request)
{
@@ -338,7 +328,7 @@ class ReportController extends AbstractController
$cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
->findByEntity(\Chill\ReportBundle\Entity\Report::class);
if (count($cFGroups) === 1) {
if (1 === \count($cFGroups)) {
return $this->redirectToRoute('report_new', ['person_id' => $person_id, 'cf_group_id' => $cFGroups[0]->getId()]);
}
@@ -372,7 +362,7 @@ class ReportController extends AbstractController
*
* @param Request $request The request
*
* @return Response The web page.
* @return Response the web page
*/
public function selectReportTypeForExportAction(Request $request)
{
@@ -387,7 +377,7 @@ class ReportController extends AbstractController
$cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
->findByEntity(\Chill\ReportBundle\Entity\Report::class);
if (count($cFGroups) === 1) {
if (1 === \count($cFGroups)) {
return $this->redirectToRoute('report_export_list', ['cf_group_id' => $cFGroups[0]->getId()]);
}
@@ -416,10 +406,10 @@ class ReportController extends AbstractController
/**
* Web page for editing an existing report.
*
* @param int $person_id The id of the person.
* @param int $report_id The id of the report.
* @param int $person_id the id of the person
* @param int $report_id the id of the report
*
* @return Response The web page.
* @return Response the web page
*/
public function updateAction($person_id, $report_id, Request $request)
{
@@ -428,9 +418,7 @@ class ReportController extends AbstractController
$report = $em->getRepository('ChillReportBundle:Report')->find($report_id);
if (!$report) {
throw $this->createNotFoundException(
$this->get('translator')->trans('Unable to find this report.')
);
throw $this->createNotFoundException($this->get('translator')->trans('Unable to find this report.'));
}
$this->denyAccessUnlessGranted('CHILL_REPORT_UPDATE', $report);
@@ -478,10 +466,10 @@ class ReportController extends AbstractController
/**
* Find and display a report.
*
* @param int $report_id The id of the report.
* @param int $person_id The id of the person.
* @param int $report_id the id of the report
* @param int $person_id the id of the person
*
* @return Response The web page.
* @return Response the web page
*/
public function viewAction($report_id, $person_id)
{
@@ -492,9 +480,7 @@ class ReportController extends AbstractController
$entity = $em->getRepository('ChillReportBundle:Report')->find($report_id);
if (!$entity || !$person) {
throw $this->createNotFoundException(
$this->get('translator')->trans('Unable to find this report.')
);
throw $this->createNotFoundException($this->get('translator')->trans('Unable to find this report.'));
}
$this->denyAccessUnlessGranted('CHILL_REPORT_SEE', $entity);
@@ -537,7 +523,7 @@ class ReportController extends AbstractController
/**
* Creates a form to edit a Report entity.
*
* @param Report $entity The report to edit.
* @param Report $entity the report to edit
*
* @return \Symfony\Component\Form\Form The form
*/