Symfony 4 Notice: Trying to access array offset on value of type null

Viewed 4317

I got a project on Symfony 4, since i install that project on my new computer with the latest version of PHP 7.4, i have an error on some query but not in all my controller.

Heres the method in the controller

/**
 * @Route("/juge/{userId}/jugementCategorie/{id}", name="jugementCategorie")
 */
public function jugementCategorie($id, $userId, CategorieRepository $repoCat, ResultatRepository $repoResult, KaratekaRepository $repoKarateka)
{

    $actif = [];

    $categorie = $repoCat->find($id);
    $karatekas = $categorie->getKarateka();

    $resultats = $repoResult->findResultatCategorieJuge($id, $userId);
    $activeKarateka = $repoKarateka->findByActiveInCat($id);
    
    if(isset($activeKarateka)){
        $count = 0;
        foreach($activeKarateka->getResultats() as $resultat){
            if($resultat->getUser()->getId() == $userId && $resultat->getCategorie()->getId() == $id){
                $count++;                   
            }        
        }
        if($count == 0){
            $actif = $activeKarateka;
        }
    }
        
    return $this->render('juge/jugementCategorie.html.twig', [
        'categorieId' => $id,
        'actif' => $actif,
        'resultats' => $resultats,
    ]);
}

When i try to access this page i have this error

enter image description here

I got some ajax call that are not working when calling methods in that specific controller too.

0 Answers
Related