Symfony Exception

TypeError

HTTP 500 Internal Server Error

Return value of App\Repository\LeagueRepository::findBySeasonIdAndLeagueName() must be an instance of App\Entity\League, null returned

Exception

TypeError

  1.             ->andWhere('l.name = :name')
  2.             ->andWhere('season = :season_id')
  3.             ->setParameter('season_id'$season_id)
  4.             ->setParameter('name'$leagueName)
  5.             ->getQuery()
  6.             ->getOneOrNullResult();
  7.     }
  8.     /**
  9.      * @param $season_id
  10.      * @return League[]|int|mixed|string
LeagueRepository->findBySeasonIdAndLeagueName() in src/Controller/Main/LeagueController.php (line 40)
  1.      * @throws NonUniqueResultException
  2.      */
  3.     public function league(EntityManagerInterface $entityManagerint $season_idstring $name): Response
  4.     {
  5.         $leagueRepository $entityManager->getRepository('App:League');
  6.         $league $leagueRepository->findBySeasonIdAndLeagueName($season_id$name);
  7.         if (!$league) {
  8.             throw $this->createNotFoundException('League not found.');
  9.         }
  10.         return $this->render('main/league/single.html.twig', [
  11.             'controller_name' => 'LeagueController',
  1.         $this->dispatcher->dispatch($eventKernelEvents::CONTROLLER_ARGUMENTS);
  2.         $controller $event->getController();
  3.         $arguments $event->getArguments();
  4.         // call controller
  5.         $response $controller(...$arguments);
  6.         // view
  7.         if (!$response instanceof Response) {
  8.             $event = new ViewEvent($this$request$type$response);
  9.             $this->dispatcher->dispatch($eventKernelEvents::VIEW);
  1.     public function handle(Request $requestint $type HttpKernelInterface::MASTER_REQUESTbool $catch true)
  2.     {
  3.         $request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
  4.         try {
  5.             return $this->handleRaw($request$type);
  6.         } catch (\Exception $e) {
  7.             if ($e instanceof RequestExceptionInterface) {
  8.                 $e = new BadRequestHttpException($e->getMessage(), $e);
  9.             }
  10.             if (false === $catch) {
  1.         $this->boot();
  2.         ++$this->requestStackSize;
  3.         $this->resetServices true;
  4.         try {
  5.             return $this->getHttpKernel()->handle($request$type$catch);
  6.         } finally {
  7.             --$this->requestStackSize;
  8.         }
  9.     }
Kernel->handle() in public/index.php (line 28)
  1.     Request::setTrustedHosts([$trustedHosts]);
  2. }
  3. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
  4. $request Request::createFromGlobals();
  5. $response $kernel->handle($request);
  6. $response->send();
  7. $kernel->terminate($request$response);

Logs

No log messages

Stack Trace

TypeError

TypeError:
Return value of App\Repository\LeagueRepository::findBySeasonIdAndLeagueName() must be an instance of App\Entity\League, null returned

  at src/Repository/LeagueRepository.php:39
  at App\Repository\LeagueRepository->findBySeasonIdAndLeagueName()
     (src/Controller/Main/LeagueController.php:40)
  at App\Controller\Main\LeagueController->league()
     (vendor/symfony/http-kernel/HttpKernel.php:157)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor/symfony/http-kernel/HttpKernel.php:79)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor/symfony/http-kernel/Kernel.php:195)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (public/index.php:28)