title: Return value of Myrepository must be an instance of MyEntity or null, array returned
body: <p>I'm using Symfony4 with doctrine, trying to fetch my data trough my repository</p>
  
  <p>I have the following query at my repository</p>
  
  <pre><code>public function findByToday($value): ?Clock
  {
  return $this-&gt;createQueryBuilder('c')
          -&gt;select('c')
          -&gt;where('c.clockIn BETWEEN :n1days AND :today')
          -&gt;andWhere('c.status = 0')
          -&gt;setParameter('today', date('Y-m-d h:i:s'))
          -&gt;setParameter('n1days', $value)
          -&gt;getQuery()
          -&gt;getArrayResult();
      }
  </code></pre>
  
  <p>My controller is</p>
  
  <pre><code>public function getToday(ClockRepository $repository)
  {
      $date = date('Y-m-d h:i:s', strtotime("-1 days"));
      $serializer = $this-&gt;get('jms_serializer');
      $clock = $repository-&gt;findByToday($date);
      return new Response ($serializer-&gt;serialize($clock, "json"));
  }
  </code></pre>
  
  <p>The response that i'm receiving is: "Return value of App\Repository\ClockRepository::findByToday() must be an instance of App\Entity\Clock or null, array returned (500 Internal Server Error)"</p>
  
  <p>I tried already to send the function as findByToday(array($date)); or build a new ArrayCollection in my entity constructor. </p>
  
  <p>I'm misplaced with this error.</p>
  
  <p>This is my entity</p>
  
  <pre><code>    &lt;?php
  
  namespace App\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * @ORM\Entity(repositoryClass="App\Repository\ClockRepository")
   */
  class Clock
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       */
      private $id;
  
      /**
       * @ORM\Column(type="datetime", nullable=true)
       */
      public $clockIn;
  
      /**
       * @ORM\Column(type="datetime", nullable=true)
       */
      public $clockOut;
  
      /**
       * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="clocks", cascade={"persist"})
       */
      private $username;
  
      /**
       * @ORM\Column(type="boolean", nullable=true)
       */
      private $status;
  
  
      public function getId(): ?int
      {
          return $this-&gt;id;
      }
  
      public function getClockIn(): ?\DateTimeInterface
      {
          return $this-&gt;clockIn;
      }
  
      public function setClockIn(?\DateTimeInterface $clockIn): self
      {
          $this-&gt;clockIn = $clockIn;
  
          return $this;
      }
  
      public function getClockOut(): ?\DateTimeInterface
      {
          return $this-&gt;clockOut;
      }
  
      public function setClockOut(?\DateTimeInterface $clockOut): self
      {
          $this-&gt;clockOut = $clockOut;
  
          return $this;
      }
  
      public function getUsername(): ?User
      {
          return $this-&gt;username;
      }
  
      public function setUsername(?User $username): self
      {
          $this-&gt;username = $username;
  
          return $this;
      }
  
      public function getStatus(): ?bool
      {
          return $this-&gt;status;
      }
  
      public function setStatus(?bool $status): self
      {
          $this-&gt;status = $status;
  
          return $this;
      }
  }
  </code></pre>
  
  <p>What i'm doing wrong?</p>
  
  <p>Thanks for your help.</p>