fix: SA: Fix "might not be defined" rule.

SA stands for Static Analysis.
This commit is contained in:
Pol Dellaiera
2021-11-16 11:41:12 +01:00
parent a7b96f1756
commit f8aeb08594
14 changed files with 365 additions and 620 deletions

View File

@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Chill\TaskBundle\Controller;
use Chill\MainBundle\Entity\Scope;
@@ -41,14 +43,8 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface as TranslationTranslatorInterface;
/**
* Class SingleTaskController
*
* @package Chill\TaskBundle\Controller
*/
final class SingleTaskController extends AbstractController
{
private EventDispatcherInterface $eventDispatcher;
private TimelineBuilder $timelineBuilder;
private LoggerInterface $logger;
@@ -332,15 +328,12 @@ final class SingleTaskController extends AbstractController
* name="chill_task_single_task_delete"
* )
*/
public function deleteAction(
Request $request,
$id
) {
public function deleteAction(Request $request, $id) {
$course = null;
$em = $this->getDoctrine()->getManager();
$task = $em->getRepository(SingleTask::class)->find($id);
if (!$task) {
if (null === $task) {
throw $this->createNotFoundException('Unable to find Task entity.');
}
@@ -415,19 +408,24 @@ final class SingleTaskController extends AbstractController
}
}
if($task->getContext() instanceof Person){
return $this->render('@ChillTask/SingleTask/Person/confirm_delete.html.twig', array(
'task' => $task,
'delete_form' => $form->createView()
));
} else {
return $this->render('@ChillTask/SingleTask/AccompanyingCourse/confirm_delete.html.twig', array(
'task' => $task,
'delete_form' => $form->createView(),
'accompanyingCourse' => $course
));
if ($task->getContext() instanceof Person) {
return $this->render(
'@ChillTask/SingleTask/Person/confirm_delete.html.twig',
[
'task' => $task,
'delete_form' => $form->createView(),
]
);
}
return $this->render(
'@ChillTask/SingleTask/AccompanyingCourse/confirm_delete.html.twig',
[
'task' => $task,
'delete_form' => $form->createView(),
'accompanyingCourse' => $course
]
);
}
/**